Class JRDocxExporter
java.lang.Object
net.sf.jasperreports.engine.JRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput,JRDocxExporterContext>
net.sf.jasperreports.engine.export.ooxml.JRDocxExporter
- All Implemented Interfaces:
Exporter<ExporterInput,DocxReportConfiguration, DocxExporterConfiguration, OutputStreamExporterOutput>
public class JRDocxExporter
extends JRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput,JRDocxExporterContext>
Exports a JasperReports document to DOCX format. It has binary output type and exports the document to a
grid-based layout, therefore having the known limitations of grid exporters.
It can work in batch mode and supports all types of
exporter input and output, content filtering, and font mappings.
Currently, there are the following special configurations that can be made to a DOCX
exporter instance (see
DocxReportConfiguration):
- Forcing the use of nested tables to render the content of frame elements using either
the
isFramesAsNestedTables()exporter configuration flag or its corresponding exporter hint callednet.sf.jasperreports.export.docx.frames.as.nested.tables. - Allowing table rows to adjust their height if more text is typed into their cells using
the Word editor. This is controlled using either the
isFlexibleRowHeight()exporter configuration flag, or its corresponding exporter hint callednet.sf.jasperreports.export.docx.flexible.row.height. - Ignoring hyperlinks in generated documents if they are not intended for the DOCX output format. This can be
customized using either the
isIgnoreHyperlink()exporter configuration flag, or its corresponding exporter hint callednet.sf.jasperreports.export.docx.ignore.hyperlink
- Author:
- Sanda Zaharia (shertage@users.sourceforge.net)
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropsAppHelperprotected Colorprotected LinkedList<Color> protected ExporterNatureprotected longprotected PropsCoreHelperprotected DocxDocumentHelperprotected Writerprotected DocxRelsHelperprotected DocxRunHelperprotected DocxContentTypesHelperprotected DocxDocumentHelperprotected Writerstatic final StringThe exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).static final Stringprotected DocxFontHelperprotected DocxFontTableHelperprotected DocxFontTableRelsHelperprotected DocxZipprotected intstatic final Stringprotected DocxHeaderHelperprotected intprotected DocxHeaderRelsHelperprotected DocxRunHelperprotected Writerstatic final Stringstatic final Stringprotected static final intprotected Stringstatic final Stringprotected Stringprotected PrintPageFormatprotected JRGridLayoutprotected intprotected ExporterNaturestatic final StringThis property is used to mark text elements as being hidden either for printing or on-screen display.protected DocxRelsHelperprotected RenderersCacheprotected Map<String, Pair<String, ExifOrientationEnum>> protected intprotected DocxRunHelperprotected booleanprotected intprotected intFields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_EMPTY_INPUT_SOURCE_IN_BATCH_MODE, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_NO_INPUT_SOURCE, EXCEPTION_MESSAGE_KEY_NO_OUTPUT_SPECIFIED, EXCEPTION_MESSAGE_KEY_OUTPUT_WRITER_ERROR, EXCEPTION_MESSAGE_KEY_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_START_PAGE_INDEX_OUT_OF_RANGE, exporterConfiguration, exporterContext, exporterInput, exporterOutput, filter, fontUtil, hyperlinkProducerFactory, itemConfiguration, jasperPrint, jasperReportsContext, noBackcolorSelector, noneSelector, numberFormatCache, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidendHyperlink(boolean isText) protected voidprotected voidexportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) protected voidexportFrame(DocxTableHelper tableHelper, JRPrintFrame frame, JRExporterGridCell gridCell) In deep grids, this is called only for empty frames.protected voidexportGenericElement(DocxTableHelper tableHelper, JRGenericPrintElement element, JRExporterGridCell gridCell) protected voidexportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameIndex) protected voidexportHeader(JRPrintPage page) voidexportImage(DocxTableHelper tableHelper, JRPrintImage image, JRExporterGridCell gridCell) protected voidexportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) protected voidexportPage(JRPrintPage page) protected voidexportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) voidPerforms the export.protected voidprotected voidexportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified, boolean rtl) voidexportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell) protected Class<DocxExporterConfiguration> protected JRPrintElementIndexgetElementIndex(JRExporterGridCell gridCell) Returns the properties prefix for the current exporter.protected Stringprotected Stringprotected Class<DocxReportConfiguration> static JRPrintElementIndexgetPrintElementIndex(String imageName) protected JRStyledTextgetStyledText(JRPrintText textElement, boolean setBackcolor) protected voidprotected voidprotected voidinsertBookmark(String bookmark, BaseHelper helper) protected voidprotected voidsetBackcolor(Color color) protected booleanstartHyperlink(JRPrintHyperlink link, boolean isText) Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureJasperReportsContext, ensureOutput, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterConfiguration, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getPropertiesUtil, getRendererUtil, getReportContext, getReportExportConfiguration, getRepository, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetExportContext, restoreElementOffsets, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setReportContext
-
Field Details
-
DOCX_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).- See Also:
-
EXCEPTION_MESSAGE_KEY_COLUMN_COUNT_OUT_OF_RANGE
- See Also:
-
DOCX_EXPORTER_PROPERTIES_PREFIX
- See Also:
-
PROPERTY_HIDDEN_TEXT
This property is used to mark text elements as being hidden either for printing or on-screen display.- See Also:
-
JR_PAGE_ANCHOR_PREFIX
- See Also:
-
IMAGE_NAME_PREFIX
- See Also:
-
IMAGE_NAME_PREFIX_LEGTH
protected static final int IMAGE_NAME_PREFIX_LEGTH -
IMAGE_LINK_PREFIX
- See Also:
-
docxZip
-
docHelper
-
docWriter
-
headerHelper
-
headerWriter
-
crtDocHelper
-
crtDocWriter
-
rendererToImagePathMap
-
renderersCache
-
reportIndex
protected int reportIndex -
pageIndex
protected int pageIndex -
startPageIndex
protected int startPageIndex -
endPageIndex
protected int endPageIndex -
tableIndex
protected int tableIndex -
headerIndex
protected int headerIndex -
startPage
protected boolean startPage -
invalidCharReplacement
-
pageFormat
-
pageGridLayout
-
backcolorStack
-
backcolor
-
runHelper
-
headerRunHelper
-
crtRunHelper
-
backgroundNature
-
pageNature
-
bookmarkIndex
protected long bookmarkIndex -
pageAnchor
-
relsHelper
-
headerRelsHelper
-
crtRelsHelper
-
ctHelper
-
appHelper
-
coreHelper
-
docxFontHelper
-
docxFontTableHelper
-
docxFontTableRelsHelper
-
-
Constructor Details
-
JRDocxExporter
public JRDocxExporter()- See Also:
-
JRDocxExporter
-
-
Method Details
-
getConfigurationInterface
-
getItemConfigurationInterface
-
exportReport
Description copied from interface:ExporterPerforms the export.- Specified by:
exportReportin interfaceExporter<ExporterInput,DocxReportConfiguration, DocxExporterConfiguration, OutputStreamExporterOutput> - Specified by:
exportReportin classJRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration, OutputStreamExporterOutput, JRDocxExporterContext> - Throws:
JRException
-
initExport
protected void initExport() -
initReport
protected void initReport() -
exportReportToStream
- Throws:
JRExceptionIOException
-
exportHeader
- Throws:
JRException
-
exportPage
- Throws:
JRException
-
exportGrid
protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameIndex) throws JRException - Throws:
JRException
-
exportLine
protected void exportLine(DocxTableHelper tableHelper, JRPrintLine line, JRExporterGridCell gridCell) -
exportRectangle
protected void exportRectangle(DocxTableHelper tableHelper, JRPrintRectangle rectangle, JRExporterGridCell gridCell) -
exportEllipse
protected void exportEllipse(DocxTableHelper tableHelper, JRPrintEllipse ellipse, JRExporterGridCell gridCell) -
exportText
-
exportStyledText
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified, boolean rtl) -
exportImage
public void exportImage(DocxTableHelper tableHelper, JRPrintImage image, JRExporterGridCell gridCell) throws JRException - Throws:
JRException
-
getElementIndex
-
getPrintElementIndex
-
exportFrame
protected void exportFrame(DocxTableHelper tableHelper, JRPrintFrame frame, JRExporterGridCell gridCell) throws JRException In deep grids, this is called only for empty frames.- Throws:
JRException
-
exportGenericElement
protected void exportGenericElement(DocxTableHelper tableHelper, JRGenericPrintElement element, JRExporterGridCell gridCell) -
setBackcolor
-
restoreBackcolor
protected void restoreBackcolor() -
startHyperlink
-
getHyperlinkTarget
-
getHyperlinkURL
-
endHyperlink
protected void endHyperlink(boolean isText) -
insertBookmark
-
ensureInput
protected void ensureInput() -
getStyledText
-
getExporterKey
-
getExporterPropertiesPrefix
Description copied from class:JRAbstractExporterReturns the properties prefix for the current exporter.- Specified by:
getExporterPropertiesPrefixin classJRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration, OutputStreamExporterOutput, JRDocxExporterContext> - Returns:
- the properties prefix for the current exporter
-