Crystal报表SDK JRC传递参数给出错误错误代码:-2147217394错误代码名称:missingParameterValueError

时间:2012-12-04 10:48:47

标签: java crystal-reports

当我尝试从水晶报告SDK传递参数并将我的报告导出为PDF时。它是独立的应用程序,所以我不能用户crystalreportviewer选项,但它一直给我错误 com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException:InternalFormatterException ----错误代码:-2147217394错误代码名称:missingParameterValueError我的代码如下,请帮助

import com.crystaldecisions.reports.sdk.DatabaseController;
import com.crystaldecisions.reports.sdk.ReportClientDocument;
import com.crystaldecisions.reports.sdk.ParameterFieldController;
import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
import com.crystaldecisions.sdk.occa.report.exportoptions.ExportOptions;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class Test {
public static void main(String args[]) throws ReportSDKException, SQLException,      FileNotFoundException, IOException{
try{

ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open("Report.rpt",0);
ParameterFieldController paramController = reportClientDoc.getDataDefController().getParameterFieldController();

paramController.setCurrentValue("","P_DP",new Integer(22));
//Here I was calling switch database code 
 ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getReportSource().export(ReportExportFormat.PDF);
 IOUtils.copy(byteArrayInputStream, new FileOutputStream("new.pdf"));

 reportClientDoc.close();

 }
}

1 个答案:

答案 0 :(得分:-1)

只需将设置参数代码移动到上一行即可开始工作。我们需要在打开报告之前设置参数。

import com.crystaldecisions.reports.sdk.DatabaseController;
import com.crystaldecisions.reports.sdk.ReportClientDocument;
import com.crystaldecisions.reports.sdk.ParameterFieldController;
import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
import com.crystaldecisions.sdk.occa.report.exportoptions.ExportOptions;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class Test {
public static void main(String args[]) throws ReportSDKException, SQLException,      FileNotFoundException, IOException{
try{

ReportClientDocument reportClientDoc = new ReportClientDocument();

ParameterFieldController paramController = reportClientDoc.getDataDefController().getParameterFieldController();
paramController.setCurrentValue("","P_DP",new Integer(22));

reportClientDoc.open("Report.rpt",0);


//Here I was calling switch database code 
 ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getReportSource().export(ReportExportFormat.PDF);
 IOUtils.copy(byteArrayInputStream, new FileOutputStream("new.pdf"));

 reportClientDoc.close();

 }
}