0
我已在桌面應用程序中成功地將Java Crystal Reports與Crystal Report連接起來。 現在我想以編程方式向報告添加一行。通過Java SDK將CrystalObject添加到Crystal Report
我試着用下面的代碼。
try {
ReportDefController rdc = reportClientDoc.getReportDefController();
} catch (ReportSDKException ex) {
Logger.getLogger(PurchaseReport.class.getName()).log(Level.SEVERE, null, ex);
}
Tables tables = null;
try {
tables = reportClientDoc.getDatabase().getTables();
} catch (ReportSDKException ex) {
Logger.getLogger(PurchaseReport.class.getName()).log(Level.SEVERE, null, ex);
}
LineObject lineObject = new LineObject();
lineObject.clone(false);
lineObject.setSectionCode(0);
lineObject.setLineThickness(10);
lineObject.setLeft(50);
lineObject.setWidth(50);
lineObject.setHeight(10);
lineObject.setRight(20);
lineObject.setTop(10);
lineObject.setLineColor(Color.BLUE);
ReportObjectController roc = null;
try {
roc = reportClientDoc.getReportDefController().getReportObjectController();
} catch (ReportSDKException ex) {
Logger.getLogger(PurchaseReport.class.getName()).log(Level.SEVERE, null, ex);
}
ReportDefController reportDefController = null;
try {
reportDefController = reportClientDoc.getReportDefController();
ISection section = reportDefController.getReportDefinition().getDetailArea().getSections().getSection(0);
lineObject.setSectionName(section.getName());
//roc.add(fieldObject, section, 0);
if(roc.canAddReportObject(lineObject, section))
{
roc.add(lineObject, section, -1);
}
} catch (ReportSDKException ex) {
Logger.getLogger(PurchaseReport.class.getName()).log(Level.SEVERE, null, ex);
}
這將引發在roc.add(lineObject, section, -1)
錯誤我怎樣才能解決這個錯誤,並適當加行?
謝謝@Chris。它完全適用於我。 – chintan