报告的报告定义'& # 39;尚未指定

本文关键字:报告 未指定 定义 | 更新日期: 2023-09-27 18:09:04

我正在开发web应用程序,在我的应用程序中,我必须在没有预览的情况下打印RDLC。我的代码如下

    LocalReport report = new LocalReport();
    report.ReportEmbeddedResource = "TCESS.ESales.CommonLayer.Reports.HandlingBillReport.rdlc";
    report.ReportPath="TCESS.ESales.CommonLayer.Reports.HandlingBillReport.rdlc";
    SettlementOfAccountsDTO objSettlementOfAccountsDTO = ESalesUnityContainer.Container.Resolve<ISettlementOfAccountsService>().GetSettlementOfAccountsByAccId(32);
    if (objSettlementOfAccountsDTO.Account_Id > 0)
    {
        SetReportParametersForBill(objSettlementOfAccountsDTO, AccountReportViewer, report);
    }
    Export(report);
    m_currentPageIndex = 0;
    Print();

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding,
                        string mimeType, bool willSeek)
{
    Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
    m_streams.Add(stream);
    return stream;
}
private void Export(LocalReport report)
{
    string deviceInfo =
      "<DeviceInfo>" +
      "  <OutputFormat>EMF</OutputFormat>" +
      "  <PageWidth>8.5in</PageWidth>" +
      "  <PageHeight>11in</PageHeight>" +
      "  <MarginTop>0.25in</MarginTop>" +
      "  <MarginLeft>0.25in</MarginLeft>" +
      "  <MarginRight>0.25in</MarginRight>" +
      "  <MarginBottom>0.25in</MarginBottom>" +
      "</DeviceInfo>";
    Warning[] warnings;
    m_streams = new List<Stream>();
    report.Render("Image", deviceInfo, CreateStream, out warnings);
    foreach (Stream stream in m_streams)
        stream.Position = 0;
}
private void PrintPage(object sender, PrintPageEventArgs ev)
{
    Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
    ev.Graphics.DrawImage(pageImage, 0, 0);
    m_currentPageIndex++;
    ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
private void Print()
{
    const string printerName = "''''193.168.0.20''Printer_Q3";
    if (m_streams == null || m_streams.Count == 0)
        return;
    PrintDocument printDoc = new PrintDocument();
    printDoc.PrinterSettings.PrinterName = printerName;
    if (!printDoc.PrinterSettings.IsValid)
    {
        string msg = String.Format("Can't find printer '"{0}'".", printerName);
        Console.WriteLine(msg);
        return;
    }
    int i=0;
    foreach (Stream stream in m_streams)
    {
        Metafile pageImage = new Metafile(stream);
        pageImage.Save(Server.MapPath("~/Images/"+i.ToString()+".jpg"));
        i++;
    }    
    //printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
    //printDoc.Print();
}

我得到错误"未指定报告' '的报告定义"在

report.Render("Image", deviceInfo, CreateStream, out warnings);

报告的报告定义'& # 39;尚未指定

我在实例化要导出的报告时遇到了这个问题,必须像这样设置这个属性:

wrvReport.LocalReport.ReportEmbeddedResource = "CommonLayer.Reports.SalesByPrice.rdlc";

我看到的区别是.LocalReport是设置嵌入资源的子属性。

From MSDN:

内嵌报表资源是一个已被定义的报表定义作为资源存储在调用程序集中。

如果已经设置了ReportPath属性,则ReportEmbeddedResource . conf将被删除属性被忽略。

因此,设置EmbeddedResource属性实际上什么也没做,您的ReportPath也失败了,因为它需要一个物理文件系统路径。

我也遇到了同样的问题。我通过设置"复制到输出目录=复制如果更新"来解决它。欢呼。

我也有同样的问题,这意味着你的代码没有找到rdlc文件,你需要使用report.ReportEmbeddedResourcereport.ReportPath。看着你的代码似乎对我来说,你只需要使用report.ReportEmbeddedResource,另一个选项是位于您的pc或网络文件系统

中的特定位置的rdlc。