//初始
            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++;             }

fastreport.net cdoe 自己的代码的更多相关文章

  1. Winform中使用FastReport的PictureObject时通过代码设置图片源并使Image图片旋转90度

    场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...

  2. FastReport.Net在Rozor中的应用

    Webconfig中配置 IIS6.0 <system.web> <httpHandlers> 下增加 <httpHandlers> <add path=&q ...

  3. fastreport代码转

    2016-07-08 //打印主从表数据 string file = Application.StartupPath @"\MasterDetail.frx"; rptMaster ...

  4. 使用fastreport以代码方式创建报表

    Report report = new Report();// register the "Products" tablereport.RegisterData(dataSet1. ...

  5. Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据

    场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...

  6. FastReport代码计算高度

    Dim iHeight As Double        Dim columnData_form As DataSourceBase             iHeight=Page1.TopMarg ...

  7. 使用FastReport打印二维码

    简单介绍一下该功能所在的项目背景:C#语言编写的WPF客户端应用程序,在“结账”模块中,打印出的收款小票上需要显示一个二维码,服务生拿着小票去找顾客,顾客可以选择现金.银行卡等普通支付方式,也可以直接 ...

  8. FastReport.Net 常用功能总汇

    一.常用控件 文本框:输入文字或表达式 表格:设置表格的行列数,输入数字或表达式 子报表:放置子报表后,系统会自动增加一个页面,你可以在此页面上设计需要的报表.系统在打印处理时,先按主报表打印,当碰到 ...

  9. FastReport自定义数据源及ListView控件的使用

    ##1.想批量生成一堆物资信息卡,效果如下图所示,fastreport可以一下全部生成,并且发现不用单独写东西, ##2.发现FastReport官方给出的Demo.exe很友好,基本可以满足要求,想 ...

随机推荐

  1. decompile elf

    no way, try,objdump --disassemble <elf file>

  2. DataSet和List<T> 泛型之间互相转换 (转载, 作者写的很好)

    /DataSet与泛型集合间的互相转换 //利用反射机制将DataTable的字段与自定义类型的公开属性互相赋值. //注意:从DataSet到IList<T>的转换,自定义类型的公开属性 ...

  3. Android tcpdump抓包应用实现

    Android tcpdump抓包应用实现   Android应用很多时候都会涉及到网络,在请求网络出错时,我们可以通过抓包来分析网络请求,返回的数据等,通常我们是用tcpdump这个工具来抓包,再通 ...

  4. 转:总结Selenium WebDriver中一些鼠标和键盘事件的使用

    在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...

  5. PAT (Advanced Level) 1044. Shopping in Mars (25)

    双指针. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  6. 第十七篇 --ANDROID DisplayManager 服务解析一

    ANDROID从版本4.2开始提供了一个显示管理服务DisplayManagerService,支持多种显示类型的多个显示器的镜像显示,包括内建的显示类型(本地).HDMI显示类型以及支持WIFI D ...

  7. mtp

    http://www.android.gs/mount-google-nexus-4-mtp-sd-card-on-ubuntu-and-other-linux-computers/ https:// ...

  8. Total Highway Distance

    Total Highway Distance 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playing a ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1001 The Country List

    #include<cstdio> #include<cstring> #include<cmath> #include<string> #include ...

  10. checkbox选择多数据传入后台时,怎样解析数据

    <input type="checkbox" name="test" value="值1" />显示的内容<input t ...