|
|
@@ -2,11 +2,15 @@ package com.uas.report.crystal;
|
|
|
|
|
|
import com.crystaldecisions.sdk.occa.report.application.OpenReportOptions;
|
|
|
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
|
|
|
+import com.crystaldecisions.sdk.occa.report.data.*;
|
|
|
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.util.Locale;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.ObjectOutputStream;
|
|
|
|
|
|
/**
|
|
|
* @author sunyj
|
|
|
@@ -18,13 +22,27 @@ public class Application {
|
|
|
public static void main(String[] args) {
|
|
|
ReportClientDocument client = new ReportClientDocument();
|
|
|
try {
|
|
|
+ String reportName = "bjd_price.rpt";
|
|
|
client.setReportAppServer(ReportClientDocument.inprocConnectionString);
|
|
|
- client.setLocale(Locale.CHINA);
|
|
|
- client.open("bjd_price.rpt", OpenReportOptions._openAsReadOnly);
|
|
|
+ client.open(reportName, OpenReportOptions._openAsReadOnly);
|
|
|
logger.info(client.getStatusVariables().toString());
|
|
|
- logger.info(client.getDatabase().toString());
|
|
|
+ IDatabase database = client.getDatabase();
|
|
|
+ Connections connections = database.getConnections();
|
|
|
+ for (IConnection iConnection : connections) {
|
|
|
+ Tables tables = iConnection.getTables();
|
|
|
+ for (ITable iTable : tables) {
|
|
|
+ logger.info(iTable.getName());
|
|
|
+ iTable.setName("1_QUOTATION_VIEW");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(new File(reportName)));
|
|
|
+ client.writeExternal(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
} catch (ReportSDKException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ logger.error("报表读取失败", e);
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("报表写入失败", e);
|
|
|
}
|
|
|
}
|
|
|
}
|