0

当我尝试从水晶报表 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();

 }
}
4

1 回答 1

-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();

 }
}

于 2014-03-07T11:32:34.403 回答