ExCella Reports1.4のライブラリを使用し帳票・ExcelをLibreOffice33経由でPDFで出力します(失敗しました)。
【準備】
1.「LibreOffice3.6.7のインストール方法」の手順で、LibreOffice3をインストールしておきます。
【手順】
1.「Javaプロジェクトの作成方法」の手順で、「ExCellaSample040-PdfLibreOffice3NG」といプロジェクトを作成。
2.「excella-reports-1.4.jarとそれに依存ライブラリを設定する方法」の手順で、プロジェクトにExCella Reports1.4とそれに依存するライブラリを追加。
3.「ExCella Reports1.4のJDOConverterのバージョンアップ方法」の手順で、JODConverterをバージョンアップ。
4.「PdfOpenOffice3OKTemplate.xls」という名前の、以下の様なテンプレートファイルを作成し、「ExCellaSample040-PdfLibreOffice3NG」直下に配置。
5.「Javaクラスファイルの作成方法」の手順で、「Main」というクラスを作成。
6.「Main.java」を以下の様に入力。
import org.bbreak.excella.reports.exporter.OoPdfExporter;
import org.bbreak.excella.reports.model.ReportBook;
import org.bbreak.excella.reports.model.ReportSheet;
import org.bbreak.excella.reports.processor.ReportProcessor;
import org.bbreak.excella.reports.tag.SingleParamParser;
public class Main {
public static void main(String[] args) throws Exception {
String templateFilePath = "PdfLibreOffice3NGTemplate.xls";
String outputFileName = "PdfLibreOffice3NG";
String outputFileDir = "";
String outputFilePath = outputFileDir.concat(outputFileName);
ReportBook outputBook = new ReportBook(templateFilePath, outputFilePath, OoPdfExporter.FORMAT_TYPE);
ReportSheet outputSheet = new ReportSheet("請求書");
outputBook.addReportSheet(outputSheet);
outputSheet.addParam(SingleParamParser.DEFAULT_TAG, "値1", "値1に入るHello, World");
outputSheet.addParam(SingleParamParser.DEFAULT_TAG, "値2", "値2に入るHello, World");
outputSheet.addParam(SingleParamParser.DEFAULT_TAG, "値3", "値3に入るHello, World");
ReportProcessor reportProcessor = new ReportProcessor();
reportProcessor.process(outputBook);
}
}
7.「Ctrl+Shift+O」を押し、パッケージのインポート文を補完。8.「Ctrl+Shift+F」を押し、ソースコードをフォーマッティング。
9.「Javaプロジェクトの実行方法」の手順で、「Main.java」を実行。
10.コンソールに以下の様にエラーが出力されます。
log4j:WARN No appenders could be found for logger (org.bbreak.excella.core.BookController).
log4j:WARN Please initialize the log4j system properly.
2013/09/10 13:55:32 org.artofsolving.jodconverter.office.ProcessPoolOfficeManager <init>
情報: ProcessManager implementation is PureJavaProcessManager
2013/09/10 13:55:32 org.artofsolving.jodconverter.office.OfficeProcess prepareInstanceProfileDir
警告: profile dir 'C:\Users\admin\AppData\Local\Temp\.jodconverter_socket_host-127.0.0.1_port-8100' already exists; deleting
2013/09/10 13:55:32 org.artofsolving.jodconverter.office.OfficeProcess start
情報: starting process with acceptString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1' and profileDir 'C:\Users\admin\AppData\Local\Temp\.jodconverter_socket_host-127.0.0.1_port-8100'
2013/09/10 13:55:32 org.artofsolving.jodconverter.office.OfficeProcess start
情報: started process
Exception in thread "main" org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:64)
at org.artofsolving.jodconverter.office.PooledOfficeManager.start(PooledOfficeManager.java:101)
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.start(ProcessPoolOfficeManager.java:62)
at org.bbreak.excella.reports.exporter.OoPdfExporter.output(OoPdfExporter.java:138)
at org.bbreak.excella.reports.exporter.ReportBookExporter.export(ReportBookExporter.java:96)
at org.bbreak.excella.reports.processor.ReportProcessor.processBook(ReportProcessor.java:207)
at org.bbreak.excella.reports.processor.ReportProcessor.process(ReportProcessor.java:110)
at Main.main(Main.java:26)
Caused by: java.util.concurrent.ExecutionException: org.artofsolving.jodconverter.office.OfficeException: could not establish connection
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:62)
... 7 more
Caused by: org.artofsolving.jodconverter.office.OfficeException: could not establish connection
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:142)
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.access$000(ManagedOfficeProcess.java:31)
at org.artofsolving.jodconverter.office.ManagedOfficeProcess$1.run(ManagedOfficeProcess.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.artofsolving.jodconverter.office.OfficeException: office process died with exit code -1073741515
at org.artofsolving.jodconverter.office.ManagedOfficeProcess$6.attempt(ManagedOfficeProcess.java:136)
at org.artofsolving.jodconverter.office.Retryable.execute(Retryable.java:40)
at org.artofsolving.jodconverter.office.Retryable.execute(Retryable.java:30)
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:120)
... 8 more
【結論】
ExCellaからLibreOffice3経由でPDFを出力するには、通常の方法では上手くいきませんでした。
以上です。
-01.png)
-02.png)
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。