日期:2014-05-20  浏览次数:21057 次

水晶报表导出问题
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);
            }