关于.net上水晶报表导出成word格式文件的问题
以前曾成功地导出成为pdf格式,并且在浏览器里面打开了,现在想导出成word,代码如下:
// 在此处放置用户代码以初始化页面
crReport= new ReportDocument();
string fileName = demo.rpt
crReport.Load(fileName);
CRViewer.ReportSource= crReport;
ExportOptions crExport= new ExportOptions();
string ExportFile= "c:/report.doc";
ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts =
new DiskFileDestinationOptions();
exportOpts = crReport.ExportOptions;
// 设置导出格式。
exportOpts.ExportFormatType = ExportFormatType.WordforWindows;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
// 设置磁盘文件选项。
diskOpts.DiskFileName = ExportFile;
exportOpts.DestinationOptions = diskOpts;
crReport.Export ();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType= "application/msword
Response.WriteFile(ExportFile);
Response.Flush();
Response.Close();
System.IO.File.Delete(ExportFile);
现在倒是能导出成word,但是并没有在浏览器里面打开(这段代码是写在Page_Load)里面的。而且保存下来的word文档里面的内容出错,总是只能显示报表的第一页。应为我的报表比较宽(A3横向纸),所以有些列也没有显示出来,自己画的表格线也是乱七八糟的。
请各位指教,在此谢过!