//初始
            Report report1 = new Report();
            report1.Clear();
            string ReportFileName = GetReportFileName(Rep);
            //report1.Load(Environment.CurrentDirectory + "\\Report\\" + ReportFileName);
            report1.Load(Environment.CurrentDirectory + "\\" + ReportFileName);
            report1.RegisterData(ds);
            //report1.RegisterData(dtItem, "item");//report1.RegisterData(ds.Tables[1], "Detail");
            report1.GetDataSource("Detail").Enabled = true;
            report1.GetDataSource("Master").Enabled = true;
            report1.GetDataSource("Material").Enabled = true;
            report1.GetDataSource("SUM").Enabled = true;              DataBand dataBand1 = report1.FindObject("DataItem") as DataBand;
            if (dataBand1 == null)
            {
                Msg.ShowError("数据区对象不存在,检查(DataItem)是否存在!");
                return;
            }             PageHeaderBand PageHeader1 = report1.FindObject("PageHeader1") as PageHeaderBand;
            if (PageHeader1 == null)
            {
                Msg.ShowError("页眉对象不存在,检查(PageHeader1)是否存在!");
                return;
            }
            dataBand1.DataSource = report1.GetDataSource("Detail");             ////列标题位置参考对象
            TextObject TxtObjRow = report1.FindObject("TextData") as TextObject;
            if (TxtObjRow == null)
            {
                Msg.ShowError("参照对象不存在,检查(TxtObjRow)是否存在!");
                return;
            }
            float iLeft = TxtObjRow.Left;
            float iTop = TxtObjRow.Top;
            float iWidth = TxtObjRow.Width;
            float iHeight = TxtObjRow.Height;             //列位置参考对象
            TextObject TextHeadRow = report1.FindObject("TextHead") as TextObject;
            if (TextHeadRow == null)
            {
                Msg.ShowError("参照对象不存在,检查(TextHead)是否存在!");
                return;
            }
            float iLeft2 = TextHeadRow.Left;
            float iTop2 = TextHeadRow.Top;
            float iWidth2 = TextHeadRow.Width;
            float iHeight2 = TextHeadRow.Height;             DataSourceBase frxSource = report1.GetDataSource("Detail");
            float AutoWith = 0;
            if (AtuoSize == true)
            {
                AutoWith = (float)198 / (frxSource.Columns.Count -9);
            }
            else
            {
                AutoWith = 10;
            }             //对数据区的列自动生成,加载到报表中
            int k = 0;
            for (int i = 0; i < frxSource.Columns.Count; i = i + 1)
            {
                //重新设置数据源列别名,由于传入别名重复。默认情况,dataTable列是caption 自动对应的fastreport数据源列的别名      
                frxSource.Columns[i].Alias = frxSource.Columns[i].Name;
                string col = frxSource.Columns[i].Name;
                string colCaption = col.Replace("_1", "");
                if (col == "ID" || col == "MaterialID" || col == "MaterialCode" || col == "MaterialName" ||
                      col == "Grade" || col == "LR" || col == "LenType" || col == "Sort" || col == "Com")
                {
                    continue;
                }                 
                //if (col == "Row") continue;                 string sName = "[" + frxSource.Alias + "." + col + "]";
                //数据区设置
                TextObject txtObject = new TextObject();
                txtObject.Name = col;
                txtObject.Border.Lines = BorderLines.All;
                txtObject.HorzAlign = HorzAlign.Center;
                txtObject.VertAlign = VertAlign.Center;
                txtObject.Font = new Font("宋体", 9.0f);
                txtObject.EvenStyle = "Style1";
                //txtObject.CreateUniqueName();
                txtObject.Bounds = new RectangleF(k * Units.Millimeters * AutoWith, 0, Units.Millimeters * AutoWith, iHeight);
                txtObject.Text = sName;
                txtObject.HideZeros = true;//当为0,设置空
                //设置打印内容格式
                if (col == "Sph" || col == "row")
                {                 }
                else
                {
                    NumberFormat fn = new NumberFormat();
                    fn.UseLocale = false;
                    fn.DecimalDigits = 1;
                    fn.DecimalSeparator ="null" ;
                    txtObject.Format = fn;
                }
                dataBand1.Objects.Add(txtObject);                 //Head列区设置
                TextObject txtObject1 = new TextObject();
                txtObject1.Name = "txt" + col;
                //txtObject1.CreateUniqueName();
                txtObject1.Border.Lines = BorderLines.All;
                txtObject1.HorzAlign = HorzAlign.Center;
                txtObject1.VertAlign = VertAlign.Center;
                txtObject1.Font = new Font("宋体", 9.0f);
                txtObject1.Bounds = new RectangleF((k) * Units.Millimeters * AutoWith, iTop2, Units.Millimeters * AutoWith, iHeight2);
                txtObject1.Text = colCaption;
                if (col == "Sph" || col == "row")
                {
                    txtObject1.Text = "球\\柱";                 }
                PageHeader1.Objects.Add(txtObject1);
                k++;             }

最新文章

  1. 超千个节点OpenStack私有云案例(1):CERN 5000+ 计算节点私有云
  2. 批量修改一张表格的多个sheet名
  3. Java知识积累3-XML的DOM解析修改和删除方法
  4. centos 安装 py pyhs2
  5. 002 C#学前入门
  6. 水晶报表设置FiledObject支持HTML格式的数据
  7. nginx添加未编译安装模块
  8. Spket在Eclipse/MyEclipse下的安装和配置(图文教程)
  9. linux 查看外网IP
  10. zend studio-如何更改字符集
  11. 使用json-lib进行Java和JSON之间的转换
  12. Apache Hadoop最佳实践和反模式
  13. 开源 iOS 项目分类索引大全
  14. 2080夹角有多大II
  15. Python 数据分析(二 本实验将学习利用 Python 数据聚合与分组运算,时间序列,金融与经济数据应用等相关知识
  16. python--函数式登录程序
  17. Codeforces Round #364 (Div. 2) E. Connecting Universities
  18. 操作系统--进程管理1--单个CPU情况
  19. linux个人情况总结
  20. 从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 二十二║Vue实战:个人博客第一版(axios+router)

热门文章

  1. Html基础详解之(jquery)
  2. php使用curl提交xml数据
  3. stock 仓位
  4. 实现RGB,CMY(K),YUV,YIQ,YCbCr颜色的转换算法
  5. 关于tomcat配置MyEclipse项目的配置代码
  6. tcp 的6个控制位
  7. 转: OGG Checkpoint 详解
  8. dom4j解析xml实例(2)
  9. 1381: Munching(BFS)
  10. Button MouseEvent颜色变化