Class JRDocxExporter
- java.lang.Object
-
- net.sf.jasperreports.engine.JRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput,JRDocxExporterContext>
-
- net.sf.jasperreports.engine.export.ooxml.JRDocxExporter
-
- All Implemented Interfaces:
JRExporter<ExporterInput,DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput>,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 (seeDocxReportConfiguration):- 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:
DocxReportConfiguration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJRDocxExporter.ExporterContext-
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.JRAbstractExporter
JRAbstractExporter.BaseExporterContext, JRAbstractExporter.PageRange
-
-
Field Summary
-
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter
allSelector, crtCompositeConfiguration, crtCompositeItemConfiguration, crtItem, dateFormatCache, EXCEPTION_MESSAGE_KEY_END_PAGE_INDEX_OUT_OF_RANGE, EXCEPTION_MESSAGE_KEY_INVALID_IMAGE_NAME, EXCEPTION_MESSAGE_KEY_INVALID_ZOOM_RATIO, EXCEPTION_MESSAGE_KEY_MIXED_CALLS_NOT_ALLOWED, 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, parameters, propertiesUtil, PROPERTY_DEFAULT_FILTER_FACTORY, PROPERTY_SUFFIX_DEFAULT_FILTER_FACTORY, rendererUtil, styledTextUtil, textValueClasses
-
-
Constructor Summary
Constructors Constructor Description JRDocxExporter()JRDocxExporter(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidendHyperlink(boolean isText)protected voidensureInput()protected voidensureOutput()protected 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)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)voidexportReport()Performs the export.protected voidexportReportToStream(OutputStream os)protected voidexportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified)voidexportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell)protected Class<DocxExporterConfiguration>getConfigurationInterface()protected JRPrintElementIndexgetElementIndex(JRExporterGridCell gridCell)StringgetExporterKey()StringgetExporterPropertiesPrefix()Returns the properties prefix for the current exporter.protected StringgetHyperlinkTarget(JRPrintHyperlink link)protected StringgetHyperlinkURL(JRPrintHyperlink link)protected Class<DocxReportConfiguration>getItemConfigurationInterface()static JRPrintElementIndexgetPrintElementIndex(String imageName)protected JRStyledTextgetStyledText(JRPrintText textElement, boolean setBackcolor)protected voidinitExport()protected voidinitReport()protected voidinsertBookmark(String bookmark, BaseHelper helper)protected voidrestoreBackcolor()protected voidsetBackcolor(Color color)protected booleanstartHyperlink(JRPrintHyperlink link, boolean isText)-
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter
checkInterrupted, createFilter, defaultParseNumber, ensureJasperReportsContext, getBooleanCellValue, getCurrentConfiguration, getCurrentItemConfiguration, getCurrentJasperPrint, getDateCellValue, getDateFormat, getExporterContext, getExporterInput, getExporterOutput, getHyperlinkProducer, getJasperReportsContext, getLocale, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getPageRange, getParameter, getParameters, getPropertiesUtil, getRendererUtil, getReportContext, getRepository, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, insideFrame, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setConfiguration, setConfiguration, setCurrentExporterInputItem, setExporterInput, setExporterOutput, setFrameElementsOffset, setJasperReportsContext, setOffset, setOffset, setParameter, setParameters, setReportContext
-
-
-
-
Field Detail
-
DOCX_EXPORTER_KEY
public static final String DOCX_EXPORTER_KEY
The exporter key, as used inGenericElementHandlerEnviroment.getElementHandler(JRGenericElementType, String).- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_COLUMN_COUNT_OUT_OF_RANGE
public static final String EXCEPTION_MESSAGE_KEY_COLUMN_COUNT_OUT_OF_RANGE
- See Also:
- Constant Field Values
-
DOCX_EXPORTER_PROPERTIES_PREFIX
public static final String DOCX_EXPORTER_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
PROPERTY_HIDDEN_TEXT
public static final String PROPERTY_HIDDEN_TEXT
This property is used to mark text elements as being hidden either for printing or on-screen display.- See Also:
JRPropertiesUtil, Constant Field Values
-
JR_PAGE_ANCHOR_PREFIX
public static final String JR_PAGE_ANCHOR_PREFIX
- See Also:
- Constant Field Values
-
IMAGE_NAME_PREFIX
public static final String IMAGE_NAME_PREFIX
- See Also:
- Constant Field Values
-
IMAGE_NAME_PREFIX_LEGTH
protected static final int IMAGE_NAME_PREFIX_LEGTH
-
IMAGE_LINK_PREFIX
public static final String IMAGE_LINK_PREFIX
- See Also:
- Constant Field Values
-
docxZip
protected DocxZip docxZip
-
docHelper
protected DocxDocumentHelper docHelper
-
docWriter
protected Writer docWriter
-
rendererToImagePathMap
protected Map<String,Pair<String,ExifOrientationEnum>> rendererToImagePathMap
-
renderersCache
protected RenderersCache renderersCache
-
reportIndex
protected int reportIndex
-
pageIndex
protected int pageIndex
-
startPageIndex
protected int startPageIndex
-
endPageIndex
protected int endPageIndex
-
tableIndex
protected int tableIndex
-
startPage
protected boolean startPage
-
invalidCharReplacement
protected String invalidCharReplacement
-
pageFormat
protected PrintPageFormat pageFormat
-
pageGridLayout
protected JRGridLayout pageGridLayout
-
backcolorStack
protected LinkedList<Color> backcolorStack
-
backcolor
protected Color backcolor
-
runHelper
protected DocxRunHelper runHelper
-
nature
protected ExporterNature nature
-
bookmarkIndex
protected long bookmarkIndex
-
pageAnchor
protected String pageAnchor
-
relsHelper
protected DocxRelsHelper relsHelper
-
appHelper
protected PropsAppHelper appHelper
-
coreHelper
protected PropsCoreHelper coreHelper
-
docxFontHelper
protected DocxFontHelper docxFontHelper
-
docxFontTableHelper
protected DocxFontTableHelper docxFontTableHelper
-
docxFontTableRelsHelper
protected DocxFontTableRelsHelper docxFontTableRelsHelper
-
-
Constructor Detail
-
JRDocxExporter
public JRDocxExporter()
- See Also:
JRDocxExporter(JasperReportsContext)
-
JRDocxExporter
public JRDocxExporter(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
getConfigurationInterface
protected Class<DocxExporterConfiguration> getConfigurationInterface()
-
getItemConfigurationInterface
protected Class<DocxReportConfiguration> getItemConfigurationInterface()
-
ensureOutput
protected void ensureOutput()
- Specified by:
ensureOutputin classJRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput,JRDocxExporterContext>
-
exportReport
public void exportReport() throws JRExceptionDescription 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
protected void exportReportToStream(OutputStream os) throws JRException, IOException
- Throws:
JRExceptionIOException
-
exportPage
protected void exportPage(JRPrintPage page) throws JRException
- 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
public void exportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell)
-
exportStyledText
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified)
-
exportImage
public void exportImage(DocxTableHelper tableHelper, JRPrintImage image, JRExporterGridCell gridCell) throws JRException
- Throws:
JRException
-
getElementIndex
protected JRPrintElementIndex getElementIndex(JRExporterGridCell gridCell)
-
getPrintElementIndex
public static JRPrintElementIndex getPrintElementIndex(String imageName)
-
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
protected void setBackcolor(Color color)
-
restoreBackcolor
protected void restoreBackcolor()
-
startHyperlink
protected boolean startHyperlink(JRPrintHyperlink link, boolean isText)
-
getHyperlinkTarget
protected String getHyperlinkTarget(JRPrintHyperlink link)
-
getHyperlinkURL
protected String getHyperlinkURL(JRPrintHyperlink link)
-
endHyperlink
protected void endHyperlink(boolean isText)
-
insertBookmark
protected void insertBookmark(String bookmark, BaseHelper helper)
-
ensureInput
protected void ensureInput()
-
getStyledText
protected JRStyledText getStyledText(JRPrintText textElement, boolean setBackcolor)
-
getExporterKey
public String getExporterKey()
- Specified by:
getExporterKeyin classJRAbstractExporter<DocxReportConfiguration,DocxExporterConfiguration,OutputStreamExporterOutput,JRDocxExporterContext>
-
getExporterPropertiesPrefix
public String 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
-
-