Class XlsxFormatter

java.lang.Object
io.jmix.reports.yarg.formatters.impl.AbstractFormatter
io.jmix.reports.yarg.formatters.impl.XlsxFormatter
All Implemented Interfaces:
ReportFormatter
Direct Known Subclasses:
JmixXlsxFormatter

public class XlsxFormatter extends AbstractFormatter
  • Field Details

    • documentConverter

      protected DocumentConverter documentConverter
    • template

      protected Document template
    • result

      protected Document result
    • rangeDependencies

      protected RangeDependencies rangeDependencies
    • bandsForRanges

      protected BandsForRanges bandsForRanges
    • rangeVerticalIntersections

      protected com.google.common.collect.LinkedHashMultimap<Range,Range> rangeVerticalIntersections
    • innerFormulas

      protected Set<XlsxFormatter.CellWithBand> innerFormulas
    • outerFormulas

      protected Set<XlsxFormatter.CellWithBand> outerFormulas
    • templateImages

      protected Map<String,List<XlsxImage>> templateImages
    • outerMergeRegions

      protected RangeDependencies outerMergeRegions
      Template merged regions that stick out of the band they are copied with, mapped to their copies in the result.
    • lastRenderedRangeForBandName

      protected Map<String,Range> lastRenderedRangeForBandName
    • lastRowForSheet

      protected Map<org.xlsx4j.sml.Worksheet,Long> lastRowForSheet
    • hintProcessor

      protected XslxHintProcessor hintProcessor
    • previousRangeBandData

      protected BandData previousRangeBandData
    • previousRangesRightOffset

      protected int previousRangesRightOffset
    • formulasPostProcessingEvaluationEnabled

      protected boolean formulasPostProcessingEvaluationEnabled
    • unmarshaller

      protected jakarta.xml.bind.Unmarshaller unmarshaller
    • marshaller

      protected jakarta.xml.bind.Marshaller marshaller
  • Constructor Details

  • Method Details

    • setDocumentConverter

      public void setDocumentConverter(DocumentConverter documentConverter)
    • setFormulasPostProcessingEvaluationEnabled

      public void setFormulasPostProcessingEvaluationEnabled(boolean formulasPostProcessingEvaluationEnabled)
    • renderDocument

      public void renderDocument()
      Description copied from interface: ReportFormatter
      Creates document and serializes it to predefined stream (or something like this)
    • validateTemplateContainsNamedRange

      protected void validateTemplateContainsNamedRange()
    • saveAndClose

      protected void saveAndClose()
    • isFormulasPostProcessingEvaluationRequired

      protected boolean isFormulasPostProcessingEvaluationRequired()
    • evaluateFormulas

      protected ByteArrayOutputStream evaluateFormulas(byte[] content)
    • isCellInBand

      protected boolean isCellInBand(String sheetName, int row, int col)
    • extractTemplateImages

      public byte[] extractTemplateImages(ReportTemplate reportTemplate)
    • init

      protected void init()
    • findVerticalDependencies

      protected void findVerticalDependencies()
    • updateOutlines

      protected void updateOutlines()
    • updateCharts

      protected void updateCharts()
    • shiftChart

      protected void shiftChart(Document.ChartWrapper chart, Range templateRange, Range firstResultRange)
    • updateFormulas

      protected void updateFormulas()
    • updateConditionalFormatting

      protected void updateConditionalFormatting()
    • updatePrintAreas

      protected void updatePrintAreas()
      Re-bases each sheet's print area onto the rendered report, so that printing the report covers everything rendered for the template print area, see XlsxUtils.rebasePrintArea(io.jmix.reports.yarg.formatters.impl.xlsx.Range, io.jmix.reports.yarg.formatters.impl.xlsx.RangeDependencies, io.jmix.reports.yarg.formatters.impl.xlsx.RangeDependencies, org.apache.poi.ss.SpreadsheetVersion), and refers it to the sheet as it is renamed from band data.
    • getPrintAreaSheet

      protected String getPrintAreaSheet(org.xlsx4j.sml.CTDefinedName printAreaName, String templateSheet)
      Returns the name of the sheet the print area belongs to as it is written in a formula: the sheet may have been renamed from band data, see updateSheetNames(), while the print area and the band ranges keep the name of the template sheet.
    • getRenderedBandBlocks

      protected RangeDependencies getRenderedBandBlocks()
    • getRenderedObjects

      protected RangeDependencies getRenderedObjects(Range printArea)
      Returns the template ranges of the objects intersecting the template print area that keep their size, mapped to the ranges they are rendered to: the merged regions copied with the bands they stick out of, see outerMergeRegions, and the drawings. A chart is moved with the band it intersects, other drawings stay in place, except for the pictures copied into the band cells, which the band blocks cover.
    • getTemplateDrawingAnchors

      protected List<Object> getTemplateDrawingAnchors(String sheetName)
      Returns the anchors of the drawing objects on the template sheet.
    • getTemplateImageKey

      protected String getTemplateImageKey(String sheetName, String cellReference)
      Returns the key of the pictures anchored in the template cell in templateImages.
    • processOuterFormulas

      protected void processOuterFormulas()
    • calculateFormulaRangeChange

      protected Range calculateFormulaRangeChange(Range formulaRange, Range templateRange, List<Range> resultRanges)
    • processInnerFormulas

      protected void processInnerFormulas()
    • updateFormula

      protected void updateFormula(org.xlsx4j.sml.Cell cellWithFormula, Range originalFormulaRange, Range formulaRange)
    • calculateOffset

      protected XlsxFormatter.Offset calculateOffset(Range from, Range to)
    • updatePivotTables

      protected void updatePivotTables()
    • updateMergeRegions

      protected void updateMergeRegions()
    • writeBand

      protected void writeBand(BandData childBand)
    • writeHBand

      protected void writeHBand(BandData band)
    • writeVBand

      protected void writeVBand(BandData band)
    • updateRangeMappings

      protected void updateRangeMappings(BandData band, Range templateRange, List<org.xlsx4j.sml.Cell> resultCells)
    • findNextRowForHBand

      protected org.xlsx4j.sml.Row findNextRowForHBand(BandData band, Range templateRange, List<org.xlsx4j.sml.Row> resultSheetRows)
    • findNextRowForVBand

      protected org.xlsx4j.sml.Row findNextRowForVBand(BandData band, Range templateRange, List<org.xlsx4j.sml.Row> resultSheetRows)
    • findNextRowForChildBand

      protected org.xlsx4j.sml.Row findNextRowForChildBand(BandData band, Range templateRange, List<org.xlsx4j.sml.Row> resultSheetRows)
    • findNextRowForFirstRender

      protected org.xlsx4j.sml.Row findNextRowForFirstRender(Range templateRange, List<org.xlsx4j.sml.Row> resultSheetRows)
    • ensureNecessaryRowsCreated

      protected org.xlsx4j.sml.Row ensureNecessaryRowsCreated(Range templateRange, org.xlsx4j.sml.Worksheet resultSheet, org.xlsx4j.sml.Row firstRow)
    • copyCells

      protected List<org.xlsx4j.sml.Cell> copyCells(BandData band, Range templateRange, List<org.xlsx4j.sml.Row> resultSheetRows, org.xlsx4j.sml.Row firstRow, org.xlsx4j.sml.Worksheet resultSheet)
    • createFakeTemplateCellsForEmptyOnes

      protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference,org.xlsx4j.sml.Cell> cellsForOneRowRange, List<org.xlsx4j.sml.Cell> templateCells)
      XLSX document does not store empty cells and it might be an issue for formula calculations and etc. So we need to create fake template cell for each empty cell.
    • getLastRenderedBandForThisLevel

      protected Range getLastRenderedBandForThisLevel(BandData band)
    • getBandRange

      protected Range getBandRange(BandData band)
    • createNewRow

      protected org.xlsx4j.sml.Row createNewRow(org.xlsx4j.sml.Worksheet resultSheet)
    • copyCells

      protected List<org.xlsx4j.sml.Cell> copyCells(Range templateRange, BandData bandData, org.xlsx4j.sml.Row newRow, List<org.xlsx4j.sml.Cell> templateCells)
    • copyCell

      protected org.xlsx4j.sml.Cell copyCell(org.xlsx4j.sml.Cell cell)
    • getWorksheet

      protected org.xlsx4j.sml.Worksheet getWorksheet(org.xlsx4j.sml.Row newRow)
    • getTemplateWorksheet

      protected org.xlsx4j.sml.Worksheet getTemplateWorksheet(org.xlsx4j.sml.Row newRow)
    • addFormulaForPostProcessing

      protected void addFormulaForPostProcessing(Range templateRange, BandData bandData, org.xlsx4j.sml.Row newRow, org.xlsx4j.sml.Cell templateCell, org.xlsx4j.sml.Cell newCell)
    • copyRowSettings

      protected void copyRowSettings(org.xlsx4j.sml.Row templateRow, org.xlsx4j.sml.Row newRow, org.xlsx4j.sml.Worksheet templateWorksheet, org.xlsx4j.sml.Worksheet resultWorksheet)
    • updateCell

      protected void updateCell(org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart worksheetPart, BandData bandData, org.xlsx4j.sml.Cell newCell)
    • getExcelTime

      protected double getExcelTime(LocalTime time)
    • getFirst

      protected <T> T getFirst(List<T> list)
    • getLast

      protected <T> T getLast(List<T> list)
    • saveXlsxAsCsv

      protected void saveXlsxAsCsv(Document document, OutputStream outputStream) throws IOException, org.docx4j.openpackaging.exceptions.Docx4JException
      Throws:
      IOException
      org.docx4j.openpackaging.exceptions.Docx4JException
    • writeToOutputStream

      protected void writeToOutputStream(org.docx4j.openpackaging.packages.SpreadsheetMLPackage mlPackage, OutputStream outputStream) throws org.docx4j.openpackaging.exceptions.Docx4JException
      Throws:
      org.docx4j.openpackaging.exceptions.Docx4JException
    • updateHeaderAndFooter

      protected void updateHeaderAndFooter()
    • updateSheetNames

      protected void updateSheetNames()
    • insertBandDataToString

      protected String insertBandDataToString(String resultStr)