与Crystal参数问题报告出口
问题描述:
我试图导出为PDF水晶报表,然后通过电子邮件发送,但每次我到导出命令时,我得到一个ParameterFieldCurrentValue例外。与Crystal参数问题报告出口
我跟踪的参数集合的值保持ReportDocument和值被设置在那里。而且,所有四个参数都是字符串。第一个设置允许多个值以及离散值或范围值。我调用的对话框为该参数的可选选项设置值。没有其他参数字段。在报告中有公式字段。
我的代码是:
SelectionDialog sd = new SelectionDialog(null, null,
@"\\er1\common\bfi_apps\ReportMasterTwo\eds\custno.csv", true, false);
DialogResult dr = sd.ShowDialog();
string filename = @"c:\documents and settings\aap\desktop\salesanalysis.pdf";
if (dr == DialogResult.OK && sd.selectedVals != null)
{
for (int i = 0; i < sd.selectedVals.Count; i++)
{
ar100SalesABC_edcustom1.Parameter_Customer_Number.CurrentValues.AddValue
(sd.selectedVals[i]);
}
ar100SalesABC_edcustom1.Parameter_Fiscal_period.CurrentValues.AddValue("1");
ar100SalesABC_edcustom1.Parameter_Fiscal_year.CurrentValues.AddValue("2007");
ar100SalesABC_edcustom1.Parameter_Product_Type.CurrentValues.AddValue("F");
ar100SalesABC_edcustom1.ExportToDisk
(ExportFormatType.PortableDocFormat, filename); // ERROR HAPPENS HERE
// .. emailing code and other stuff
}
我在做什么错?有没有其他方法可以做得更好?我试过导出选项,我试过SetParameter,我一直在收到这个错误。
答
我结束了使用SetParameter而不是当前值方法,并使用值集合的多值参数。
而不是使用类型的报告,我使用了一个无类型的报告文档。
我还从Crystal Reports中复制了SQL,并用它来创建数据集。我认为数据集是我之前缺少的部分。
它现在可以工作,尽管它看起来不像上面的代码。