我已经做好了水晶报表,文件为1..rpt,我该怎么把它在WEB上通过按钮事件导出来呢,比如导为PDF文件?
弄了一下下午,还是没弄好,求教给个例子吧,谢谢了
弄了一下下午,还是没弄好,求教给个例子吧,谢谢了
解决方案 »
- 为什么解析收到的字符串 显示出来的是乱码方块?
- .net winform控件更新
- timer和 event 处理不同步
- 客户机器上没有安装sqlserver,软件要用到sqlserver,这个软件安装在客户机器上可以用吗
- 新建一个类,继承一个借口,如何直接全部列出继承的借口的所有方法??
- 事务(进程)与另一个进程已被死锁在 lock 资源上,且该事务已被选作死锁牺牲品。请重新运行该事务
- .Net2.0正式版本Express是到4月份过期么?
- 有没有byte型的list或是collection?
- pushsharp消息推送 c# 如何使用?
- gridview 第一列 手动赋值
- csharp 多串口解决方案
- 难题关于 AutoCompleteAttribute 属性!高手进
ReportDocument rpt=new ReportDocument();
rpt.Load(Server.MapPath(".") + "\\MyReport.rpt");
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat,Response,false,"MyReport");
我用了你的代码,可是,我还是不太明白["数据集中存放数据的那个表的名称"]是什么?
我的水晶报表是从两个库表来生成数据的,我该怎么写你所得那个["数据集中存放数据的那个表的名称"]?
this.reportDocument1.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile; SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
SaveFileDialog1.Filter = "Microsoft Office Excel 文件 (*.xls)|*.xls|Microsoft Office Word 文件 (*.doc)|*.doc|Microsoft Office RichText 文件 (*.rtf)|*.rtf|Adobe PDF 文件 (*.pdf)|*.pdf";
SaveFileDialog1.FilterIndex = 1; //默认Microsoft Office Excel
SaveFileDialog1.RestoreDirectory = true;
SaveFileDialog1.FileName = "报表_" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; //默认图片保存名称 Pic01 if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
{
switch (SaveFileDialog1.FilterIndex)
{
case 1:
this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;
break;
case 2:
this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.WordForWindows;
break;
case 3:
this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.RichText;
break;
case 4:
this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
break;
}
DiskOpts.DiskFileName = SaveFileDialog1.FileName;
this.reportDocument1.ExportOptions.DestinationOptions = DiskOpts;
this.reportDocument1.Export(); MessageBox.Show("数据导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
this.CrystalReportSource1.ReportDocument.SetDataSource(dsCase.Tables["数据集中存放数据的那个表的名称"]);
我用了你的代码,可是,我还是不太明白["数据集中存放数据的那个表的名称"]是什么?
我的水晶报表是从两个库表来生成数据的,我该怎么写你所得那个["数据集中存放数据的那个表的名称"]?
——————————————————————————————————————
我这里有个解决这个问题的方法你看看!
http://blog.csdn.net/pfworld/archive/2007/07/29/1715299.aspx
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath(".") + @"\kevin.rpt");
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "MyReport"); 我不过是把2楼兄弟的代码修改了一下,改了一个参数.这样就能导出成pdf了,而不是在pdf中打开.
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath(".") + @"\kevin.rpt");
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "MyReport");
这个方法,系统会说数据库登陆失败,我该怎么设置登陆用户名那些的呢?