首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

水晶报表导出有关问题

2012-12-22 
水晶报表导出问题B/S模式:我用VS2010的水晶报表,CRforVS_13_0_1 安装起来的 string reportPath Server.M

水晶报表导出问题
B/S模式:
我用VS2010的水晶报表,CRforVS_13_0_1 安装起来的
 string reportPath = Server.MapPath("Report\\CrystalReport.rpt");
  //rptDoc.FileName = reportPath;
  rptDoc.Load(reportPath);
  ds.Merge(dbTitle);
  rptDoc.SetDataSource(ds);
  Viewer1.ReportSource = rptDoc;

调试之后,数据显示出来了。不过用水晶报表自带的导出功能的时候,提示我(未能使用您指定的选项导出。请检查选项并重试)

1)这个问题到底有哪些原因引起的
2)我能不能重写报表自带的导出功能

希望各位大大们能给出解决方案,谢谢啦!!
[最优解释]
Microsoft.Reporting.WinForms.Warning[] Warnings;
            string[] strStreamIds;
            string strMimeType;
            string strEncoding;
            string strFileNameExtension;

            byte[] bytes = this.rptViewer.LocalReport.Render("Excel", null, out strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings);

            string strFilePath = @"D:" + this.GetTimeStamp() + ".xls";

            using (System.IO.FileStream fs = new FileStream(strFilePath, FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }

            if (System.Windows.Forms.MessageBox.Show("Report Viewer: \r\n    Succeed to export the excel file!" + strFilePath + "\r\n    Do you want to open the file" + strFilePath + "?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                System.Diagnostics.Process.Start(strFilePath);
            }

热点排行