简体   繁体   English

Crystal Reports导出的参数问题

[英]Parameter Problem with Crystal Reports Export

I'm trying to export a crystal report to pdf and then email it, but every time I get to the export command, I get a ParameterFieldCurrentValue exception. 我正在尝试将Crystal报表导出为pdf,然后通过电子邮件发送给我,但是每当我导出命令时,都会出现ParameterFieldCurrentValue异常。

I've traced the values of the Parameter collection in the ReportDocument and the values are being set there. 我已经在ReportDocument中跟踪了Parameter集合的值,并在那里设置了这些值。 Also, all four parameters are strings. 另外,所有四个参数都是字符串。 The first one is set to allow more than one value and also either discrete or range values. 第一个设置为允许多个值,也可以是离散值或范围值。 The dialog I call sets values for the choosable selections for that parameter. 我调用的对话框为该参数的可选选择设置值。 There are no other parameter fields. 没有其他参数字段。 There are formula fields, in the report however. 但是,报告中有公式字段。

My code is: 我的代码是:

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
}

What am I doing wrong? 我究竟做错了什么? Is there some other way of doing this that is better? 还有其他更好的方法吗? I have tried export options, I have tried SetParameter, I keep getting that error. 我尝试了导出选项,我尝试了SetParameter,但不断收到该错误。

I ended up using SetParameter instead of the current values method and using a values collection for the multi-valued parameter. 我最终使用SetParameter而不是当前values方法,并且对多值参数使用了values集合。

Also instead of using the typed report, I used an untyped report document. 另外,我没有使用类型化的报告,而是使用了未类型化的报告文档。

I also copied over the sql from Crystal Reports and used it to make a dataset. 我还从Crystal Reports复制了sql,并用它来制作数据集。 I think the dataset was the part I was missing before. 我认为数据集是我之前缺少的部分。

It works now, although it looks nothing like the code above. 现在它可以工作,尽管看起来与上面的代码完全不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM