我正在尝试将水晶报告导出为pdf然后通过电子邮件发送,但每次进入导出命令时,我都会收到ParameterFieldCurrentValue异常。
我在ReportDocument中跟踪了Parameter集合的值,并在那里设置了值。此外,所有四个参数都是字符串。第一个设置为允许多个值以及离散值或范围值。我调用的对话框为该参数的可选择选择设置值。没有其他参数字段。但是,报告中有公式字段。
我的代码是:
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,我一直收到错误。
答案 0 :(得分:0)
我最终使用SetParameter而不是当前值方法,并使用值集合作为多值参数。
我还使用了无类型的报告文档,而不是使用类型化的报告。
我还从Crystal Reports复制了sql并用它来制作数据集。我认为数据集是我之前缺少的部分。
它现在有效,虽然它看起来与上面的代码完全不同。