首页 技术 正文
技术 2022年11月10日
0 收藏 978 点赞 4,239 浏览 5043 个字
  //初始
            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++;            }
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,074
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,551
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,399
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,811
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,892