代码之家  ›  专栏  ›  技术社区  ›  Tony Peterson

Crystal报表导出的参数问题

  •  1
  • Tony Peterson  · 技术社区  · 16 年前

    我试图将一个crystal报告导出为pdf,然后通过电子邮件发送,但是每次转到export命令时,都会收到一个ParameterFieldCurrentValue异常。

    我跟踪了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,我一直得到那个错误。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Tony Peterson    16 年前

    最后,我使用了SetParameter而不是current values方法,并为多值参数使用了values集合。

    另外,我没有使用键入的报表,而是使用了非键入的报表文档。

    我还从Crystal Reports中复制了sql,并用它制作了一个数据集。我想数据集是我之前丢失的部分。

    它现在可以工作了,尽管它看起来不像上面的代码。