| Modifier and Type | Field and Description |
|---|---|
| public static final int | DEFAULT_CHAR_WIDTH
Which default char-width to use if the font-system is unavailable. |
| private static final char | defaultChar
Excel measures columns in units of 1/256th of a character width but the docs say nothing about what particular character is used. |
| private static final FormulaEvaluator | dummyEvaluator
Dummy formula evaluator that does nothing. |
| private static final double | fontHeightMultiple
This is the multiple that the font height is scaled by when determining the boundary of rotated text. |
| private static FontRenderContext | fontRenderContext
drawing context to measure text |
| private static boolean | ignoreMissingFontSystem
A system property which can be enabled to not fail when the font-system is not available on the current machine |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: true if computing the size for this Font will succeed, false otherwiseThe Font that is used in the Cell font)Check if the Fonts are installed correctly so that Java can compute the size of columns. |
| private static void | copyAttributes(Font font, AttributedString str, int startIdx, int endIdx)
Copy text attributes from the supplied Font to Java2D AttributedString |
| public static Cell | |
| public static double | Returns: the width in pixels or -1 if cell is emptythe cell whose width is to be calculated cell, int the width of a single character defaultCharWidth, DataFormatter formatter used to prepare the text to be measured formatter, boolean whether to use merged cells useMergedCells)
Deprecated
since POI 5.2.5, it is better to pass defaultCharWidth as a float
Compute width of a single cell |
| public static double | Returns: the width in pixels or -1 if cell is emptythe cell whose width is to be calculated cell, float the width of a single character defaultCharWidth, DataFormatter formatter used to prepare the text to be measured formatter, boolean whether to use merged cells useMergedCells)Compute width of a single cell |
| public static double | Returns: the width in pixels or -1 if cell is emptythe cell whose width is to be calculated cell, int the width of a single character defaultCharWidth, DataFormatter formatter used to prepare the text to be measured formatter, boolean whether to use merged cells useMergedCells, List<CellRangeAddress> The list of merged regions as received via cell.getSheet().getMergedRegions() mergedRegions)
Deprecated
since POI 5.2.5, it is better to pass defaultCharWidth as a float
Compute width of a single cell This method receives the list of merged regions as querying it from the cell/sheet is time-consuming and thus caching the list across cells speeds up certain operations considerably. |
| public static double | Returns: the width in pixels or -1 if cell is emptythe cell whose width is to be calculated cell, float the width of a single character defaultCharWidth, DataFormatter formatter used to prepare the text to be measured formatter, boolean whether to use merged cells useMergedCells, List<CellRangeAddress> The list of merged regions as received via cell.getSheet().getMergedRegions() mergedRegions)Compute width of a single cell This method receives the list of merged regions as querying it from the cell/sheet is time-consuming and thus caching the list across cells speeds up certain operations considerably. |
| private static double | Returns: the best fit cell widththe width of a character using the default font in a workbook defaultCharWidth, int the number of columns that is spanned by the cell (1 if the cell is not part of a merged region) colspan, CellStyle the cell style, which contains text rotation and indention information needed to compute the cell width style, double the minimum best-fit width. This algorithm will only return values greater than or equal to the minimum width. minWidth, AttributedString the text contained in the cell str)Calculate the best-fit width for a cell If a merged cell spans multiple columns, evenly distribute the column width among those columns |
| public static Cell | Returns: cell at the given location, its base merged cell, or null if not definedThe workbook sheet to look at. sheet, int The 0-based index of the row. rowIx, int The 0-based index of the cell. colIx)Return the cell, taking account of merged regions. |
| public static double | Returns: the width in pixels or -1 if all cells are emptythe sheet to calculate sheet, int 0-based index of the column column, boolean whether to use merged cells useMergedCells)Compute width of a column and return the result. |
| public static double | Returns: the width in pixels or -1 if cell is emptythe sheet to calculate sheet, int 0-based index of the column column, boolean whether to use merged cells useMergedCells, int 0-based index of the first row to consider (inclusive) firstRow, int 0-based index of the last row to consider (inclusive) lastRow)Compute width of a column based on a subset of the rows and return the result. |
| private static double | Returns: the width in pixels or -1 if cell is emptythe row that contains the cell of interest row, int the column number of the cell whose width is to be calculated column, float the width of a single character defaultCharWidth, DataFormatter formatter used to prepare the text to be measured formatter, boolean whether to use merged cells useMergedCells, List<CellRangeAddress> mergedRegions)Compute width of a single cell in a row
Convenience method for |
| public static int | Returns: default character width in pixelsthe workbook to get the default character width from wb)
Deprecated
since POI 5.2.5, it is recommended to switch to
getDefaultCharWidthAsFloat(Workbook).
Get default character width using the Workbook's default font. |
| public static float | Returns: default character width in pixels (as a float)the workbook to get the default character width from wb)Get default character width using the Workbook's default font. |
| protected static FontRenderContext | |
| protected static boolean | |
| protected static void | |
| protected static void |
| DEFAULT_CHAR_WIDTH | back to summary |
|---|---|
| public static final int DEFAULT_CHAR_WIDTH Which default char-width to use if the font-system is unavailable. | |
| defaultChar | back to summary |
|---|---|
| private static final char defaultChar Excel measures columns in units of 1/256th of a character width but the docs say nothing about what particular character is used. '0' looks to be a good choice. | |
| dummyEvaluator | back to summary |
|---|---|
| private static final FormulaEvaluator dummyEvaluator Dummy formula evaluator that does nothing.
YK: The only reason of having this class is that
| |
| fontHeightMultiple | back to summary |
|---|---|
| private static final double fontHeightMultiple This is the multiple that the font height is scaled by when determining the boundary of rotated text. | |
| fontRenderContext | back to summary |
|---|---|
| private static FontRenderContext fontRenderContext drawing context to measure text | |
| ignoreMissingFontSystem | back to summary |
|---|---|
| private static boolean ignoreMissingFontSystem A system property which can be enabled to not fail when the font-system is not available on the current machine | |
| SheetUtil | back to summary |
|---|---|
| public SheetUtil() | |
| canComputeColumnWidth | back to summary |
|---|---|
| public static boolean canComputeColumnWidth(Font font) Check if the Fonts are installed correctly so that Java can compute the size of columns. If a Cell uses a Font which is not available on the operating system then Java may fail to return useful Font metrics and thus lead to an auto-computed size of 0. This method allows to check if computing the sizes for a given Font will succeed or not.
| |
| copyAttributes | back to summary |
|---|---|
| private static void copyAttributes(Font font, AttributedString str, int startIdx, int endIdx) Copy text attributes from the supplied Font to Java2D AttributedString | |
| getCell | back to summary |
|---|---|
| public static Cell getCell(Sheet sheet, int rowIx, int colIx) Return the cell, without taking account of merged regions.
Use Use this where you want to know if the given cell is explicitly defined or not.
| |
| getCellWidth | back to summary |
|---|---|
| public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells)
Deprecated since POI 5.2.5, it is better to pass defaultCharWidth as a float Compute width of a single cell
| |
| getCellWidth | back to summary |
|---|---|
| public static double getCellWidth(Cell cell, float defaultCharWidth, DataFormatter formatter, boolean useMergedCells) Compute width of a single cell
| |
| getCellWidth | back to summary |
|---|---|
| public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells, List<CellRangeAddress> mergedRegions)
Deprecated since POI 5.2.5, it is better to pass defaultCharWidth as a float Compute width of a single cell This method receives the list of merged regions as querying it from the cell/sheet is time-consuming and thus caching the list across cells speeds up certain operations considerably.
| |
| getCellWidth | back to summary |
|---|---|
| public static double getCellWidth(Cell cell, float defaultCharWidth, DataFormatter formatter, boolean useMergedCells, List<CellRangeAddress> mergedRegions) Compute width of a single cell This method receives the list of merged regions as querying it from the cell/sheet is time-consuming and thus caching the list across cells speeds up certain operations considerably.
| |
| getCellWidth | back to summary |
|---|---|
| private static double getCellWidth(float defaultCharWidth, int colspan, CellStyle style, double minWidth, AttributedString str) Calculate the best-fit width for a cell If a merged cell spans multiple columns, evenly distribute the column width among those columns
| |
| getCellWithMerges | back to summary |
|---|---|
| public static Cell getCellWithMerges(Sheet sheet, int rowIx, int colIx) Return the cell, taking account of merged regions. Allows you to find the cell who's contents are shown in a given position in the sheet. If the cell at the given co-ordinates is a merged cell, this will return the primary (top-left) most cell of the merged region. If the cell at the given co-ordinates is not in a merged region, then will return the cell itself. If there is no cell defined at the given co-ordinates, will return null.
| |
| getColumnWidth | back to summary |
|---|---|
| public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells) Compute width of a column and return the result. Note that this fall can fail if you do not have the right fonts installed in your OS.
| |
| getColumnWidth | back to summary |
|---|---|
| public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells, int firstRow, int lastRow) Compute width of a column based on a subset of the rows and return the result. Note that this fall can fail if you do not have the right fonts installed in your OS.
| |
| getColumnWidthForRow | back to summary |
|---|---|
| private static double getColumnWidthForRow(Row row, int column, float defaultCharWidth, DataFormatter formatter, boolean useMergedCells, List<CellRangeAddress> mergedRegions) Compute width of a single cell in a row
Convenience method for
| |
| getDefaultCharWidth | back to summary |
|---|---|
| public static int getDefaultCharWidth(final Workbook wb)
Deprecated since POI 5.2.5, it is recommended to switch to Get default character width using the Workbook's default font. Note that this can fail if your OS does not have the right fonts installed. | |
| getDefaultCharWidthAsFloat | back to summary |
|---|---|
| public static float getDefaultCharWidthAsFloat(final Workbook wb) Get default character width using the Workbook's default font. Note that this can fail if your OS does not have the right fonts installed. | |
| getFontRenderContext | back to summary |
|---|---|
| protected static FontRenderContext getFontRenderContext() | |
| isIgnoreMissingFontSystem | back to summary |
|---|---|
| protected static boolean isIgnoreMissingFontSystem() | |
| setFontRenderContext | back to summary |
|---|---|
| protected static void setFontRenderContext(FontRenderContext fontRenderContext) | |
| setIgnoreMissingFontSystem | back to summary |
|---|---|
| protected static void setIgnoreMissingFontSystem(boolean value) | |