百科狗-知识改变命运!
--

关于DevExpress的XtraReports的用法

一语惊醒梦中人1年前 (2023-12-16)阅读数 6#综合百科
文章标签报表宋体

XtraReport report = new XtraReport();// 建立报表实例

report.Dpi = 254F;

report.DataSource = dt;//设置报表数据源

report.ReportUnit = DevExpress.XtraReports.UI.ReportUnit.TenthsOfAMillimeter;

//report.PageHeight = 1169;

//report.PageWidth = 827;

if (radioGroup2.EditValue.ToString() == "A4")

report.PaperKind = System.Drawing.Printing.PaperKind.A4;

if (radioGroup2.EditValue.ToString() == "A5")

report.PaperKind = System.Drawing.Printing.PaperKind.A5;

report.Margins = new System.Drawing.Printing.Margins(107, 99, 99, 107);

//报表头

ReportHeaderBand reportHeader = new ReportHeaderBand();

reportHeader.Dpi = 254F;

//数据

DetailBand detail = new DetailBand();

detail.Dpi = 254F;

//页眉

PageHeaderBand pageHeader = new PageHeaderBand();

pageHeader.Dpi = 254F;

//页脚

PageFooterBand pageFooter = new PageFooterBand();

pageFooter.Dpi = 254F;

//分组头

GroupHeaderBand groupHeader = new GroupHeaderBand();

groupHeader.Dpi = 254F;

groupHeader.GroupFields.AddRange(new DevExpress.XtraReports.UI.GroupField[] { new DevExpress.XtraReports.UI.GroupField("箱号", DevExpress.XtraReports.UI.XRColumnSortOrder.Ascending)});

//分组尾

GroupFooterBand groupFooter = new GroupFooterBand();

groupFooter.Dpi = 254F;

//报表尾

ReportFooterBand reportFooter = new ReportFooterBand();

reportFooter.Dpi = 254F;

pageHeader.Height = Convert.ToInt32(spinEdit1.Value); ;

detail.Height = Convert.ToInt32(spinEdit2.Value);

pageFooter.Height = 50;

groupHeader.Height = 0;

groupFooter.Height = 50;

reportFooter.Height = 50;

report.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { reportHeader, detail, pageHeader, reportFooter, pageFooter, groupHeader, groupFooter });

//封面 DevExpress.XtraReports.UI.XRLabel A1 = new DevExpress.XtraReports.UI.XRLabel();

A1.Dpi = 254F;

A1.Font = new System.Drawing.Font("宋体", 36F, System.Drawing.FontStyle.Bold);

A1.Location = new System.Drawing.Point(0, 212);

A1.Name = "A1";

A1.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A1.ParentStyleUsing.UseFont = false;

A1.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 190);

A1.Text = "浙江XXX服饰股份有限公司";

A1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

report.Bands[BandKind.ReportHeader].Controls.Add(A1);

DevExpress.XtraReports.UI.XRLabel A2 = new DevExpress.XtraReports.UI.XRLabel();

A2.Dpi = 254F;

A2.Font = new System.Drawing.Font("宋体", 36F, System.Drawing.FontStyle.Bold);

A2.Location = new System.Drawing.Point(0, 466);

A2.Name = "A2";

A2.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A2.ParentStyleUsing.UseFont = false;

A2.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 148);

A2.Text = "装 箱 单";

A2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

report.Bands[BandKind.ReportHeader].Controls.Add(A2);

DevExpress.XtraReports.UI.XRLabel A3 = new DevExpress.XtraReports.UI.XRLabel();

A3.Dpi = 254F;

A3.Font = new System.Drawing.Font("宋体", 28F, System.Drawing.FontStyle.Bold);

A3.Location = new System.Drawing.Point(0, 762);

A3.Name = "A3";

A3.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A3.ParentStyleUsing.UseFont = false;

A3.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 127);

A3.Text = "订单号:" + str_HTBN;

A3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

report.Bands[BandKind.ReportHeader].Controls.Add(A3);

DevExpress.XtraReports.UI.XRLabel A4 = new DevExpress.XtraReports.UI.XRLabel();

A4.Dpi = 254F;

A4.Font = new System.Drawing.Font("宋体", 28F, System.Drawing.FontStyle.Bold);

A4.Location = new System.Drawing.Point(0, 910);

A4.Name = "A4";

A4.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A4.ParentStyleUsing.UseFont = false;

A4.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 127);

A4.Text = "客户名:" + str_KHName;

A4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

report.Bands[BandKind.ReportHeader].Controls.Add(A4);

DevExpress.XtraReports.UI.XRLabel A5 = new DevExpress.XtraReports.UI.XRLabel();

A5.Dpi = 254F;

A5.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold);

A5.Location = new System.Drawing.Point(0, 1058);

A5.Name = "A5";

A5.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A5.ParentStyleUsing.UseFont = false;

A5.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 127);

A5.Text = "共 " + hejixiangshu + " 箱( 方案编号: " + str_Fenzu + " )";

A5.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

report.Bands[BandKind.ReportHeader].Controls.Add(A5);

DevExpress.XtraReports.UI.XRLabel A6 = new DevExpress.XtraReports.UI.XRLabel();

A6.Dpi = 254F;

A6.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold);

A6.Location = new System.Drawing.Point(212, 1206);

A6.Name = "A5";

A6.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A6.ParentStyleUsing.UseFont = false;

A6.Size = new System.Drawing.Size(317, 106);

A6.Text = "其中:";

A6.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;

report.Bands[BandKind.ReportHeader].Controls.Add(A6);

DevExpress.XtraReports.UI.XRLabel A7 = new DevExpress.XtraReports.UI.XRLabel();

A7.Dpi = 254F;

A7.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold);

A7.Location = new System.Drawing.Point(0, 2286);

A7.Name = "A5";

A7.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A7.ParentStyleUsing.UseFont = false;

A7.Size = new System.Drawing.Size(report.PageWidth - (report.Margins.Left + report.Margins.Right) - 2, 148);

A7.Text = DateTime.Now.ToString("yyyy 年 MM 月 dd 日");

A7.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;

report.Bands[BandKind.ReportHeader].Controls.Add(A7);

DevExpress.XtraReports.UI.XRPageBreak A8 = new DevExpress.XtraReports.UI.XRPageBreak();

A8.Dpi = 254F; A8.Location = new System.Drawing.Point(0, 2455);

report.Bands[BandKind.ReportHeader].Controls.Add(A8);

//封面合计

int lie = -1;

int a = 529;//X

int b = 1206;//Y

int c = 508;//size x

int d = 106;//size y

for (int i = 5; i

{

if (dt.Columns[i].Caption != "长袖衬衫规格" && dt.Columns[i].Caption != "中袖衬衫规格" && dt.Columns[i].Caption != "短袖衬衫规格")

{

lie++;

DevExpress.XtraReports.UI.XRLabel A = new DevExpress.XtraReports.UI.XRLabel();

A.Dpi = 254F;

A.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold);

A.Location = new System.Drawing.Point(a, b + lie * d);

A.Name = "A" + i + "标";

A.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

A.ParentStyleUsing.UseFont = false;

A.Size = new System.Drawing.Size(c, d);

A.Text = dt.Columns[i].Caption + ":";

A.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;

report.Bands[BandKind.ReportHeader].Controls.Add(A);

DevExpress.XtraReports.UI.XRLabel B = new DevExpress.XtraReports.UI.XRLabel();

B.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", dt, dt.Columns[i].Caption, "") });

B.Dpi = 254F;

B.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold);

B.Location = new System.Drawing.Point(a + c, b + lie * d);

B.Name = "A" + i;

B.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254F);

B.ParentStyleUsing.UseFont = false;

B.Size = new System.Drawing.Size(c, d);

DevExpress.XtraReports.UI.XRSummary C = new DevExpress.XtraReports.UI.XRSummary();

C.FormatString = "{0} 件";

C.Running = DevExpress.XtraReports.UI.SummaryRunning.Report;

B.Summary = C;

B.Text = dt.Columns[i].Caption;

B.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;

report.Bands[BandKind.ReportHeader].Controls.Add(B);

}

}

int colCount = dt.Columns.Count;

//int[] cw = { 100, 100, 180, 100, 400 };

string p = spinEdit3.Value + "," + spinEdit4.Value + "," + spinEdit5.Value + ",100," + spinEdit6.Value;

string[] cw = p.Split(',');

int cw8 = 172;

int cw5 = Convert.ToInt32(cw[0]) + Convert.ToInt32(cw[1]) + Convert.ToInt32(cw[2]) + Convert.ToInt32(cw[3]) + Convert.ToInt32(cw[4]);

int colWidth = (report.PageWidth - (report.Margins.Left + report.Margins.Right) - cw5) / (colCount - chenshancount - 5);

if (colWidth

colWidth = (report.PageWidth - (report.Margins.Left + report.Margins.Right) - cw5 - chenshancount * cw8) / (colCount - 2 * chenshancount - 5);

else

关于DevExpress的XtraReports的用法

cw8 = colWidth;

国外的话水晶报表,SAP公司的商业报表工具,作为SAP“集团”下的报表组件模块。10年事前盛行一时,后被SAP收购。但水晶报表(Crystal Report)在理论上只支持单数据集,对多集的支持依赖于数据库的运算能力(叉乘与联合等或写存储过程),多库一般难以支持。

国内的话FineReport,目前国内报表软件领域发展最成熟也是市场份额最高的。IDC的报告里,17年甚至超过SAP,IBM,在这个细分领域,也是Gartner的BI选型市场指南里唯一推荐的报表工具。零代码开发,类似excel的设计方式,上手简单。尤其数据字典、实际值和显示值等的设计更是切入快速开发的要害,这些放在别的语言和体系下往往要大量代码才能实现且频繁需要的功能放在FineReport里却只是几个操作的事情。移动端报表+可视化大屏,FineReport做大屏有先天开发优势。

鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com

免责声明:我们致力于保护作者版权,注重分享,当前被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!邮箱:344225443@qq.com)

图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)