java.lang.Object
io.jmix.reports.yarg.formatters.impl.xlsx.XlsxUtils

public final class XlsxUtils extends Object
  • Method Details

    • getNumberFromColumnReference

      public static int getNumberFromColumnReference(String columnReference)
    • getColumnReferenceFromNumber

      public static String getColumnReferenceFromNumber(int number)
    • convertPxToEmu

      public static long convertPxToEmu(long px)
    • computeColumnIndex

      public static Integer computeColumnIndex(String cellName)
    • createPicture

      public static org.docx4j.dml.spreadsheetdrawing.CTPicture createPicture(String imageRelID)
    • attachImageToCell

      public static org.docx4j.openpackaging.parts.relationships.RelationshipsPart attachImageToCell(org.docx4j.openpackaging.parts.DrawingML.Drawing drawing, Integer col, Integer row, XlsxImage image, String imageRelID)
    • getOrCreateWorksheetDrawing

      public static org.docx4j.openpackaging.parts.DrawingML.Drawing getOrCreateWorksheetDrawing(org.docx4j.openpackaging.packages.SpreadsheetMLPackage pkg, org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart worksheetPart)
    • addCTDrawing

      public static org.docx4j.openpackaging.parts.DrawingML.Drawing addCTDrawing(org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart worksheetPart, org.docx4j.openpackaging.parts.PartName drawingPart) throws org.docx4j.openpackaging.exceptions.Docx4JException
      Throws:
      org.docx4j.openpackaging.exceptions.Docx4JException
    • deleteCTAnchor

      public static void deleteCTAnchor(org.apache.poi.xssf.usermodel.XSSFPicture xssfPicture)
    • parsePrintArea

      public static @Nullable Range parsePrintArea(@Nullable String formula, org.apache.poi.ss.SpreadsheetVersion version)
      Parses a print area that is one area of cell references: a rectangle, a cell, whole rows or whole columns, e.g. 'My sheet'!$A$1:$F$20, Sheet1!$1:$20 or Sheet1!$A:$F. Whole rows span all the columns and whole columns all the rows of the spreadsheet version. The sheet name is kept the way Range.fromFormula(String) keeps it: without the enclosing quotes, with the doubled ones inside; it is null if the formula names no sheet. Returns null for other print areas, e.g. several areas or a formula.
    • parsePrintAreas

      public static @Nullable List<Range> parsePrintAreas(@Nullable String formula, org.apache.poi.ss.SpreadsheetVersion version)
      Parses a print area of one or more areas of cell references separated with commas, see parsePrintArea(String, SpreadsheetVersion). Returns null if any of them cannot be parsed, e.g. for a formula.
    • spansAllRows

      public static boolean spansAllRows(Range range, org.apache.poi.ss.SpreadsheetVersion version)
      Returns whether the range spans all the rows of the spreadsheet version, i.e. consists of whole columns.
    • spansAllColumns

      public static boolean spansAllColumns(Range range, org.apache.poi.ss.SpreadsheetVersion version)
      Returns whether the range spans all the columns of the spreadsheet version, i.e. consists of whole rows.
    • toCellRangeAddress

      public static org.apache.poi.ss.util.CellRangeAddress toCellRangeAddress(Range printArea, org.apache.poi.ss.SpreadsheetVersion version)
      Converts a print area to a cell range address, e.g. to format it with CellRangeAddress.formatAsString(String, boolean). An area spanning all the columns of the spreadsheet version becomes whole rows, e.g. $1:$20, which also suit applications with fewer columns; an area spanning all the rows becomes whole columns, e.g. $A:$F.
    • formatPrintArea

      public static String formatPrintArea(Range printArea, org.apache.poi.ss.SpreadsheetVersion version)
      Formats a print area as a defined name formula, e.g. 'My sheet'!$A$1:$F$20, see toCellRangeAddress(Range, SpreadsheetVersion) for whole rows and whole columns. The sheet name is expected the way parsePrintArea(String, SpreadsheetVersion) returns it.
    • getAnchorRange

      public static @Nullable Range getAnchorRange(String sheetName, Object anchor)
      Returns the cells a drawing object is anchored in: only the anchor cell for an object sized in EMUs, or null for an object that is not anchored in cells.
    • getRenderedBandBlocks

      public static RangeDependencies getRenderedBandBlocks(BandData rootBand, Function<BandData,@Nullable Range> renderedRange, Function<BandData,Range> templateRange)
      Returns the template range of each rendered band mapped to the range covering the blocks of all its instances. The block of a band instance covers the range it is rendered to and the blocks of its nested bands rendered on the same sheet.
      Parameters:
      rootBand - root band of the report
      renderedRange - the range a band instance is rendered to, or null if it is not rendered
      templateRange - the template range of a band, requested with one of its rendered instances
    • rebasePrintArea

      public static @Nullable Range rebasePrintArea(Range printArea, RangeDependencies bandBlocks, RangeDependencies objects, org.apache.poi.ss.SpreadsheetVersion version)
      Re-bases a template print area onto the rendered report.

      The rows cover everything rendered by the bands that intersect the area, and the objects that intersect it as far as they lie inside it: an object keeps its size, so the part inside the area is covered wherever the object is rendered, from the first row of the sheet on.

      The columns cover the columns the content of the area is rendered to: the parts of those bands and objects inside the area, a band with the columns it grows by, e.g. as a vertical band. The area keeps the blank columns it has around its content, unless another band is rendered there. An area spanning all the columns keeps them.

      Parameters:
      printArea - print area of the template
      bandBlocks - template ranges of the bands mapped to the ranges their instances are rendered to, the rows of their nested bands included
      objects - template ranges of the objects that keep their size, e.g. merged regions and pictures, mapped to the ranges they are rendered to
      version - spreadsheet version that limits the number of rows and columns
      Returns:
      the print area of the report, or null to leave the print area as it is: it spans whole columns, which cover every rendered row anyway, or nothing intersecting it is rendered