public abstract class ExcelColumnRowBase extends Object implements com.gembox.spreadsheet.internal.ExcelEditor<com.gembox.spreadsheet.internal.ExcelColumnRowBaseData>, com.gembox.spreadsheet.internal.styles.CellFormatDataFormatHolder
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Determines whether the specified
Object is equal to this ExcelColumnRowBase instance. |
CellRange |
getCells()
Gets cell range with column / row cells.
|
long |
getExtentEmuVisible()
Gets the extent in EMU.
|
int |
getIndex()
Gets the row / column zero-based index which represents its position in a worksheet.
|
String |
getName()
Gets the name of
ExcelColumnRowBase instance. |
int |
getOutlineLevel()
Gets outline level.
|
CellStyle |
getStyle()
Gets the cell formatting of cells in this column / row.
|
int |
hashCode()
Returns a hash code for this
ExcelColumnRowBase instance. |
boolean |
isCollapsed()
Gets whether object is collapsed in outlining.
|
boolean |
isHidden()
Gets whether excel object is hidden.
|
void |
setCollapsed(boolean value)
Sets whether object is collapsed in outlining.
|
void |
setHidden(boolean value)
Sets whether excel object is hidden.
|
void |
setOutlineLevel(int value)
Sets outline level.
|
void |
setStyle(CellStyle style)
Sets the cell formatting of cells in this column / row.
|
String |
toString()
Returns a
String that represents this ExcelColumnRowBase instance. |
public boolean equals(Object obj)
Object
is equal to this ExcelColumnRowBase
instance.equals
in class Object
obj
- The Object
to compare with this ExcelColumnRowBase
instance.true
if the specified Object
is a ExcelColumnRowBase
and is equal to this ExcelColumnRowBase
instance; otherwise, false
.public final CellRange getCells()
Look at following code for cell referencing examples:
ExcelWorksheet ws = excelFile.getWorksheets().getActiveWorksheet();
ws.getCell("B2").setValue("Cell B2.");
ws.getCell(6, 0).setValue("Cell in row 7 and column A.");
ws.getRow(2).getCell(0).setValue("Cell in row 3 and column A.");
ws.getRow("4").getCell("B").setValue("Cell in row 4 and column B.");
ws.getColumn(2).getCell(4).setValue("Cell in column C and row 5.");
ws.getColumn("AA").getCell("6").setValue("Cell in AA column and row 6.");
ExcelRow.getAllocatedCells()
,
ExcelCell
public final long getExtentEmuVisible()
public final int getIndex()
public final String getName()
ExcelColumnRowBase
instance.
A row name includes row number. For example, the name of row 0 is "1". A column name includes column letter. For example, the name of column 0 is "A".
public final int getOutlineLevel()
setOutlineLevel(int)
public final CellStyle getStyle()
setStyle(CellStyle)
public int hashCode()
ExcelColumnRowBase
instance.hashCode
in class Object
ExcelColumnRowBase
instance.public final boolean isCollapsed()
setCollapsed(boolean)
public final boolean isHidden()
setHidden(boolean)
public final void setCollapsed(boolean value)
When you use outline grouping and you want outline group to be collapsed, you need to use three methods:
setOutlineLevel(int)
methods needs to be set to correct outline level.
If group is collapsed, for all rows in the collapsed group setHidden(boolean)
method
needs to be set to true
.
If group is collapsed, for the row where collapsed (plus) sign is located
this method needs to be set to true
.
public static void groupingAndOutline(ExcelWorksheet ws) {
ws.getCell(0, 0).setValue("Grouping and outline example:");
//Vertical grouping.
ws.getCell(2, 0).setValue("GroupA Start");
ws.getRow(2).setOutlineLevel(1);
ws.getCell(3, 0).setValue("A");
ws.getRow(3).setOutlineLevel(1);
ws.getCell(4, 1).setValue("GroupB Start");
ws.getRow(4).setOutlineLevel(2);
ws.getCell(5, 1).setValue("B");
ws.getRow(5).setOutlineLevel(2);
ws.getCell(6, 1).setValue("GroupB End");
ws.getRow(6).setOutlineLevel(2);
ws.getCell(7, 0).setValue("GroupA End");
ws.getRow(7).setOutlineLevel(1);
// Put outline row buttons above groups.
ws.getViewOptions().setOutlineRowButtonsBelow(false);
//Horizontal grouping (collapsed).
ws.getCell("E2").setValue("Gr.C Start");
ws.getColumns().get("E").setOutlineLevel(1);
ws.getColumns().get("E").setHidden(true);
ws.getCell("F2").setValue("C");
ws.getColumns().get("F").setOutlineLevel(1);
ws.getColumns().get("F").setHidden(true);
ws.getCell("G2").setValue("Gr.C End");
ws.getColumns().get("G").setOutlineLevel(1);
ws.getColumns().get("G").setHidden(true);
ws.getColumns().get("H").setCollapsed(true);
}
setOutlineLevel(int)
public final void setHidden(boolean value)
When you use outline grouping and you want outline group to be collapsed, you need to use three methods:
setOutlineLevel(int)
methods needs to be set to correct outline level.
If group is collapsed, for all rows in the collapsed group setHidden(boolean)
method
needs to be set to true
.
If group is collapsed, for the row where collapsed (plus) sign is located
setCollapsed(boolean)
method needs to be set to true
.
public final void setOutlineLevel(int value)
Exception is thrown if value is out of 0 to 7 range.
Using this property you can create hierarchical groups. Range of consecutive objects (rows or columns) with the same value of outline level belongs to the same group. Default value is zero, which prevents grouping.
When you use outline grouping and you want outline group to be collapsed, you need to use three methods:
this method needs to be set to correct outline level.
If group is collapsed, for all rows in the collapsed group setHidden(boolean)
method
needs to be set to true
.
If group is collapsed, for the row where collapsed (plus) sign is located
setCollapsed(boolean)
method needs to be set to true
.
public static void groupingAndOutline(ExcelWorksheet ws) {
ws.getCell(0, 0).setValue("Grouping and outline example:");
//Vertical grouping.
ws.getCell(2, 0).setValue("GroupA Start");
ws.getRow(2).setOutlineLevel(1);
ws.getCell(3, 0).setValue("A");
ws.getRow(3).setOutlineLevel(1);
ws.getCell(4, 1).setValue("GroupB Start");
ws.getRow(4).setOutlineLevel(2);
ws.getCell(5, 1).setValue("B");
ws.getRow(5).setOutlineLevel(2);
ws.getCell(6, 1).setValue("GroupB End");
ws.getRow(6).setOutlineLevel(2);
ws.getCell(7, 0).setValue("GroupA End");
ws.getRow(7).setOutlineLevel(1);
// Put outline row buttons above groups.
ws.getViewOptions().setOutlineRowButtonsBelow(false);
//Horizontal grouping (collapsed).
ws.getCell("E2").setValue("Gr.C Start");
ws.getColumns().get("E").setOutlineLevel(1);
ws.getColumns().get("E").setHidden(true);
ws.getCell("F2").setValue("C");
ws.getColumns().get("F").setOutlineLevel(1);
ws.getColumns().get("F").setHidden(true);
ws.getCell("G2").setValue("Gr.C End");
ws.getColumns().get("G").setOutlineLevel(1);
ws.getColumns().get("G").setHidden(true);
ws.getColumns().get("H").setCollapsed(true);
}
IndexOutOfBoundsException
- Value is out of 0 to 7 range.setCollapsed(boolean)
public final void setStyle(CellStyle style)
Conceptually, cell formatting is divided into following groups:
CellStyle.setNumberFormat(java.lang.String)
.
CellStyle.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
, CellStyle.setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
, CellStyle.setIndent(int)
, CellStyle.setRotation(int)
, CellStyle.setTextVertical(boolean)
, CellStyle.setWrapText(boolean)
and CellStyle.setShrinkToFit(boolean)
.
CellStyle.setFont(com.gembox.spreadsheet.ExcelFont)
.
CellStyle.setBorders(com.gembox.spreadsheet.CellBorders)
.
CellStyle.setFillPattern(com.gembox.spreadsheet.ExcelFillPattern)
.
CellStyle.setLocked(boolean)
and CellStyle.setFormulaHidden(boolean)
.
Additional CellStyle
methods not associated with any formatting group are:
CellStyle.getName()
- name of the referenced workbook style
.
CellStyle.setQuotePrefix(boolean)
- true
to store numeric value of a cell as text; otherwise, false
.
CellStyle.isDefault()
- true
if referenced
workbook style
is default (
CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting; otherwise, false
.
Workbook
contains a set of master styles
which can be referenced by multiple cells.
Workbook
must always contain at least one master style
which cannot be removed and is, by default, referenced by all cells. This default style is
CellStyleCollection.getNormal()
.
Workbook style
can either be built-in or user-defined. Built-in style is accessible from workbook styles
via BuiltInCellStyleName
enumeration.
Cell formatting group (Number, Alignment, Font, Border, Fill or Protection) (and its associated methods) is resolved from referenced
workbook (master) style
, unless cell formatting group or its associated method is modified.
Cell formatting is available for one or more cells through AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method which is available on ExcelCell
and CellRange
types.
Cell formatting specified on ExcelColumn
and ExcelRow
types through setStyle(com.gembox.spreadsheet.CellStyle)
method is simply propagated to cell formatting of its getCells()
.
For performance reasons, cell formatting on CellRange
is resolved based just on its top-left cell formatting, except borders which are resolved based on corner cells depending on border side.
Setting cell formatting method on CellRange
is propagated to each cell in a range.
To set workbook (master) style
to one or more cells, simply assign it to AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method.
Preferable way to modify formatting method of multiple cells is to get CellRange
to which all those cells belong, and use AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range to make the modification.
If modifying multiple formatting properties of a CellRange
, without preserving unmodified formatting properties, preferable way is to create new instance of CellStyle
, make modifications on it, and assign it using AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range.
GemBox.Spreadsheet internally takes care not to allocate unnecessary cells when formatting a range of cells (for example, when formatting all worksheet cells
) and to cache formatting information of equally formatted cells, at the appropriate time, to reduce memory footprint.
style
- The cell formatting of cells in this column / row.public String toString()
String
that represents this ExcelColumnRowBase
instance.
This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).
toString
in class Object
String
that represents this ExcelColumnRowBase
instance.© GemBox d.o.o. — All rights reserved.