|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.util.SheetUtil
public class SheetUtil
Helper methods for when working with Usermodel sheets
Constructor Summary | |
---|---|
SheetUtil()
|
Method Summary | |
---|---|
static boolean |
canComputeColumnWidth(Font font)
Check if the Fonts are installed correctly so that Java can compute the size of columns. |
static boolean |
containsCell(CellRangeAddress cr,
int rowIx,
int colIx)
Deprecated. 3.15 beta 2. Use CellRangeAddressBase.isInRange(int, int) . |
static Cell |
getCell(Sheet sheet,
int rowIx,
int colIx)
Return the cell, without taking account of merged regions. |
static double |
getCellWidth(Cell cell,
int defaultCharWidth,
DataFormatter formatter,
boolean useMergedCells)
Compute width of a single cell |
static Cell |
getCellWithMerges(Sheet sheet,
int rowIx,
int colIx)
Return the cell, taking account of merged regions. |
static double |
getColumnWidth(Sheet sheet,
int column,
boolean useMergedCells)
Compute width of a column and return the result |
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 |
static int |
getDefaultCharWidth(Workbook wb)
Get default character width using the Workbook's default font |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SheetUtil()
Method Detail |
---|
public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells)
cell
- the cell whose width is to be calculateddefaultCharWidth
- the width of a single characterformatter
- formatter used to prepare the text to be measureduseMergedCells
- whether to use merged cells
public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells)
sheet
- the sheet to calculatecolumn
- 0-based index of the columnuseMergedCells
- whether to use merged cells
public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells, int firstRow, int lastRow)
sheet
- the sheet to calculatecolumn
- 0-based index of the columnuseMergedCells
- whether to use merged cellsfirstRow
- 0-based index of the first row to consider (inclusive)lastRow
- 0-based index of the last row to consider (inclusive)
@Internal public static int getDefaultCharWidth(Workbook wb)
wb
- the workbook to get the default character width from
public static boolean canComputeColumnWidth(Font font)
font
- The Font that is used in the Cell
@Deprecated public static boolean containsCell(CellRangeAddress cr, int rowIx, int colIx)
CellRangeAddressBase.isInRange(int, int)
.
cr
- the cell range to check inrowIx
- the row to checkcolIx
- the column to check
public static Cell getCell(Sheet sheet, int rowIx, int colIx)
Use getCellWithMerges(Sheet, int, int)
if you want the top left
cell from merged regions instead when the reference is a merged cell.
Use this where you want to know if the given cell is explicitly defined or not.
sheet
- The workbook sheet to look at.rowIx
- The 0-based index of the row.colIx
- The 0-based index of the cell.
java.lang.NullPointerException
- if sheet is nullpublic static Cell getCellWithMerges(Sheet sheet, int rowIx, int colIx)
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.
sheet
- The workbook sheet to look at.rowIx
- The 0-based index of the row.colIx
- The 0-based index of the cell.
java.lang.NullPointerException
- if sheet is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |