我是水晶报道的新手。我面临一个问题,我的报告显示没有数据,尽管数据集显示它在调试过程中确实有数据。我注意到在“m_rptViewReport.SetDataSource(ds);”行之后一切都出错了,它显示“HasRecords =功能评估已禁用,因为之前的功能评估已超时。您必须继续执行以重新启用功能评估晶体报告” 基本上,我正在尝试使用push方法将数据导出到xls文件。我正在使用VS2015,我的水晶报告汇编版本是13.0.3500.0
请看看我的代码
public bool ExportToFile(DataSet ds,string fileType)
{
try
{
object obj = null;
char[] split ={ '.' };
CrystalDecisions.CrystalReports.Engine.ReportDocument m_rptViewReport = null;
if (File.Exists(Request.PhysicalApplicationPath + "\\" + this.ReportFile))
{
try {
m_rptViewReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
m_rptViewReport.Load(Request.PhysicalApplicationPath + "\\" + this.ReportFile);
ds.WriteXml("D:\\testfile.XML", XmlWriteMode.WriteSchema); //the output XML file does have data
m_rptViewReport.SetDataSource(ds);//something went wrong after this line
}
catch (Exception ex) //nothing happened here
{
throw ex;
}
}
else
this.SetTextTitle(Resources.GetLanguage("msgNoFile") + " " + this.ReportFile);
if (m_rptViewReport.HasRecords){ //I added this line later and founded that the value is not TRUE
if (m_rptViewReport != null)
{
SetReportParameterValue(m_rptViewReport);
Response.ContentType = "application/vnd.ms-excel";
try {
m_rptViewReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, this.ReportCode);
}
catch (System.Threading.ThreadAbortException ex1)
{
//throw ex1;
}
}
}
return true;
}
catch(Exception ex)
{
return false;
}
}
任何帮助将不胜感激。
答案 0 :(得分:0)
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="1202px" ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" />
&#13;
您可以尝试从UI中删除报告的数据源,不要在水晶报表查看器中指定报表数据源。
使用上面的示例代码并删除Reportdatasource等,然后立即尝试。