fastreport.net cdoe 自己的代码
//初始
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 自己的代码的更多相关文章
- Winform中使用FastReport的PictureObject时通过代码设置图片源并使Image图片旋转90度
场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...
- FastReport.Net在Rozor中的应用
Webconfig中配置 IIS6.0 <system.web> <httpHandlers> 下增加 <httpHandlers> <add path=&q ...
- fastreport代码转
2016-07-08 //打印主从表数据 string file = Application.StartupPath @"\MasterDetail.frx"; rptMaster ...
- 使用fastreport以代码方式创建报表
Report report = new Report();// register the "Products" tablereport.RegisterData(dataSet1. ...
- Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据
场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...
- FastReport代码计算高度
Dim iHeight As Double Dim columnData_form As DataSourceBase iHeight=Page1.TopMarg ...
- 使用FastReport打印二维码
简单介绍一下该功能所在的项目背景:C#语言编写的WPF客户端应用程序,在“结账”模块中,打印出的收款小票上需要显示一个二维码,服务生拿着小票去找顾客,顾客可以选择现金.银行卡等普通支付方式,也可以直接 ...
- FastReport.Net 常用功能总汇
一.常用控件 文本框:输入文字或表达式 表格:设置表格的行列数,输入数字或表达式 子报表:放置子报表后,系统会自动增加一个页面,你可以在此页面上设计需要的报表.系统在打印处理时,先按主报表打印,当碰到 ...
- FastReport自定义数据源及ListView控件的使用
##1.想批量生成一堆物资信息卡,效果如下图所示,fastreport可以一下全部生成,并且发现不用单独写东西, ##2.发现FastReport官方给出的Demo.exe很友好,基本可以满足要求,想 ...
随机推荐
- Django: 之数据库完美解析
Python的web矿建有Django.Tornado.Flask等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定,模版引擎.缓存.Session等诸多功能. ...
- Linux 部署 Tomcat和JDK
一:安装jdk下载将jdk加压后放到/usr/local目录下: [root@master ~]#chmod 755 jdk-6u5-linux-x64.bin [root@master ~]# ./ ...
- 求余区间的求和类问题 离线+线段树 HDU4228
题目大意:给一个数组a,他的顺序是严格的单调增,然后有如下三个操作 ①加入一个val到a数组里面去,加入的位置就是a[i-1]<val<a[i+1] ②删除一个a[i]=val的值 ③查询 ...
- android:windowSoftInputMode属性使用 软键盘
android:windowSoftInputMode="adjustResize|stateHidden" windowSoftInputMode属性设置值说明. <act ...
- Cells Not Under Attack
Cells Not Under Attack Vasya has the square chessboard of size n × n and m rooks. Initially the ches ...
- 关于JSON.parse在ie6,ie7下未定义的issue
情况是这样的: 在ie6下出现一个js error,说是JSON.parse为定义,一查,才知道,ie6,ie7不支持JSON. solution:只要在使用JSON之前加载个json2.js就行了. ...
- Ubuntu + VMware=Linux虚拟机
1.工具 2.要点 3.问题 有时间再写
- JSP中EL表达式取值问题记录(已解决)
***************************2015-10-28 22:21************************* 问题描述如下: 在当前的jsp页面已经有了如下代码: < ...
- php自学笔记3
-------补充--------建议定义常量时,判断常量名是否被定义,用defined()判断,返回布尔型if(!defined("POEM")){//没定义过 define(& ...
- POJ 2976 Dropping tests 01分数规划 模板
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6373 Accepted: 2198 ...