OfficeIntegration officeIntegration = new OfficeIntegration(openOfficePath, ports); formatterFactory.setOfficeIntegration(officeIntegration);
OfficeIntegration officeIntegration = new OfficeIntegration(openOfficePath, ports); formatterFactory.setOfficeIntegration(officeIntegration);
@Test public void testXlsToPdf() throws Exception { BandData root = createRootBand(); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result.pdf"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("xls", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.xls", "./modules/core/test/smoketest/test.xls", ReportOutputType.pdf), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("odt", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/colontitules.odt", "./modules/core/test/smoketest/colontitules.odt", ReportOutputType.doc), outputStream));
defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("xlsx", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/print-spaces.xlsx", "./modules/core/test/smoketest/print-spaces.xlsx", ReportOutputType.pdf), outputStream));
@Test public void testDoc() throws Exception { BandData root = createRootBand(); root.addReportFieldFormats(Collections.singletonList(new ReportFieldFormatImpl("Band1.col2", "${html}"))); BandData footer = root.getChildByName("Footer"); BandData footerChild = new BandData("FooterChild", footer); footerChild.addData("nestedData", "NESTED_DATA"); footer.addChild(footerChild); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result2.doc"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("doc", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.doc", "./modules/core/test/smoketest/test.doc", ReportOutputType.doc), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testOdt() throws Exception { BandData root = createRootBand(); root.addReportFieldFormats(Collections.singletonList(new ReportFieldFormatImpl("Band1.col2", "${html}"))); BandData footer = root.getChildByName("Footer"); BandData footerChild = new BandData("FooterChild", footer); footerChild.addData("nestedData", "NESTED_DATA"); footer.addChild(footerChild); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result.doc"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("odt", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.odt", "./modules/core/test/smoketest/test.odt", ReportOutputType.doc), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testDocxToPdf() throws Exception { BandData root = createRootBand(); BandData footer = root.getChildByName("Footer"); BandData footerChild = new BandData("FooterChild", footer); footerChild.addData("nestedData", "NESTED_DATA"); footer.addChild(footerChild); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result_docx.pdf"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("docx", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.docx", "./modules/core/test/smoketest/test.docx", ReportOutputType.pdf), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testDocxToHtml_OfficeIntegration() throws Exception { BandData root = createRootBand(); root.addReportFieldFormats(Collections.singletonList(new ReportFieldFormatImpl("Band1.col2", "${html}"))); BandData footer = root.getChildByName("Footer"); BandData footerChild = new BandData("FooterChild", footer); footerChild.addData("nestedData", "NESTED_DATA"); footer.addChild(footerChild); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result_docx_office.html"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("docx", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.docx", "./modules/core/test/smoketest/test.docx", ReportOutputType.html), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
final CountDownLatch countDownLatch = new CountDownLatch(3); final DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); final OfficeIntegration officeIntegrationAPI = new OfficeIntegration(openOfficePath, 8100, 8101, 8102); officeIntegrationAPI.setTimeoutInSeconds(10); officeIntegrationAPI.setTemporaryDirPath("./result/temp/");
@Test public void testXlsxToHtml() throws Exception { BandData root = createRootBand(); BandData band3_1 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_1.addData("col1", 123); band3_1.addData("col2", 321); BandData band3_2 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_2.addData("col1", 456); band3_2.addData("col2", 654); BandData band3_3 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_3.addData("col1", 789); band3_3.addData("col2", 987); BandData second = new BandData("Second", root, BandOrientation.HORIZONTAL); root.addChild(band3_1); root.addChild(band3_2); root.addChild(band3_3); root.addChild(second); BandData split = new BandData("Split", root, BandOrientation.HORIZONTAL); split.setData(new HashMap<>()); split.addData("image", FileUtils.readFileToByteArray(new File("./modules/core/test/yarg.png"))); root.addChild(split); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result_xlsx.html"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("xlsx", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.xlsx", "./modules/core/test/smoketest/test.xlsx", ReportOutputType.html), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testXlsxToPdf() throws Exception { BandData root = createRootBand(); BandData band3_1 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_1.addData("col1", 123); band3_1.addData("col2", 321); BandData band3_2 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_2.addData("col1", 456); band3_2.addData("col2", 654); BandData band3_3 = new BandData("Band3", root, BandOrientation.VERTICAL); band3_3.addData("col1", 789); band3_3.addData("col2", 987); BandData second = new BandData("Second", root, BandOrientation.HORIZONTAL); root.addChild(band3_1); root.addChild(band3_2); root.addChild(band3_3); root.addChild(second); BandData split = new BandData("Split", root, BandOrientation.HORIZONTAL); split.setData(new HashMap<>()); split.addData("image", FileUtils.readFileToByteArray(new File("./modules/core/test/yarg.png"))); root.addChild(split); FileOutputStream outputStream = new FileOutputStream("./result/smoke/result_xlsx.pdf"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("xlsx", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.xlsx", "./modules/core/test/smoketest/test.xlsx", ReportOutputType.pdf), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testTableOdt() throws Exception { BandData root = new BandData("Root"); root.setData(new RandomMap()); BandData ship = new BandData("Ship", root); ship.setData(new RandomMap()); BandData corrosion = new BandData("Corrosion", root); corrosion.setData(new RandomMap()); BandData custom = new BandData("Custom", root); custom.setData(new RandomMap()); root.addChild(ship); root.addChild(corrosion); root.addChild(custom); FileOutputStream outputStream = new FileOutputStream("./result/smoke/table.doc"); DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory(); defaultFormatterFactory.setOfficeIntegration(new OfficeIntegration(openOfficePath, 8100)); ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("odt", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/table.odt", "./modules/core/test/smoketest/table.odt", ReportOutputType.doc), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }