diff --git a/jasperreports/demo/samples/shapes/reports/ShapesReportMSOffice2007.jrxml b/jasperreports/demo/samples/shapes/reports/ShapesReportMSOffice2007.jrxml new file mode 100755 index 0000000000..1310adebcd --- /dev/null +++ b/jasperreports/demo/samples/shapes/reports/ShapesReportMSOffice2007.jrxml @@ -0,0 +1,146 @@ + + + + + + <band height="782"> + <line> + <reportElement x="0" y="50" width="200" height="1" uuid="409fe65d-91f6-4e4d-aba2-a9dad8137acc"/> + </line> + <staticText> + <reportElement x="210" y="50" width="340" height="40" uuid="4cb22491-9354-4668-a216-bcf300391ef1"/> + <text><![CDATA[<line><reportElement x="0" y="50" width="200" height="0"/></line>]]></text> + </staticText> + <line> + <reportElement x="0" y="100" width="200" height="40" uuid="7e389bc8-a8bb-458f-b290-ad67538857f8"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </line> + <staticText> + <reportElement x="210" y="100" width="340" height="40" uuid="47a5fc73-1466-4c66-aa68-102a3530a5f7"/> + <text><![CDATA[<line direction="TopDown"><reportElement x="0" y="100" width="200" height="40"/><graphicElement><pen lineWidth="2"/></graphicElement></line>]]></text> + </staticText> + <line direction="BottomUp"> + <reportElement x="0" y="150" width="200" height="40" forecolor="#00FF00" uuid="862e5f68-d45a-4c40-a6d3-835a039b6a61"/> + <graphicElement> + <pen lineWidth="4.0"/> + </graphicElement> + </line> + <staticText> + <reportElement x="210" y="150" width="340" height="40" uuid="d02e6d0d-f499-49ac-9fec-8f2f88881f52"/> + <text><![CDATA[<line direction="BottomUp"><reportElement x="0" y="150" width="200" height="40" forecolor="green"/><graphicElement><pen lineWidth="4"/></graphicElement></line>]]></text> + </staticText> + <line> + <reportElement x="100" y="200" width="1" height="40" forecolor="#0000FF" uuid="b72ba1b1-ad13-471f-a9d3-ced9a2819641"/> + <graphicElement> + <pen lineWidth="1.0" lineStyle="Dashed"/> + </graphicElement> + </line> + <staticText> + <reportElement x="210" y="200" width="340" height="40" uuid="7ff2655b-97d3-4f28-922d-a380c6ec24e3"/> + <text><![CDATA[<line><reportElement x="100" y="200" width="0" height="40" forecolor="blue"/><graphicElement><pen lineWidth="1" lineStyle="Dashed"/></graphicElement></line>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="250" width="200" height="40" backcolor="#FFFF99" uuid="88282a3b-af28-4518-a316-1f49bf2e6420"/> + <graphicElement> + <pen lineWidth="0.0"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="250" width="340" height="40" uuid="8644ce9d-d2d0-47bc-9e29-1a9c8f29c5ca"/> + <text><![CDATA[<rectangle><reportElement x="0" y="250" width="200" height="40" backcolor="#FFFF99"/><graphicElement><pen lineWidth="0"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="300" width="200" height="40" uuid="e2556436-be36-4b35-8439-2d536e018235"/> + </rectangle> + <staticText> + <reportElement x="210" y="300" width="340" height="40" uuid="f8f9cc57-71c2-474b-84f7-c7335baeddfc"/> + <text><![CDATA[<rectangle><reportElement x="0" y="300" width="200" height="40"/><graphicElement><pen lineWidth="1"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle radius="15"> + <reportElement x="0" y="350" width="200" height="40" backcolor="#FFFF00" uuid="86432e0c-bda7-4a01-8d62-669a09bbb6c1"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="350" width="340" height="40" uuid="4c945c5f-296f-4e84-ad3a-6ef73a85d066"/> + <text><![CDATA[<rectangle radius="15"><reportElement x="0" y="350" width="200" height="40" backcolor="#FFFF00"/><graphicElement><pen lineWidth="2"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="400" width="200" height="40" forecolor="#FF0000" backcolor="#00FFFF" uuid="22404d39-dacb-425e-b74b-cbfbcfec67a0"/> + <graphicElement> + <pen lineWidth="4.0"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="400" width="340" height="40" uuid="0e0858c2-8a5a-4bf1-b71e-524d2b66f4f8"/> + <text><![CDATA[<rectangle><reportElement x="0" y="400" width="200" height="40" forecolor="red" backcolor="#00FFFF"/><graphicElement><pen lineWidth="4"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="450" width="200" height="40" forecolor="#FF00FF" backcolor="#C0C0C0" uuid="f7e584bf-dd59-4ad4-8058-87e3a01b4424"/> + <graphicElement> + <pen lineWidth="1.0" lineStyle="Dashed"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="450" width="340" height="40" uuid="456f90a3-c28b-4ec1-aefc-d8d872657653"/> + <text><![CDATA[<rectangle><reportElement x="0" y="450" width="200" height="40" forecolor="#FF00FF" backcolor="#C0C0C0"/><graphicElement><pen lineWidth="1" lineStyle="Dashed"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="500" width="150" height="30" backcolor="#FFAABB" uuid="28f02797-c08d-48b1-af9c-01148d5eab2d"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </rectangle> + <rectangle> + <reportElement x="50" y="510" width="150" height="30" forecolor="#0000FF" uuid="d1c1a829-97b3-4331-ba52-e14a74b5fdf1"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="500" width="340" height="40" uuid="10ffcc22-1a97-43e5-b721-1f0b7ddceb6a"/> + <text><![CDATA[<rectangle><reportElement x="50" y="510" width="150" height="30" forecolor="blue" mode="Opaque"/><graphicElement><pen lineWidth="2"/></graphicElement></rectangle>]]></text> + </staticText> + <rectangle> + <reportElement x="0" y="550" width="150" height="30" backcolor="#FFAABB" uuid="63cd0120-d0c4-434b-b456-b3f7840399be"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </rectangle> + <rectangle> + <reportElement mode="Transparent" x="50" y="560" width="150" height="30" forecolor="#0000FF" uuid="cdcb8329-d89b-45e4-ac51-2d77f3bc0237"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement x="210" y="550" width="340" height="40" uuid="1bb8255a-d2e4-4b0c-9e4f-1d3d1d3bfb10"/> + <text><![CDATA[<rectangle><reportElement x="50" y="560" width="150" height="30" forecolor="blue" mode="Transparent"/><graphicElement><pen lineWidth="2"/></graphicElement></rectangle>]]></text> + </staticText> + <ellipse> + <reportElement x="0" y="600" width="200" height="40" forecolor="#FF0000" backcolor="#FFFF99" uuid="a20aa973-ef67-4101-8004-ef03b6574c36"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </ellipse> + <staticText> + <reportElement x="210" y="600" width="340" height="40" uuid="ff089b34-6810-4732-828d-bd47dac6e038"/> + <text><![CDATA[<ellipse><reportElement x="0" y="600" width="200" height="40" forecolor="red" backcolor="#FFFF99"/><graphicElement><pen lineWidth="2"/></graphicElement></ellipse>]]></text> + </staticText> + <ellipse> + <reportElement x="80" y="650" width="40" height="40" forecolor="#009900" backcolor="#99FFFF" uuid="045857bd-fb35-458a-9fd0-baf26200707f"/> + <graphicElement> + <pen lineWidth="2.0"/> + </graphicElement> + </ellipse> + <staticText> + <reportElement x="210" y="650" width="340" height="40" uuid="a113dbe9-5416-4f04-b832-93e753be60ea"/> + <text><![CDATA[<ellipse><reportElement x="80" y="650" width="40" height="40" forecolor="#009900" backcolor="#99FFFF"/><graphicElement><pen lineWidth="2"/></graphicElement></ellipse>]]></text> + </staticText> + </band> + + + diff --git a/jasperreports/demo/samples/shapes/src/ShapesApp.java b/jasperreports/demo/samples/shapes/src/ShapesApp.java index aa47d229ef..dbb5920617 100755 --- a/jasperreports/demo/samples/shapes/src/ShapesApp.java +++ b/jasperreports/demo/samples/shapes/src/ShapesApp.java @@ -86,9 +86,18 @@ public void test() throws JRException */ public void fill() throws JRException { - long start = System.currentTimeMillis(); - JasperFillManager.fillReportToFile("build/reports/ShapesReport.jasper", null, (JRDataSource)null); - System.err.println("Filling time : " + (System.currentTimeMillis() - start)); + File[] files = getFiles(new File("build/reports"), "jasper"); + for(int i = 0; i < files.length; i++) + { + File reportFile = files[i]; + long start = System.currentTimeMillis(); + JasperFillManager.fillReportToFile( + reportFile.getAbsolutePath(), + null, + (JRDataSource)null + ); + System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start)); + } } @@ -97,9 +106,17 @@ public void fill() throws JRException */ public void print() throws JRException { - long start = System.currentTimeMillis(); - JasperPrintManager.printReport("build/reports/ShapesReport.jrprint", true); - System.err.println("Printing time : " + (System.currentTimeMillis() - start)); + File[] files = getFiles(new File("build/reports"), "jrprint"); + for(int i = 0; i < files.length; i++) + { + File reportFile = files[i]; + long start = System.currentTimeMillis(); + JasperPrintManager.printReport( + reportFile.getAbsolutePath(), + true + ); + System.err.println("Report : " + reportFile + ". Printing time : " + (System.currentTimeMillis() - start)); + } } @@ -175,24 +192,28 @@ public void html() throws JRException */ public void xls() throws JRException { - long start = System.currentTimeMillis(); - File sourceFile = new File("build/reports/ShapesReport.jrprint"); + File[] files = getFiles(new File("build/reports"), "jrprint"); + for(int i = 0; i < files.length; i++) + { + long start = System.currentTimeMillis(); + File sourceFile = files[i]; - JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); + JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); - File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls"); + File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls"); - JRXlsExporter exporter = new JRXlsExporter(); + JRXlsExporter exporter = new JRXlsExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); - SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); - configuration.setOnePagePerSheet(false); - exporter.setConfiguration(configuration); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); + SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); + configuration.setOnePagePerSheet(false); + exporter.setConfiguration(configuration); - exporter.exportReport(); + exporter.exportReport(); - System.err.println("XLS creation time : " + (System.currentTimeMillis() - start)); + System.err.println("Report : " + sourceFile + ". XLS creation time : " + (System.currentTimeMillis() - start)); + } } @@ -293,24 +314,28 @@ public void docx() throws JRException */ public void xlsx() throws JRException { - long start = System.currentTimeMillis(); - File sourceFile = new File("build/reports/ShapesReport.jrprint"); + File[] files = getFiles(new File("build/reports"), "jrprint"); + for(int i = 0; i < files.length; i++) + { + long start = System.currentTimeMillis(); + File sourceFile = files[i]; - JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); + JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); - File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx"); + File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx"); - JRXlsxExporter exporter = new JRXlsxExporter(); + JRXlsxExporter exporter = new JRXlsxExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); - SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration(); - configuration.setOnePagePerSheet(false); - exporter.setConfiguration(configuration); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile)); + SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration(); + configuration.setOnePagePerSheet(false); + exporter.setConfiguration(configuration); - exporter.exportReport(); + exporter.exportReport(); - System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start)); + System.err.println("Report : " + sourceFile + ". XLSX creation time : " + (System.currentTimeMillis() - start)); + } } diff --git a/jasperreports/src/default.jasperreports.properties b/jasperreports/src/default.jasperreports.properties index 8a7b2fccdd..8535933c5a 100644 --- a/jasperreports/src/default.jasperreports.properties +++ b/jasperreports/src/default.jasperreports.properties @@ -121,6 +121,7 @@ net.sf.jasperreports.export.xls.wrap.text=true net.sf.jasperreports.export.xls.use.timezone=false net.sf.jasperreports.export.xls.auto.fit.page.height=false net.sf.jasperreports.export.xls.force.page.breaks=false +net.sf.jasperreports.export.xls.compatibility=none # XML exporter settings net.sf.jasperreports.export.xml.validation=true @@ -137,6 +138,7 @@ net.sf.jasperreports.export.csv.write.header=false # DOCX exporter settings net.sf.jasperreports.export.docx.frames.as.nested.tables=true net.sf.jasperreports.export.docx.flexible.row.height=false +net.sf.jasperreports.export.docx.compatibility=none # Properties to be transferred in the generated document net.sf.jasperreports.print.transfer.awt=net.sf.jasperreports.awt diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/ExportCompatibility.java b/jasperreports/src/net/sf/jasperreports/engine/export/ExportCompatibility.java new file mode 100644 index 0000000000..14900468b0 --- /dev/null +++ b/jasperreports/src/net/sf/jasperreports/engine/export/ExportCompatibility.java @@ -0,0 +1,42 @@ +/* + * JasperReports - Free Java Reporting Library. + * Copyright (C) 2001 - 2019 TIBCO Software Inc. All rights reserved. + * http://www.jaspersoft.com + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of JasperReports. + * + * JasperReports is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JasperReports is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with JasperReports. If not, see . + */ +package net.sf.jasperreports.engine.export; + +/* + * Contributor: + * Hitoshi Ozawa https://github.com/ozawa-hi/jasperreports + */ +public enum ExportCompatibility +{ + NONE, + MSOFFICE2007; + + public static ExportCompatibility getCompatibility(String name) { + try { + return ExportCompatibility.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + } + return NONE; + } +} diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/JRGridLayout.java b/jasperreports/src/net/sf/jasperreports/engine/export/JRGridLayout.java index ec2ff59101..f082907fb2 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/JRGridLayout.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/JRGridLayout.java @@ -69,6 +69,7 @@ public class JRGridLayout private int height; private int offsetX; private int offsetY; + private ExportCompatibility compatibility; private CutsInfo xCuts; private CutsInfo yCuts; @@ -107,10 +108,52 @@ public JRGridLayout( height, offsetX, offsetY, - null //xCuts + null, //xCuts + ExportCompatibility.NONE // compatibility ); } + /** + * Constructor. + * + * @param elements the elements that should arranged in a grid + * @param width the width available for the grid + * @param height the height available for the grid + * @param offsetX horizontal element position offset + * @param offsetY vertical element position offset + * @param xCuts An optional list of pre-calculated X cuts. + * @param compatibility export compatiblity version + */ + public JRGridLayout( + ExporterNature nature, + List elements, + int width, + int height, + int offsetX, + int offsetY, + CutsInfo xCuts, + ExportCompatibility compatibility + ) + { + this.nature = nature; + this.elementList = elements; + + // TODO lucianc cache these across report pages? + this.cellSizes = new HashMap(); + this.cellStyles = new HashMap(); + this.emptyCells = new HashMap, EmptyGridCell>(); + + this.height = height; + this.width = width; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.xCuts = xCuts; + this.compatibility = compatibility; + boxesCache = new HashMap(); + + layoutGrid(null, elements); + } + /** * Constructor. * @@ -377,7 +420,7 @@ protected void setGridElements(PrintElementIndex parentIndex, List hssfColorsRgbs; + private static ExportCompatibility compatibility; static { @@ -376,6 +382,7 @@ protected void openWorkbook(OutputStream os) { summaryInformation.setKeywords(keywords); } + compatibility = ExportCompatibility.getCompatibility(configuration.getCompatibility()); } @@ -738,6 +745,80 @@ protected void addOccupiedCell(OccupiedGridCell occupiedGridCell, int colIndex, @Override protected void exportLine(JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + switch(compatibility) + { + case MSOFFICE2007: + { + exportLine2007(line, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportLineDefault(line, gridCell, colIndex, rowIndex); + break; + } + } + } + + private void exportLine2007(JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + int row1 = rowIndex; + int row2 = rowIndex; + if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) + { + row2 += gridCell.getRowSpan(); + } + else + { + row1 += gridCell.getRowSpan(); + } + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) colIndex, row1, (short) (colIndex + gridCell.getColSpan()), row2); + HSSFSimpleShape shape = patriarch.createSimpleShape(anchor); + shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE ); + JRPen pen = line.getLinePen(); + + if (pen.getLineWidth() > 0) + { + shape.setLineWidth(LengthUtil.emu(Math.round(pen.getLineWidth()))); + switch (pen.getLineStyleValue()) + { + case DASHED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DASHGEL); + break; + } + case DOTTED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DOTSYS); + break; + } + case DOUBLE : + case SOLID : + default : + { + shape.setLineStyle(HSSFShape.LINESTYLE_SOLID); + break; + } + } + } + + Color penColor = pen.getLineColor(); + shape.setLineStyleColor(penColor.getRed(), penColor.getGreen(), penColor.getBlue()); + + if (line.getModeValue() == ModeEnum.OPAQUE && line.getBackcolor() != null) + { + Color bgcolor = line.getBackcolor(); + shape.setFillColor(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue()); + shape.setNoFill(true); + } + else + { + shape.setNoFill(true); + } + } + + private void exportLineDefault(JRPrintLine line, JRExporterGridCell gridCell, int colIndex, int rowIndex) { short forecolor = getWorkbookColor(line.getLinePen().getLineColor()).getIndex(); @@ -796,9 +877,72 @@ protected void exportLine(JRPrintLine line, JRExporterGridCell gridCell, int col cell.setCellStyle(cellStyle); } - @Override - protected void exportRectangle(JRPrintGraphicElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex) + protected void exportRectangle(JRPrintRectangle element, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + switch (compatibility) + { + case MSOFFICE2007: + { + exportRectangle2007(element, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportRectangleDefault((JRPrintGraphicElement)element, gridCell, colIndex, rowIndex); + break; + } + } + } + + private void exportRectangle2007(JRPrintRectangle element, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) colIndex, rowIndex, (short) (colIndex + gridCell.getColSpan()), rowIndex + gridCell.getRowSpan()); + HSSFSimpleShape shape = patriarch.createSimpleShape(anchor); + shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE ); + JRPen pen = element.getLinePen(); + + if (pen.getLineWidth() > 0) + { + shape.setLineWidth(LengthUtil.emu(Math.round(pen.getLineWidth()))); + switch (pen.getLineStyleValue()) + { + case DASHED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DASHGEL); + break; + } + case DOTTED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DOTSYS); + break; + } + case DOUBLE : + case SOLID : + default : + { + shape.setLineStyle(HSSFShape.LINESTYLE_SOLID); + break; + } + } + } + + Color penColor = pen.getLineColor(); + shape.setLineStyleColor(penColor.getRed(), penColor.getGreen(), penColor.getBlue()); + + if (element.getModeValue() == ModeEnum.OPAQUE && element.getBackcolor() != null) + { + Color bgcolor = element.getBackcolor(); + shape.setFillColor(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue()); + shape.setNoFill(false); + } + else + { + shape.setNoFill(true); + } + } + + private void exportRectangleDefault(JRPrintGraphicElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex) { short forecolor = getWorkbookColor(element.getLinePen().getLineColor()).getIndex(); @@ -831,6 +975,70 @@ protected void exportRectangle(JRPrintGraphicElement element, JRExporterGridCell cell.setCellStyle(cellStyle); } + @Override + protected void exportEllipse(JRPrintEllipse element, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + switch(compatibility) + { + case MSOFFICE2007: + { + exportEllipse2007(element, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportRectangleDefault((JRPrintGraphicElement)element, gridCell, colIndex, rowIndex); + break; + } + } + } + + private void exportEllipse2007(JRPrintEllipse element, JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) colIndex, rowIndex, (short) (colIndex + gridCell.getColSpan()), rowIndex + gridCell.getRowSpan()); + HSSFSimpleShape shape = patriarch.createSimpleShape(anchor); + shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL); + JRPen pen = element.getLinePen(); + + if (pen.getLineWidth() > 0) + { + shape.setLineWidth(LengthUtil.emu(Math.round(pen.getLineWidth()))); + switch (pen.getLineStyleValue()) + { + case DASHED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DASHGEL); + break; + } + case DOTTED : + { + shape.setLineStyle(HSSFShape.LINESTYLE_DOTSYS); + break; + } + case DOUBLE : + case SOLID : + default : + { + shape.setLineStyle(HSSFShape.LINESTYLE_SOLID); + break; + } + } + } + + Color penColor = pen.getLineColor(); + shape.setLineStyleColor(penColor.getRed(), penColor.getGreen(), penColor.getBlue()); + + if (element.getModeValue() == ModeEnum.OPAQUE && element.getBackcolor() != null) + { + Color bgcolor = element.getBackcolor(); + shape.setFillColor(bgcolor.getRed(), bgcolor.getGreen(), bgcolor.getBlue()); + shape.setNoFill(false); + } + else + { + shape.setNoFill(true); + } + } @Override public void exportText(JRPrintText textElement, JRExporterGridCell gridCell, int colIndex, int rowIndex) throws JRException @@ -1146,6 +1354,34 @@ protected void createMergeRegion(JRExporterGridCell gridCell, int colIndex, int } } + protected void createMergeRegion(JRExporterGridCell gridCell, int colIndex, int rowIndex) + { + boolean isCollapseRowSpan = getCurrentItemConfiguration().isCollapseRowSpan(); + int rowSpan = isCollapseRowSpan ? 1 : gridCell.getRowSpan(); + if (gridCell.getColSpan() > 1 || rowSpan > 1) + { + sheet.addMergedRegion(new CellRangeAddress(rowIndex, (rowIndex + rowSpan - 1), + colIndex, (colIndex + gridCell.getColSpan() - 1))); + + for(int i = 0; i < rowSpan; i++) + { + HSSFRow spanRow = sheet.getRow(rowIndex + i); + if (spanRow == null) + { + spanRow = sheet.createRow(rowIndex + i); + } + for(int j = 0; j < gridCell.getColSpan(); j++) + { + HSSFCell spanCell = spanRow.getCell((colIndex + j)); + if (spanCell == null) + { + spanCell = spanRow.createCell((colIndex + j)); + } + } + } + } + } + private HorizontalAlignment getHorizontalAlignment(TextAlignHolder alignment) { switch (alignment.horizontalAlignment) diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/JRXlsMetadataExporter.java b/jasperreports/src/net/sf/jasperreports/engine/export/JRXlsMetadataExporter.java index 7a87ce5c71..080dbe0337 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/JRXlsMetadataExporter.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/JRXlsMetadataExporter.java @@ -744,7 +744,7 @@ protected void exportLine(JRPrintLine line) throws JRException { } @Override - protected void exportRectangle(JRPrintGraphicElement element) throws JRException { + protected void exportRectangle(JRPrintRectangle element) throws JRException { String currentColumnName = element.getPropertiesMap().getProperty(JRXlsAbstractMetadataExporter.PROPERTY_COLUMN_NAME); if (currentColumnName != null && currentColumnName.length() > 0) { @@ -780,6 +780,42 @@ protected void exportRectangle(JRPrintGraphicElement element) throws JRException } } + @Override + protected void exportEllipse(JRPrintEllipse element) throws JRException { // TODO need to fix to show ellipse on xls metadata + String currentColumnName = element.getPropertiesMap().getProperty(JRXlsAbstractMetadataExporter.PROPERTY_COLUMN_NAME); + + if (currentColumnName != null && currentColumnName.length() > 0) { + boolean repeatValue = getPropertiesUtil().getBooleanProperty(element, JRXlsAbstractMetadataExporter.PROPERTY_REPEAT_VALUE, false); + + setColumnName(currentColumnName); + adjustColumnWidth(currentColumnName, element.getWidth(), ((JRXlsExporterNature)nature).getColumnAutoFit(element)); + adjustRowHeight(element.getHeight(), ((JRXlsExporterNature)nature).getRowAutoFit(element)); + + short forecolor = getWorkbookColor(element.getLinePen().getLineColor()).getIndex(); + + FillPatternType mode = backgroundMode; + short backcolor = whiteIndex; + if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && element.getBackcolor() != null) { + mode = FillPatternType.SOLID_FOREGROUND; + backcolor = getWorkbookColor(element.getBackcolor()).getIndex(); + } + + HSSFCellStyle cellStyle = + getLoadedCellStyle( + mode, + backcolor, + HorizontalAlignment.LEFT, + VerticalAlignment.TOP, + (short)0, + getLoadedFont(getDefaultFont(), forecolor, null, getLocale()), + new BoxStyle(element), + isCellLocked(element), + isCellHidden(element), + isShrinkToFit(element) + ); + addBlankElement(cellStyle, repeatValue, currentColumnName); + } + } @Override protected void exportText(final JRPrintText textElement) throws JRException { @@ -1630,7 +1666,7 @@ protected void exportFrame(JRPrintFrame frame) throws JRException { } else if (element instanceof JRPrintRectangle) { exportRectangle((JRPrintRectangle)element); } else if (element instanceof JRPrintEllipse) { - exportRectangle((JRPrintEllipse)element); + exportEllipse((JRPrintEllipse)element); } else if (element instanceof JRPrintImage) { exportImage((JRPrintImage) element); } else if (element instanceof JRPrintText) { diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/oasis/GraphicStyle.java b/jasperreports/src/net/sf/jasperreports/engine/export/oasis/GraphicStyle.java index 0e07331946..d51dc4e8dc 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/oasis/GraphicStyle.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/oasis/GraphicStyle.java @@ -25,6 +25,7 @@ import net.sf.jasperreports.engine.JRPrintGraphicElement; import net.sf.jasperreports.engine.JRPrintImage; +import net.sf.jasperreports.engine.JRPrintRectangle; import net.sf.jasperreports.engine.export.LengthUtil; import net.sf.jasperreports.engine.type.HorizontalImageAlignEnum; import net.sf.jasperreports.engine.type.ModeEnum; @@ -152,7 +153,14 @@ public GraphicStyle( case LEFT: default: { - hAlign = "left"; + if (element instanceof JRPrintRectangle) + { + hAlign = "from-left"; + } + else + { + hAlign = "left"; + } break; } } @@ -172,10 +180,16 @@ public GraphicStyle( case TOP: default: { - vAlign = "top"; + if (element instanceof JRPrintRectangle) + { + vAlign="from-top"; + } + else + { + vAlign = "top"; + } break; } - } } @@ -212,7 +226,14 @@ public void write(String lineStyleName) styleWriter.write(" \n"); styleWriter.write(" 1) // { // tempBodyWriter.write(" table:number-columns-spanned=\"" + emptyCellColSpan + "\""); -// } - tempBodyWriter.write("/>\n"); +// } **/ + tempColumnWriter.append("/>\n"); // // exportOccupiedCells(emptyCellColSpan - 1); } @@ -508,7 +517,7 @@ protected String getCellAddress(int row, int col) @Override protected void exportRectangle( - JRPrintGraphicElement rectangle, + JRPrintRectangle rectangle, JRExporterGridCell gridCell, int colIndex, int rowIndex @@ -517,6 +526,17 @@ protected void exportRectangle( tableBuilder.exportRectangle(rectangle, gridCell); } + @Override + protected void exportEllipse( + JRPrintEllipse ellipse, + JRExporterGridCell gridCell, + int colIndex, + int rowIndex + ) throws JRException + { + tableBuilder.exportEllipse(ellipse, gridCell); + } + @Override protected void exportLine( JRPrintLine line, @@ -525,70 +545,7 @@ protected void exportLine( int rowIndex ) throws JRException { - JRLineBox box = new JRBaseLineBox(null); - JRPen pen = null; - float ratio = line.getWidth() / line.getHeight(); - if (ratio > 1) - { - if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) - { - pen = box.getTopPen(); - } - else - { - pen = box.getBottomPen(); - } - } - else - { - if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) - { - pen = box.getLeftPen(); - } - else - { - pen = box.getRightPen(); - } - } - pen.setLineColor(line.getLinePen().getLineColor()); - pen.setLineStyle(line.getLinePen().getLineStyleValue()); - pen.setLineWidth(line.getLinePen().getLineWidth()); - - gridCell.setBox(box);//CAUTION: only some exporters set the cell box - - tableBuilder.buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan()); - -// double x1, y1, x2, y2; -// -// if (line.getDirection() == JRLine.DIRECTION_TOP_DOWN) -// { -// x1 = Utility.translatePixelsToInches(0); -// y1 = Utility.translatePixelsToInches(0); -// x2 = Utility.translatePixelsToInches(line.getWidth() - 1); -// y2 = Utility.translatePixelsToInches(line.getHeight() - 1); -// } -// else -// { -// x1 = Utility.translatePixelsToInches(0); -// y1 = Utility.translatePixelsToInches(line.getHeight() - 1); -// x2 = Utility.translatePixelsToInches(line.getWidth() - 1); -// y2 = Utility.translatePixelsToInches(0); -// } - - tempBodyWriter.write(""); -//FIXMEODS insertPageAnchor(); -// tempBodyWriter.write( -// "" -// //+ "" -// + "" -// ); - tempBodyWriter.write(""); - tableBuilder.buildCellFooter(); + tableBuilder.exportLine(line, gridCell); } @Override @@ -746,7 +703,9 @@ protected OdsTableBuilder( DocumentBuilder documentBuilder, JasperPrint jasperPrint, int pageFormatIndex, - int pageIndex, + int pageIndex, + StringBuffer tempShapeWriter, + StringBuffer tempColumnWriter, WriterHelper bodyWriter, WriterHelper styleWriter, StyleCache styleCache, @@ -758,7 +717,9 @@ protected OdsTableBuilder( documentBuilder, jasperPrint, pageFormatIndex, - pageIndex, + pageIndex, + tempShapeWriter, + tempColumnWriter, bodyWriter, styleWriter, styleCache, @@ -771,7 +732,9 @@ protected OdsTableBuilder( DocumentBuilder documentBuilder, JasperPrint jasperPrint, int pageFormatIndex, - int pageIndex, + int pageIndex, + StringBuffer tempShapeWriter, + StringBuffer tempColumnWriter, WriterHelper bodyWriter, WriterHelper styleWriter, StyleCache styleCache, @@ -784,7 +747,9 @@ protected OdsTableBuilder( documentBuilder, jasperPrint, pageFormatIndex, - pageIndex, + pageIndex, + tempShapeWriter, + tempColumnWriter, bodyWriter, styleWriter, styleCache, diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/oasis/TableBuilder.java b/jasperreports/src/net/sf/jasperreports/engine/export/oasis/TableBuilder.java index 9bf0c2d1d0..7de20d6135 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/oasis/TableBuilder.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/oasis/TableBuilder.java @@ -46,6 +46,7 @@ import net.sf.jasperreports.engine.JRPrintLine; import net.sf.jasperreports.engine.JRPrintText; import net.sf.jasperreports.engine.JRPropertiesUtil; +import net.sf.jasperreports.engine.JRPrintRectangle; import net.sf.jasperreports.engine.JRRuntimeException; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReportsContext; @@ -72,6 +73,8 @@ public class TableBuilder protected String tableName; private final JasperPrint jasperPrint; private int pageFormatIndex; + private StringBuffer shapeWriter; + private StringBuffer columnWriter; private final WriterHelper bodyWriter; private final WriterHelper styleWriter; private final StyleCache styleCache; @@ -87,6 +90,8 @@ protected TableBuilder( DocumentBuilder documentBuilder, JasperPrint jasperPrint, String name, + StringBuffer shapeWriter, + StringBuffer columnWriter, WriterHelper bodyWriter, WriterHelper styleWriter, StyleCache styleCache, @@ -101,6 +106,8 @@ protected TableBuilder( isFrame = true; isPageBreak = false; + this.shapeWriter = shapeWriter; + this.columnWriter = columnWriter; this.bodyWriter = bodyWriter; this.styleWriter = styleWriter; this.styleCache = styleCache; @@ -111,6 +118,21 @@ protected TableBuilder( this.tabColor = tabColor; } + protected TableBuilder( + DocumentBuilder documentBuilder, + JasperPrint jasperPrint, + String name, + WriterHelper bodyWriter, + WriterHelper styleWriter, + StyleCache styleCache, + Map rowStyles, + Map columnStyles, + Color tabColor + ) + { + this(documentBuilder, jasperPrint, name, null, null, bodyWriter, styleWriter, styleCache, rowStyles, columnStyles, null); + } + protected TableBuilder( DocumentBuilder documentBuilder, JasperPrint jasperPrint, @@ -132,6 +154,8 @@ protected TableBuilder( JasperPrint jasperPrint, int pageFormatIndex, int pageIndex, + StringBuffer shapeWriter, + StringBuffer columnWriter, WriterHelper bodyWriter, WriterHelper styleWriter, StyleCache styleCache, @@ -147,6 +171,8 @@ protected TableBuilder( isPageBreak = (pageFormatIndex != 0 || pageIndex != 0); this.pageFormatIndex = pageFormatIndex; + this.shapeWriter = shapeWriter; + this.columnWriter = columnWriter; this.bodyWriter = bodyWriter; this.styleWriter = styleWriter; this.styleCache = styleCache; @@ -157,6 +183,21 @@ protected TableBuilder( this.tabColor = tabColor; } + protected TableBuilder( + DocumentBuilder documentBuilder, + JasperPrint jasperPrint, + int pageFormatIndex, + int pageIndex, + WriterHelper bodyWriter, + WriterHelper styleWriter, + StyleCache styleCache, + Map rowStyles, + Map columnStyles, + Color tabColor + ) + { + this(documentBuilder, jasperPrint, pageFormatIndex, pageIndex, null, null, bodyWriter, styleWriter, styleCache, rowStyles, columnStyles, tabColor); + } protected TableBuilder( DocumentBuilder documentBuilder, @@ -202,6 +243,12 @@ public void buildTableHeader() public void buildTableFooter() { + if (shapeWriter != null) { + bodyWriter.write(shapeWriter.toString()); + } + if (columnWriter != null) { + bodyWriter.write(columnWriter.toString()); + } bodyWriter.write("\n"); } @@ -216,14 +263,24 @@ public void buildRowStyle(int rowIndex, int rowHeight) public void buildRowHeader(int rowHeight) { - bodyWriter.write("\n"); + if (columnWriter != null) { + columnWriter.append("\n"); + } else { + bodyWriter.write("\n"); + } } public void buildRowFooter() { - bodyWriter.write("\n"); + if (columnWriter != null) { + columnWriter.append("\n"); + } else { + bodyWriter.write("\n"); + } } public void buildRow(int rowIndex, int rowHeight) @@ -246,56 +303,126 @@ public void buildColumnStyle(int colIndex, int colWidth) public void buildColumnHeader(int colWidth) { - bodyWriter.write("\n"); + if (columnWriter != null) { + columnWriter.append("\n"); + } else { + bodyWriter.write("\n"); + } } public void buildColumnFooter() { - bodyWriter.write("\n"); + if (columnWriter != null) { + columnWriter.append("\n"); + } else { + bodyWriter.write("\n"); + } } public void buildCellHeader(String cellStyleName, int colSpan, int rowSpan) { - //FIXMEODT officevalue bodyWriter.write(" 1) - { - bodyWriter.write(" table:number-columns-spanned=\"" + colSpan + "\""); - } - if (rowSpan > 1) - { - bodyWriter.write(" table:number-rows-spanned=\"" + rowSpan + "\""); + if (columnWriter != null) { + //FIXMEODT officevalue bodyWriter.write(" 1) + { + columnWriter.append(" table:number-columns-spanned=\"" + colSpan + "\""); + } + if (rowSpan > 1) + { + columnWriter.append(" table:number-rows-spanned=\"" + rowSpan + "\""); + } + + columnWriter.append(">\n"); + } else { + //FIXMEODT officevalue bodyWriter.write(" 1) + { + bodyWriter.write(" table:number-columns-spanned=\"" + colSpan + "\""); + } + if (rowSpan > 1) + { + bodyWriter.write(" table:number-rows-spanned=\"" + rowSpan + "\""); + } + + bodyWriter.write(">\n"); } - - bodyWriter.write(">\n"); } public void buildCellFooter() { - bodyWriter.write("\n"); + if (columnWriter != null) { + columnWriter.append("\n"); + } else { + bodyWriter.write("\n"); + } } /** * */ - public void exportRectangle(JRPrintGraphicElement rectangle, JRExporterGridCell gridCell) + public void exportRectangle(JRPrintRectangle rectangle, JRExporterGridCell gridCell) { - JRLineBox box = new JRBaseLineBox(null); - JRPen pen = box.getPen(); - pen.setLineColor(rectangle.getLinePen().getLineColor()); - pen.setLineStyle(rectangle.getLinePen().getLineStyleValue()); - pen.setLineWidth(rectangle.getLinePen().getLineWidth()); - - gridCell.setBox(box);//CAUTION: only some exporters set the cell box + buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); + if (shapeWriter != null) { + documentBuilder.insertPageAnchor(this); + if (rectangle.getRadius() > 0) + { + int size = Math.min(50000, ((rectangle).getRadius() * 100000)/Math.min(rectangle.getHeight(), rectangle.getWidth())); + shapeWriter.append( + "" + + "" + + "" + + "" + + "" + + "" + ); + } + else + { + shapeWriter.append( + "" + + "" + ); + } + } else { + bodyWriter.write(""); + documentBuilder.insertPageAnchor(this); + bodyWriter.write( + "" + + "" + ); + } - buildCellHeader(styleCache.getCellStyle(gridCell), gridCell.getColSpan(), gridCell.getRowSpan()); buildCellFooter(); } @@ -305,38 +432,64 @@ public void exportRectangle(JRPrintGraphicElement rectangle, JRExporterGridCell */ public void exportLine(JRPrintLine line, JRExporterGridCell gridCell) { - buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); - double x1, y1, x2, y2; - if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) - { - x1 = 0; - y1 = 0; - x2 = line.getWidth() - 1; - y2 = line.getHeight() - 1; + buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); + if (shapeWriter != null) { + if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) + { + x1 = line.getX(); + x2 = x1 + line.getWidth() - 1; + y1 = line.getY()+1; + y2 = y1 + line.getHeight() - 1; + } + else + { + x1 = line.getX(); + x2 = x1 + line.getWidth() - 1; + y2 = line.getY()+1; + y1 = y2 + line.getHeight() - 1; + } + //documentBuilder.insertPageAnchor(this); + //bodyWriter.write(""); + shapeWriter.append( + "" + + "" + ); + } else { + if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) + { + x1 = 0; + y1 = 0; + x2 = line.getWidth() - 1; + y2 = line.getHeight() - 1; + } + else + { + x1 = 0; + y1 = line.getHeight() - 1; + x2 = line.getWidth() - 1; + y2 = 0; + } + + bodyWriter.write(""); + documentBuilder.insertPageAnchor(this); + bodyWriter.write( + "" + + "" + + "" + ); } - else - { - x1 = 0; - y1 = line.getHeight() - 1; - x2 = line.getWidth() - 1; - y2 = 0; - } - - bodyWriter.write(""); - documentBuilder.insertPageAnchor(this); - bodyWriter.write( - "" - //+ "" - + "" - + "" - ); buildCellFooter(); } @@ -347,17 +500,30 @@ public void exportLine(JRPrintLine line, JRExporterGridCell gridCell) public void exportEllipse(JRPrintEllipse ellipse, JRExporterGridCell gridCell) { buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); - bodyWriter.write(""); - documentBuilder.insertPageAnchor(this); - bodyWriter.write( - "" - + "" - ); + if (shapeWriter != null) { + documentBuilder.insertPageAnchor(this); + shapeWriter.append( + "" + + "" + ); + } else { + bodyWriter.write(""); + documentBuilder.insertPageAnchor(this); + bodyWriter.write( + "" + + "" + ); + } buildCellFooter(); } @@ -368,20 +534,33 @@ public void exportEllipse(JRPrintEllipse ellipse, JRExporterGridCell gridCell) public void exportText(JRPrintText text, JRExporterGridCell gridCell, boolean shrinkToFit, boolean wrapText, boolean isIgnoreTextFormatting) { buildCellHeader((isIgnoreTextFormatting ? null : styleCache.getCellStyle(gridCell, shrinkToFit, wrapText)), gridCell.getColSpan(), gridCell.getRowSpan()); - - bodyWriter.write(""); - documentBuilder.insertPageAnchor(this); - if (text.getAnchorName() != null) - { - exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName())); - } + if (columnWriter != null) { + columnWriter.append(""); + documentBuilder.insertPageAnchor(this); + if (text.getAnchorName() != null) + { + exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName())); + } + + exportTextContents(text); - exportTextContents(text); + columnWriter.append("\n"); + } else { + bodyWriter.write(""); + documentBuilder.insertPageAnchor(this); + if (text.getAnchorName() != null) + { + exportAnchor(JRStringUtil.xmlEncode(text.getAnchorName())); + } - bodyWriter.write("\n"); + exportTextContents(text); + bodyWriter.write("\n"); + } buildCellFooter(); } @@ -482,13 +661,23 @@ protected void exportStyledTextRun( */ protected void startTextSpan(Map attributes, String text, Locale locale, boolean isIgnoreTextFormatting) { - bodyWriter.write(""); + } else { + bodyWriter.write(""); } - bodyWriter.write(">"); } @@ -497,7 +686,11 @@ protected void startTextSpan(Map */ protected void endTextSpan() { - bodyWriter.write(""); + if (columnWriter != null) { + columnWriter.append(""); + } else { + bodyWriter.write(""); + } } @@ -508,7 +701,11 @@ protected void writeText(String text) { if (text != null) { - bodyWriter.write(Utility.replaceNewLineWithLineBreak(JRStringUtil.xmlEncode(text, documentBuilder.getInvalidCharReplacement())));//FIXMEODT try something nicer for replace + if (columnWriter != null) { + columnWriter.append(Utility.replaceNewLineWithLineBreak(JRStringUtil.xmlEncode(text, documentBuilder.getInvalidCharReplacement())));//FIXMEODT try something nicer for replace + } else { + bodyWriter.write(Utility.replaceNewLineWithLineBreak(JRStringUtil.xmlEncode(text, documentBuilder.getInvalidCharReplacement())));//FIXMEODT try something nicer for replace + } } } @@ -518,9 +715,15 @@ protected void writeText(String text) */ protected void exportAnchor(String anchorName) { - bodyWriter.write(""); + if (columnWriter != null) { + columnWriter.append(""); + } else { + bodyWriter.write(""); + } } @@ -575,40 +778,77 @@ protected boolean startHyperlink(JRPrintHyperlink link, boolean isText, boolean */ protected void writeHyperlink(JRPrintHyperlink link, String href, boolean isText) { - if(isText) - { - bodyWriter.write(""); + } else { + if(isText) + { + bodyWriter.write(""); } -*/ - bodyWriter.write(">"); } @@ -617,13 +857,24 @@ protected void writeHyperlink(JRPrintHyperlink link, String href, boolean isText */ protected void endHyperlink(boolean isText) { - if(isText) - { - bodyWriter.write(""); - } - else - { - bodyWriter.write(""); + if (columnWriter != null) { + if(isText) + { + columnWriter.append(""); + } + else + { + columnWriter.append(""); + } + } else { + if(isText) + { + bodyWriter.write(""); + } + else + { + bodyWriter.write(""); + } } } @@ -663,4 +914,4 @@ protected JasperReportsContext getJasperReportsContext() public String getTableName() { return tableName; } -} \ No newline at end of file +} diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/DocxDocumentHelper.java b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/DocxDocumentHelper.java index 61a898cd1e..611987ab24 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/DocxDocumentHelper.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/DocxDocumentHelper.java @@ -40,7 +40,7 @@ */ public class DocxDocumentHelper extends BaseHelper { - protected static int DEFAULT_LINE_PITCH = 360; + protected static int DEFAULT_LINE_PITCH = 360; /** * @@ -63,6 +63,11 @@ public void exportHeader() write(" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"\n"); write(" xmlns:v=\"urn:schemas-microsoft-com:vml\"\n"); write(" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"\n"); + write(" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"\n"); + write(" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n"); + write(" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\"\n"); + write(" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"\n"); + write(" mc:Ignorable=\"w14 wp14\"\n"); write(" xmlns:w10=\"urn:schemas-microsoft-com:office:word\"\n"); write(" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"\n"); write(" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\"\n"); @@ -127,7 +132,7 @@ public void exportSection(PrintPageFormat pageFormat, JRGridLayout pageGridLayou + LengthUtil.twip(leftMargin) + "\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\" />\n"); // write(" \n"); - write(" \n"); + write(" \n"); write(" \n"); if (!lastPage) { diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRDocxExporter.java b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRDocxExporter.java index f097d44fa0..ff67acc2d2 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRDocxExporter.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRDocxExporter.java @@ -58,6 +58,7 @@ import net.sf.jasperreports.engine.JRPrintImage; import net.sf.jasperreports.engine.JRPrintLine; import net.sf.jasperreports.engine.JRPrintPage; +import net.sf.jasperreports.engine.JRPrintGraphicElement; import net.sf.jasperreports.engine.JRPrintRectangle; import net.sf.jasperreports.engine.JRPrintText; import net.sf.jasperreports.engine.JRPropertiesUtil; @@ -69,6 +70,7 @@ import net.sf.jasperreports.engine.export.CutsInfo; import net.sf.jasperreports.engine.export.ElementGridCell; import net.sf.jasperreports.engine.export.ExporterNature; +import net.sf.jasperreports.engine.export.ExportCompatibility; import net.sf.jasperreports.engine.export.GenericElementHandlerEnviroment; import net.sf.jasperreports.engine.export.Grid; import net.sf.jasperreports.engine.export.GridRow; @@ -86,6 +88,7 @@ import net.sf.jasperreports.engine.type.LineDirectionEnum; import net.sf.jasperreports.engine.type.ModeEnum; import net.sf.jasperreports.engine.type.ScaleImageEnum; +import net.sf.jasperreports.engine.util.JRColorUtil; import net.sf.jasperreports.engine.util.JRStringUtil; import net.sf.jasperreports.engine.util.JRStyledText; import net.sf.jasperreports.engine.util.JRTextAttribute; @@ -210,6 +213,7 @@ public class JRDocxExporter extends JRAbstractExporter items = exporterInput.getItems(); @@ -513,7 +518,8 @@ protected void exportPage(JRPrintPage page) throws JRException pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), - null //address + null, //address + ExportCompatibility.getCompatibility(getCurrentConfiguration().getCompatibility()) ); exportGrid(pageGridLayout, null); @@ -631,7 +637,8 @@ protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameInde for(int col = 0; col < rowSize; col++) { JRExporterGridCell gridCell = gridRow.get(col); - if (gridCell.getType() == JRExporterGridCell.TYPE_OCCUPIED_CELL) + + if (ExportCompatibility.NONE == compatibility && gridCell.getType() == JRExporterGridCell.TYPE_OCCUPIED_CELL) { if (emptyCellColSpan > 0) { @@ -650,7 +657,8 @@ protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameInde } col += elementGridCell.getColSpan() - 1; } - else if (gridCell.getType() == JRExporterGridCell.TYPE_ELEMENT_CELL) + else if ((ExportCompatibility.NONE == compatibility && gridCell.getType() == JRExporterGridCell.TYPE_ELEMENT_CELL) || +(ExportCompatibility.NONE != compatibility && (gridCell.getType() == JRExporterGridCell.TYPE_OCCUPIED_CELL || gridCell.getType() == JRExporterGridCell.TYPE_ELEMENT_CELL))) { if (emptyCellColSpan > 0) { @@ -719,11 +727,194 @@ else if (element instanceof JRGenericPrintElement) emptyPageState = false; } + private void drawShape(JRPrintGraphicElement shape, JRExporterGridCell gridCell) throws JRException + { + String shapeFill = ""; + if (shape.getModeValue() == ModeEnum.OPAQUE && shape.getBackcolor() != null) + { + shapeFill = ""; + } + + JRPen pen = shape.getLinePen(); + String fgColor = ""; + String penStyle = ""; + if (pen.getLineWidth() > 0) + { + switch (pen.getLineStyleValue()) + { + case DASHED : + { + penStyle = ""; + break; + } + case DOTTED : + { + penStyle = ""; + break; + } + case DOUBLE : + case SOLID : + default : + { + break; + } + } + } + + String shapeType = "rect"; + String flip = ""; + String radius = ""; + String fallback; + + if (shape instanceof JRPrintEllipse) + { + shapeType = "ellipse"; + fallback = + "" + + "" + + "" + + "" + + ""; + } + else if (shape instanceof JRPrintLine) + { + shapeType = "line"; + if (((JRPrintLine)shape).getDirectionValue() != LineDirectionEnum.TOP_DOWN) + { + flip = " flipV=\"1\""; + } + fallback = + "" + + "" + + "" + + "" + + ""; + } + else if (shape instanceof JRPrintRectangle) + { + shapeType = (((JRPrintRectangle)shape).getRadius() == 0) ? "rect" : "roundRect"; + if (((JRPrintRectangle)shape).getRadius() > 0) + { + // a rounded rectangle radius cannot exceed 1/2 of its lower side; + int size = Math.min(50000, (((JRPrintRectangle)shape).getRadius() * 100000)/Math.min(shape.getHeight(), shape.getWidth())); + radius = ""; + } + fallback = + "" + + "" + + "" + + "" + + ""; + } + else + { + shapeType = "rect"; + fallback = + "" + + "" + + "" + + "" + + ""; + } + + try + { + docWriter.write( + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + LengthUtil.emu(shape.getX()) + "" + + "" + + "" + + "" + LengthUtil.emu(shape.getY()) + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + radius + + "" + + shapeFill + + "" + + fgColor + + penStyle + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + fallback + + "" + + "" + + "" + + "" + ); + } catch (IOException e) { + throw new JRException(e); + } + } /** * */ - protected void exportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) + protected void exportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) throws JRException + { + switch(compatibility) + { + case MSOFFICE2007: + { + drawShape(line, gridCell); + break; + } + default: + { + exportLineDefault(tableHelper, line, gridCell); + break; + } + } + } + + private void exportLineDefault(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = null; @@ -766,11 +957,27 @@ protected void exportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExpor tableHelper.getCellHelper().exportFooter(); } - /** * */ - protected void exportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) + protected void exportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) throws JRException + { + switch (compatibility) + { + case MSOFFICE2007: + { + drawShape(rectangle, gridCell); + break; + } + default: + { + exportRectangleDefault(tableHelper, rectangle, gridCell); + break; + } + } + } + + private void exportRectangleDefault(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); @@ -790,11 +997,27 @@ protected void exportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rec tableHelper.getCellHelper().exportFooter(); } - /** * */ - protected void exportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) + protected void exportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) throws JRException + { + switch(compatibility) + { + case MSOFFICE2007: + { + drawShape(ellipse, gridCell); + break; + } + default: + { + exportEllipseDefault(tableHelper, ellipse, gridCell); + break; + } + } + } + + private void exportEllipseDefault(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) { JRLineBox box = new JRBaseLineBox(null); JRPen pen = box.getPen(); @@ -814,7 +1037,6 @@ protected void exportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse tableHelper.getCellHelper().exportFooter(); } - /** * */ @@ -1705,5 +1927,14 @@ public String getExporterPropertiesPrefix() return DOCX_EXPORTER_PROPERTIES_PREFIX; } + protected String toOOXMLId(JRPrintElement element) + { + // using hashCode() for now, though in theory there is a risk of collisions + // we could use something based on getSourceElementId() and getPrintElementId() + // or even a counter since we do not have any references to Ids + int hashCode = element.hashCode(); + // OOXML object ids are xsd:unsignedInt + return Long.toString(hashCode & 0xFFFFFFFFL); + } } diff --git a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRXlsxExporter.java b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRXlsxExporter.java index 073e06d979..345b6b596d 100644 --- a/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRXlsxExporter.java +++ b/jasperreports/src/net/sf/jasperreports/engine/export/ooxml/JRXlsxExporter.java @@ -51,12 +51,14 @@ import net.sf.jasperreports.engine.JRPen; import net.sf.jasperreports.engine.JRPrintElement; import net.sf.jasperreports.engine.JRPrintElementIndex; +import net.sf.jasperreports.engine.JRPrintEllipse; import net.sf.jasperreports.engine.JRPrintFrame; import net.sf.jasperreports.engine.JRPrintGraphicElement; import net.sf.jasperreports.engine.JRPrintHyperlink; import net.sf.jasperreports.engine.JRPrintImage; import net.sf.jasperreports.engine.JRPrintLine; import net.sf.jasperreports.engine.JRPrintPage; +import net.sf.jasperreports.engine.JRPrintRectangle; import net.sf.jasperreports.engine.JRPrintText; import net.sf.jasperreports.engine.JRPropertiesUtil; import net.sf.jasperreports.engine.JRRuntimeException; @@ -67,6 +69,7 @@ import net.sf.jasperreports.engine.base.JRBaseLineBox; import net.sf.jasperreports.engine.export.Cut; import net.sf.jasperreports.engine.export.CutsInfo; +import net.sf.jasperreports.engine.export.ExportCompatibility; import net.sf.jasperreports.engine.export.GenericElementHandlerEnviroment; import net.sf.jasperreports.engine.export.HyperlinkUtil; import net.sf.jasperreports.engine.export.JRExporterGridCell; @@ -87,10 +90,12 @@ import net.sf.jasperreports.engine.export.zip.FileBufferedZipEntry; import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; import net.sf.jasperreports.engine.type.LineDirectionEnum; +import net.sf.jasperreports.engine.type.LineStyleEnum; import net.sf.jasperreports.engine.type.ModeEnum; import net.sf.jasperreports.engine.type.ScaleImageEnum; import net.sf.jasperreports.engine.util.DefaultFormatFactory; import net.sf.jasperreports.engine.util.FileBufferedOutputStream; +import net.sf.jasperreports.engine.util.JRColorUtil; import net.sf.jasperreports.engine.util.JRDataUtils; import net.sf.jasperreports.engine.util.JRStringUtil; import net.sf.jasperreports.engine.util.JRStyledText; @@ -189,6 +194,7 @@ public class JRXlsxExporter extends JRXlsAbstractExporter sheetMapping; + private static ExportCompatibility compatibility; protected class ExporterContext extends BaseExporterContext implements JRXlsxExporterContext { @@ -1325,6 +1331,129 @@ protected InternalImageProcessorResult(String imagePath, Dimension2D dimension) } } + private void drawShape( + JRPrintGraphicElement shape, + JRExporterGridCell gridCell, + int colIndex, + int rowIndex + ) throws JRException + { + String shapeType = "rect"; + String flip = ""; + String radius = ""; + + if (shape instanceof JRPrintEllipse) + { + shapeType = "ellipse"; + + } + else if (shape instanceof JRPrintLine) + { + shapeType = "line"; + if (((JRPrintLine)shape).getDirectionValue() != LineDirectionEnum.TOP_DOWN) + { + flip = " flipV=\"1\""; + } + } + else if (shape instanceof JRPrintRectangle) + { + shapeType = (((JRPrintRectangle)shape).getRadius() == 0) ? "rect" : "roundRect"; + if (((JRPrintRectangle)shape).getRadius() > 0) + { + // a rounded rectangle radius cannot exceed 1/2 of its lower side; + int size = Math.min(50000, (((JRPrintRectangle)shape).getRadius() * 100000)/Math.min(shape.getHeight(), shape.getWidth())); + radius = ""; + } + } + else + { + shapeType = "rect"; + } + Boolean tIgnoreCellBackground = sheetInfo.ignoreCellBackground; + sheetInfo.ignoreCellBackground = Boolean.TRUE; // TODO currently used to force background of shape cell to be white + cellHelper.exportHeader(gridCell, rowIndex, colIndex, maxColumnIndex, sheetInfo); + sheetHelper.exportMergedCells(rowIndex, colIndex, maxColumnIndex, gridCell.getRowSpan(), gridCell.getColSpan()); + sheetInfo.ignoreCellBackground = tIgnoreCellBackground; + + String shapeFill = ""; + if (shape.getModeValue() == ModeEnum.OPAQUE && shape.getBackcolor() != null) + { + shapeFill = ""; + } + JRPen pen = shape.getLinePen(); + Color penColor = pen.getLineColor(); + String penStyle = ""; + if (pen.getLineWidth() > 0) + { + switch (pen.getLineStyleValue()) + { + case DASHED : + { + penStyle = ""; + break; + } + case DOTTED : + { + penStyle = ""; + break; + } + case DOUBLE : + case SOLID : + default : + { + break; + } + } + } + + drawingHelper.write( + "" + + "" + + "" + colIndex + "" + + "0" + + "" + rowIndex + "" + + "0" + + "" + + "" + + "" + (colIndex + gridCell.getColSpan()) + "" + + "0" + + "" + (rowIndex + gridCell.getRowSpan()) + "" + + "0" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + radius + + "" + + shapeFill + + "" + + "" + + "" + + "" + + penStyle + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + ); + + cellHelper.exportFooter(); + } @Override protected void exportLine( @@ -1333,6 +1462,28 @@ protected void exportLine( int colIndex, int rowIndex ) throws JRException + { + switch(compatibility) + { + case MSOFFICE2007: + { + drawShape(line, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportLineDefault(line, gridCell, colIndex, rowIndex); + break; + } + } + } + + private void exportLineDefault( + JRPrintLine line, + JRExporterGridCell gridCell, + int colIndex, + int rowIndex + ) throws JRException { JRLineBox box = new JRBaseLineBox(null); JRPen pen = null; @@ -1381,9 +1532,30 @@ else if (line.getDirectionValue() == LineDirectionEnum.TOP_DOWN) cellHelper.exportFooter(); } - @Override protected void exportRectangle( + JRPrintRectangle rectangle, + JRExporterGridCell gridCell, + int colIndex, + int rowIndex + ) throws JRException + { + switch (compatibility) + { + case MSOFFICE2007: + { + drawShape(rectangle, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportRectangleDefault((JRPrintGraphicElement)rectangle, gridCell, colIndex, rowIndex); + break; + } + } + } + + private void exportRectangleDefault( JRPrintGraphicElement rectangle, JRExporterGridCell gridCell, int colIndex, @@ -1403,6 +1575,28 @@ protected void exportRectangle( cellHelper.exportFooter(); } + @Override + protected void exportEllipse( + JRPrintEllipse ellipse, + JRExporterGridCell gridCell, + int colIndex, + int rowIndex + ) throws JRException + { + switch(compatibility) + { + case MSOFFICE2007: + { + drawShape(ellipse, gridCell, colIndex, rowIndex); + break; + } + default: + { + exportRectangleDefault((JRPrintGraphicElement)ellipse, gridCell, colIndex, rowIndex); + break; + } + } + } @Override public void exportText( @@ -1682,6 +1876,7 @@ protected void openWorkbook(OutputStream os) throws JRException firstPageNotSet = true; firstSheetName = null; + compatibility = ExportCompatibility.getCompatibility(configuration.getCompatibility()); } catch (IOException e) { @@ -1806,5 +2001,14 @@ protected String getDefinedName(String name) return null; } + protected String toOOXMLId(JRPrintElement element) + { + // using hashCode() for now, though in theory there is a risk of collisions + // we could use something based on getSourceElementId() and getPrintElementId() + // or even a counter since we do not have any references to Ids + int hashCode = element.hashCode(); + // OOXML object ids are xsd:unsignedInt + return Long.toString(hashCode & 0xFFFFFFFFL); + } } diff --git a/jasperreports/src/net/sf/jasperreports/export/AbstractXlsExporterConfiguration.java b/jasperreports/src/net/sf/jasperreports/export/AbstractXlsExporterConfiguration.java index 5e8e9b287e..cbbd682383 100644 --- a/jasperreports/src/net/sf/jasperreports/export/AbstractXlsExporterConfiguration.java +++ b/jasperreports/src/net/sf/jasperreports/export/AbstractXlsExporterConfiguration.java @@ -31,6 +31,7 @@ public abstract class AbstractXlsExporterConfiguration extends SimpleExporterCon { private Boolean isCreateCustomPalette; private String workbookTemplate; + private String compatibility; private Boolean isKeepWorkbookTemplateSheets; private String metadataTitle; private String metadataAuthor; @@ -78,7 +79,17 @@ public void setWorkbookTemplate(String workbookTemplate) this.workbookTemplate = workbookTemplate; } - + @Override + public String getCompatibility() + { + return compatibility; + } + + public void setCompatibility(String compatibility) + { + this.compatibility = compatibility; + } + @Override public Boolean isKeepWorkbookTemplateSheets() { diff --git a/jasperreports/src/net/sf/jasperreports/export/DocxExporterConfiguration.java b/jasperreports/src/net/sf/jasperreports/export/DocxExporterConfiguration.java index 6b4e5ef21f..b2742cbe08 100644 --- a/jasperreports/src/net/sf/jasperreports/export/DocxExporterConfiguration.java +++ b/jasperreports/src/net/sf/jasperreports/export/DocxExporterConfiguration.java @@ -89,6 +89,16 @@ public interface DocxExporterConfiguration extends ExporterConfiguration ) public static final String PROPERTY_METADATA_APPLICATION = JRDocxExporter.DOCX_EXPORTER_PROPERTIES_PREFIX + "metadata.application"; + /** + * Property whose value is used to determine export compatibilty version. + */ + @Property( + category = PropertyConstants.CATEGORY_EXPORT, + scopes = {PropertyScope.CONTEXT, PropertyScope.REPORT}, + sinceVersion = PropertyConstants.VERSION_6_8_0 + ) + public static final String PROPERTY_COMPATIBILITY = JRDocxExporter.DOCX_EXPORTER_PROPERTIES_PREFIX + "compatibility"; + /** * The Title of the DOCX document. */ @@ -118,4 +128,7 @@ public interface DocxExporterConfiguration extends ExporterConfiguration */ @ExporterProperty(PROPERTY_METADATA_APPLICATION) public String getMetadataApplication(); + + @ExporterProperty(PROPERTY_COMPATIBILITY) + public String getCompatibility(); } diff --git a/jasperreports/src/net/sf/jasperreports/export/SimpleDocxExporterConfiguration.java b/jasperreports/src/net/sf/jasperreports/export/SimpleDocxExporterConfiguration.java index 354e29ceed..bd15b954cd 100644 --- a/jasperreports/src/net/sf/jasperreports/export/SimpleDocxExporterConfiguration.java +++ b/jasperreports/src/net/sf/jasperreports/export/SimpleDocxExporterConfiguration.java @@ -34,6 +34,7 @@ public class SimpleDocxExporterConfiguration extends SimpleExporterConfiguration private String metadataSubject; private String metadataKeywords; private String metadataApplication; + private String compatibility; @Override public String getMetadataTitle() @@ -104,4 +105,15 @@ public void setMetadataApplication(String metadataApplication) { this.metadataApplication = metadataApplication; } + + @Override + public String getCompatibility() + { + return compatibility; + } + + public void setCompatibility(String compatibility) + { + this.compatibility = compatibility; + } } diff --git a/jasperreports/src/net/sf/jasperreports/export/XlsExporterConfiguration.java b/jasperreports/src/net/sf/jasperreports/export/XlsExporterConfiguration.java index 29690eec13..6f56f441be 100644 --- a/jasperreports/src/net/sf/jasperreports/export/XlsExporterConfiguration.java +++ b/jasperreports/src/net/sf/jasperreports/export/XlsExporterConfiguration.java @@ -146,6 +146,16 @@ public interface XlsExporterConfiguration extends ExporterConfiguration ) public static final String PROPERTY_METADATA_APPLICATION = JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.metadata.application"; + /** + * Property whose value is used to determine export compatibilty version. + */ + @Property( + category = PropertyConstants.CATEGORY_EXPORT, + scopes = {PropertyScope.CONTEXT, PropertyScope.REPORT}, + sinceVersion = PropertyConstants.VERSION_3_0_0 + ) + public static final String PROPERTY_COMPATIBILITY = JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.compatibility"; + /** * Returns a boolean value specifying whether the standard color palette should be customized * so that the XLS result uses the original report colors. @@ -238,4 +248,10 @@ public interface XlsExporterConfiguration extends ExporterConfiguration */ @ExporterProperty(PROPERTY_METADATA_APPLICATION) public String getMetadataApplication(); + + /** + * Export compatibility version. Defaults to "NONE" implying export using cells without using shapes. + */ + @ExporterProperty(PROPERTY_COMPATIBILITY) + public String getCompatibility(); }