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很友好,基本可以满足要求,想 ...
随机推荐
- JS跨域代码
//部分JS代码 $.ajax({ async: false, url: "http://www.xxxx.com/api/", type: "GET",//不 ...
- ubuntu上面安装eclipse android到adt下载方法
如果自动安装有问题的话,就需要手动安装,其实是差不多的,唯一不同的就是手动下载ADT插件包,http://dl.google.com/android/ADT-0.9.6.zip ,可以下载到. 版本号 ...
- Win下安装Cygwin中的SSH服务
windows和linux各有其优越性,可以安装在同一台电脑上,但切换要重启.同时拥有两台电脑,一台装win,一台装linux,自然非常好,但具备此条件的不多.本文介绍cygwin,它可以让你在win ...
- MDK下调试时提示AXF文件无法导入的解决方法(转)
源:http://blog.163.com/zhaojun_xf/blog/static/3005058020117784643555/ 在开发ARM项目中,很多工程师都不太喜欢使用MDK的调试模式, ...
- 蛙人(ple)
蛙人(ple) 题目描述 蛙人使用特殊设备潜水.设备中有一个气瓶,分两格:一格装氧气,另一格装氮气.留在水中有时间的限制,在深水中需要大量的氧气与氮气.为完成任务,蛙人必须安排好气瓶.每个气瓶可以用它 ...
- 使用JAVA NIO实现的UDP client和server
//////////////////////////////////////////////////////////////////////////////////////////////////// ...
- HDU 1114 Piggy-Bank(判断是否恰好装满的背包)
其实这道题在寒假自学训练赛的时候就做过,不过感觉现在的理解跟当时真的不一样,大一半年过去了,变了这么多,我们都在进步,一回头便走出了这么远... 好了,题目很简单,一个背包,装不满做一个标记就行了 # ...
- docker 1.12 版本 docker swarm 集群
博客已经迁移到 个人博客中 个人博客 更新地址: http://www.xf80.com/2016/10/25/docker-swarm-1.12/ docker 1.12 版本 的新特性 (1)do ...
- js 中调用 Object.prototype.toString()来检测对象的类型
1.使用toString()方法来检测对象类型 可以通过toString() 来获取每个对象的类型.为了每个对象都能通过 Object.prototype.toString() 来检测,需要以 Fun ...
- PAT (Advanced Level) 1079. Total Sales of Supply Chain (25)
树的遍历. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...