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很友好,基本可以满足要求,想 ...
随机推荐
- TCP/IP模型各个层次的功能和协议
层次名称 功 能 协 议 应用层 (Application Layer) 负责实现一切与应用程序相关的功能,对应OSI参考模型的上三层 FTP(文件传输协议) HTTP(超文本传输协议 ...
- Object.wait()与Object.notify()的用法
http://www.cnblogs.com/xwdreamer/archive/2012/05/12/2496843.html 参考文献: object.wait()和object.notify() ...
- 设置div,td失去焦点
$(downobj).attr({"tabindex":"0"});还需要设置css样式outline:none;
- drawRect & layoutSubviews 调用时间
首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSub ...
- android Service Activity三种交互方式(付源码)(转)
android Service Activity三种交互方式(付源码) Android应用服务器OSBeanthread android Service Binder交互通信实例 最下边有源代码: ...
- FZU Problem 2029 买票问题(树状数组)
当我看到题目是5秒的时候,压根没有想树状数组,一直奔着模拟队列去想了,最后也没搞定,赛后看到大神的题解才恍然大悟,原来如此,题目中有明显的暗示,求前n项和,骤然感叹,自己太low... 果然还是要多做 ...
- 使用nginx负载平衡
1. 介绍 在许多应用中,负载平衡是一种常用的技术来优化利用资源最大化吞吐量,减少等待时间,并确保容错. 可以使用nginx的作为一种非常高效的HTTP负载平衡器,将流量分配到多个应用服务器上提高性能 ...
- 继续几道经典的js题(局部和全局变量,对象等)
1. //现有代码如下:var foo = 1;function main(){alert(foo);var foo = 2;alert(this.foo)this.foo = 3;}//1.请给出以 ...
- Shortest Path
Shortest Path Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- TCP与UDP的区别(转)
源:http://blog.chinaunix.net/uid-20745340-id-1878774.html 参考:TCP协议与UDP协议的区别 TCP与UDP的区别 中国移动.中国联通推行的GP ...