public final class ExcelColumn extends ExcelColumnRowBase
Note that the cells are internally allocated in rows and not in columns. ExcelColumn objects are created only if they have non-standard width or style, or they are accessed directly. So, while ExcelRowCollection.Count shows number of rows occupied with data, ExcelColumnCollection.Count does not say which Column is the last one occupied with data!
If you want to read all data in a sheet, use
ExcelRow.getAllocatedCells()
method.
If you want to find last column occupied with data, use
ExcelWorksheet.calculateMaxUsedColumns()
method.
for (ExcelColumn column : ws.getColumns()) {
// Writes hidden columns
if (column.isHidden())
System.out.println("Column '" + ExcelColumnCollection.columnIndexToName(column.getIndex()) + "' is hidden");
}
// Counts used columns (columns that contain some data)
System.out.println("Number of used columns is: " + ws.calculateMaxUsedColumns());
Modifier and Type | Method and Description |
---|---|
ExcelCell |
getCell(int contextIndex)
Gets excel cell at the specified index from this column.
|
ExcelCell |
getCell(String contextName)
Gets excel cell with the specified partial name from this column.
|
int |
getWidth()
Gets column width.
|
double |
getWidth(LengthUnit lengthUnit)
Gets the width of column in arbitrary length unit.
|
void |
setWidth(double value,
LengthUnit lengthUnit)
Sets the width of column in arbitrary length unit.
|
void |
setWidth(int value)
Sets column width.
|
equals, getCells, getExtentEmuVisible, getIndex, getName, getOutlineLevel, getStyle, hashCode, isCollapsed, isHidden, setCollapsed, setHidden, setOutlineLevel, setStyle, toString
public final ExcelCell getCell(int contextIndex)
This method has the same effect as using column.
getCells()
.get(contextIndex)
contextIndex
- The zero-based context index of the cell.CellRange.get(int)
public final ExcelCell getCell(String contextName)
This method has the same effect as using column.
getCells()
.get(contextName)
RangeIndexingMode.Vertical
row name
must be used (for example; "1", "7", etc.).
contextName
- Partial name of the cell.CellRange.get(String)
public int getWidth()
Unit is 1/256th of the width of the zero character in default font.
ExcelWorksheet.getDefaultColumnWidth()
public double getWidth(LengthUnit lengthUnit)
lengthUnit
- The length unit in which to return column width.public void setWidth(double value, LengthUnit lengthUnit)
value
- Column width value.lengthUnit
- The length unit in which value
is specified.public void setWidth(int value)
Unit is 1/256th of the width of the zero character in default font.
ExcelWorksheet.getDefaultColumnWidth()
© GemBox Ltd. — All rights reserved.