0
我有一個表格,允許用戶選擇他們想要生成的報告。他們也可以選擇標準,選擇打印,預覽,導出等。用戶做出選擇並點擊「生成」按鈕後,我有一個類創建報表對象,加載報表,數據集,然後打印或導出那個報告。我創建了一個單獨的表單來預覽報表。當我將報表對象傳遞給預覽窗體時,我收到「無效的報表源」。報告打印和輸出很好,我只是不能預覽報告。我不想在預覽窗體中複製代碼,我希望能夠傳遞報表對象。我的代碼片段如下。有什麼建議麼?預覽水晶報告在一個單獨的表格
public static class CrystalReportUtilities
{
private static ReportDocument goReport {get; set;}
private static string gsReportName { get; set; }
private static string gsSqlString { get; set; }
private static object[,] goParameters { get; set; }
public static void generateReport(parameters...)
{
goReport = loadReport();
...
goReport.SetDataSource(DataTable);
...
previewReport();
private static void previewReport()
{
CrystalReportPrintPreviewForm loReportPreview = new CrystalReportPrintPreviewForm(goReport);
loReportPreview.ShowDialog();
}
public partial class CrystalReportPrintPreviewForm : Form
{
private ReportDocument goReport;
public CrystalReportPrintPreviewForm(ReportDocument poReport)
{
InitializeComponent();
goReport = poReport;
}
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
try
{
if (goReport != null)
{
crystalReportViewer1.ReportSource = goReport; // Receive "Invalid Report Source"
}
}
所以我改變了預覽表格,以便我不再將報告傳遞到窗體中,形成類。我更改了類中的方法,以在加載報告後返回ReportDocument。在我的表單中,我調用該加載方法並設置DataSource。現在,表單加載,但我得到的錯誤消息:方法沒有找到「'Void CrystalDecisions.Shared.PageRender.set_ExceptionWIndowTitle(System.String)'。我現在試圖追查下來。 – ggrewe1959