C# DevExpress gridControl1 中如何制作打印报表功能。。。。

hanjinkai 2009-03-19 04:35:18
C# DevExpress gridControl1 中如何制作打印报表功能。。。。
GridControl 数据绑定,如何制作导出报表或打印报表呢
...全文
714 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanjinkai 2009-03-19
  • 打赏
  • 举报
回复
是不是有可以直接利用的控件呢
hanjinkai 2009-03-19
  • 打赏
  • 举报
回复
首先,楼上的大哥谢谢,可以直接打印对吧,就是 软件界面上直接看到的数据(也就就是数据库中的数据),那又如何导出呢,,
zzrxxl 2009-03-19
  • 打赏
  • 举报
回复
看你要怎么打印了,设置报表还是直接打印你所看见的。
this.colPrice.Visible = false;
ReportCenter rc = new ReportCenter(this.gridControl, "报表名称");
this.colPrice.Visible = true;
rc.Preview();

类的代码



using System;
using System.Data;
using DevExpress.XtraPrintingLinks;
using DevExpress.XtraPrinting;
using System.Drawing;
using System.Drawing.Printing;

namespace MobileSell
{
class ReportCenter
{
private PrintingSystem printSystem;
private string mReportName;
private string mCondition;

public ReportCenter(IPrintable Printable)
{
printSystem = new PrintingSystem();
mReportName = "";
mCondition = "";
PrintableComponentLink pcl = new PrintableComponentLink();
pcl.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalHeaderArea);
pcl.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalFooterArea);
pcl.Component = Printable;
printSystem.Links.Add(pcl);
pcl.CreateDocument();

PrinterSettingsUsing pst = new PrinterSettingsUsing();
pst.UseMargins = false;
pst.UsePaperKind = false;
printSystem.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
printSystem.PageSettings.PaperName = "A4";
printSystem.PageSettings.LeftMargin = 2;
printSystem.PageSettings.RightMargin = 2;
printSystem.PageSettings.AssignDefaultPrinterSettings(pst);
}
public ReportCenter(IPrintable Printable, string ReportName)
{
printSystem = new PrintingSystem();
mReportName = ReportName;
mCondition = "";
PrintableComponentLink pcl = new PrintableComponentLink();
pcl.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalHeaderArea);
pcl.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalFooterArea);
pcl.Component = Printable;
printSystem.Links.Add(pcl);
pcl.CreateDocument();

PrinterSettingsUsing pst = new PrinterSettingsUsing();
pst.UseMargins = false;
pst.UsePaperKind = false;
printSystem.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
printSystem.PageSettings.PaperName = "A4";
printSystem.PageSettings.LeftMargin = 30;
printSystem.PageSettings.RightMargin = 30;
printSystem.PageSettings.AssignDefaultPrinterSettings(pst);
}
public void Print()
{
printSystem.Print();
}

public void Preview()
{
// FrmPreview frm = new FrmPreview(printSystem);
// frm.Show();
printSystem.PreviewForm.Show();
}
public void Designe()
{ }
}
}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧