public class CellStyle extends Object
Conceptually, cell formatting is divided into following groups:
setNumberFormat(java.lang.String)
.
setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
, setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
, setIndent(int)
, setRotation(int)
, setTextVertical(boolean)
, setWrapText(boolean)
and setShrinkToFit(boolean)
.
setFont(com.gembox.spreadsheet.ExcelFont)
.
setBorders(com.gembox.spreadsheet.CellBorders)
.
setFillPattern(com.gembox.spreadsheet.ExcelFillPattern)
.
setLocked(boolean)
and setFormulaHidden(boolean)
.
Additional CellStyle
methods not associated with any formatting group are:
getName()
- name of the referenced workbook style
.
setQuotePrefix(boolean)
- true
to store numeric value of a cell as text; otherwise, false
.
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 ExcelColumnRowBase.setStyle(com.gembox.spreadsheet.CellStyle)
method is simply propagated to cell formatting of its ExcelColumnRowBase.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.
// Set 'Good' style to all cells of the first sheet.
workbook.getWorksheet(0).getCells().setStyle(workbook.getStyle(BuiltInCellStyleName.GOOD));
Following code demonstrates when not to and when to initialize a new instance of the CellStyle class:
// To modify a single formatting property on a range of cells, simply modify it.
// Other formatting properties will remain unchanged.
sheet.getCells().getStyle().getFont().setItalic(true);
// To modify multiple formatting properties on a range of cells, create new CellStyle instance, modify it, and assign it to a range of cells.
// All formatting properties are changed.
CellStyle style = new CellStyle(sheet.getParent());
style.setNumberFormat("#,##0.00");
style.setHorizontalAlignment(HorizontalAlignmentStyle.CENTER);
style.setLocked(false);
sheet.getCells().setStyle(style);
Following code demonstrates cell formatting:
// 'Number' formatting group
sheet.getCell("B3").setValue("NumberFormat");
sheet.getCell("C3").setValue(1234);
sheet.getCell("C3").getStyle().setNumberFormat("#.##0,00 [$Krakozhian Money Units]");
// 'Alignment' formatting group
sheet.getCell("B5").setValue("HorizontalAlignment = ");
sheet.getCell("C5").setValue("HorizontalAlignmentStyle.Center");
sheet.getCell("C5").getStyle().setHorizontalAlignment(HorizontalAlignmentStyle.CENTER);
sheet.getCell("B6").setValue("VerticalAlignment = ");
sheet.getCell("C6").setValue("VerticalAlignmentStyle.Top");
sheet.getCell("C6").getStyle().setVerticalAlignment(VerticalAlignmentStyle.TOP);
// Set row height to 30 points.
sheet.getRow("6").setHeight(30 * 20);
sheet.getCell("B7").setValue("Indent");
sheet.getCell("C7").setValue("five");
sheet.getCell("C7").getStyle().setIndent(5);
sheet.getCell("C7").getStyle().setHorizontalAlignment(HorizontalAlignmentStyle.LEFT);
sheet.getCell("B8").setValue("Rotation");
sheet.getCell("C8").setValue("35 degrees up");
sheet.getCell("C8").getStyle().setRotation(35);
sheet.getCell("B9").setValue("IsTextVertical = ");
sheet.getCell("C9").setValue("true");
sheet.getCell("C9").getStyle().setTextVertical(true);
sheet.getCell("B10").setValue("WrapText");
sheet.getCell("C10").setValue("This property is set to true so this text appears broken into multiple lines.");
sheet.getCell("C10").getStyle().setWrapText(true);
sheet.getCell("B11").setValue("ShrinkToFit");
sheet.getCell("C11").setValue("This property is set to true so this text appears shrunk.");
sheet.getCell("C11").getStyle().setShrinkToFit(true);
// 'Font' formatting group
sheet.getCell("B13").setValue("Font.Name = ");
sheet.getCell("C13").setValue("Comic Sans MS");
sheet.getCell("C13").getStyle().getFont().setName("Comic Sans MS");
sheet.getCell("B14").setValue("Font.Italic = ");
sheet.getCell("C14").setValue("true");
sheet.getCell("C14").getStyle().getFont().setItalic(true);
sheet.getCell("B15").setValue("Font.Weight = ");
sheet.getCell("C15").setValue("ExcelFont.BoldWeight");
sheet.getCell("C15").getStyle().getFont().setWeight(ExcelFont.BOLD_WEIGHT);
sheet.getCell("B16").setValue("Font.Size = ");
sheet.getCell("C16").setValue("18 * 20");
sheet.getCell("C16").getStyle().getFont().setSize(18 * 20);
sheet.getCell("B17").setValue("Font.Color");
sheet.getCell("C17").setValue("Text2");
sheet.getCell("C17").getStyle().getFont().setColor(SpreadsheetColor.fromName(ColorName.TEXT_2));
sheet.getCell("B18").setValue("Font.UnderlineStyle = ");
sheet.getCell("C18").setValue("UnderlineStyle.Double");
sheet.getCell("C18").getStyle().getFont().setUnderlineStyle(UnderlineStyle.DOUBLE);
sheet.getCell("B19").setValue("Font.Strikeout = ");
sheet.getCell("C19").setValue("true");
sheet.getCell("C19").getStyle().getFont().setStrikeout(true);
sheet.getCell("B20").setValue("Font.ScriptPosition = ");
sheet.getCell("C20").setValue("ScriptPosition.Superscript");
sheet.getCell("C20").getStyle().getFont().setScriptPosition(ScriptPosition.SUBSCRIPT);
// 'Border' formatting group
sheet.getCell("B22").setValue("Borders.setBorders(...)");
sheet.getCell("C22").getStyle().getBorders().setBorders(MultipleBorders.all(), SpreadsheetColor.fromName(ColorName.ACCENT_2), LineStyle.THIN);
// 'Fill' formatting group
sheet.getCell("B24").setValue("FillPattern.setPattern(...)");
sheet.getCell("C24").getStyle().getFillPattern().setPattern(FillPatternStyle.THIN_HORIZONTAL_CROSSHATCH, SpreadsheetColor.fromName(ColorName.GREEN), SpreadsheetColor.fromName(ColorName.YELLOW));
sheet.getCell("B25").setValue("FillPattern.setGradient(...)");
sheet.getCell("C25").getStyle().getFillPattern().setGradient(GradientShadingStyle.HORIZONTAL_HIGH, SpreadsheetColor.fromName(ColorName.GREEN), SpreadsheetColor.fromName(ColorName.YELLOW));
// 'Protection' formatting group
sheet.getCell("B27").setValue("Locked = ");
sheet.getCell("C27").setValue("false");
sheet.getCell("C27").getStyle().setLocked(false);
sheet.getCell("B28").setValue("FormulaHidden = ");
sheet.getCell("C28").setValue("true");
sheet.getCell("C28").getStyle().setFormulaHidden(true);
Constructor and Description |
---|
CellStyle()
Initializes a new instance of the
CellStyle class not associated with any workbook. |
CellStyle(ExcelFile workbook)
Initializes a new instance of the
CellStyle class which references default (CellStyleCollection.getNormal() ) style from the specified workbook. |
Modifier and Type | Method and Description |
---|---|
CellBorders |
getBorders()
Gets the borders.
|
ExcelFillPattern |
getFillPattern()
Gets the fill (cell background).
|
ExcelFont |
getFont()
Gets the font.
|
boolean |
getFormulaHidden()
Gets a value indicating whether the contents of the cell will not be displayed in the formula bar.
|
HorizontalAlignmentStyle |
getHorizontalAlignment()
Gets the horizontal alignment.
|
int |
getIndent()
Gets the number of spaces (of the
CellStyleCollection.getNormal() style font) of indentation for text in a cell. |
String |
getName()
|
String |
getNumberFormat()
Gets the number format which indicates how to format and render the numeric value of a cell.
|
String |
getNumberFormatLocal()
Gets a
String that represents the format code for the numeric value in the language of the user. |
boolean |
getQuotePrefix()
Gets a value indicating whether the text string in a cell should be prefixed by a single quote mark (e.g., 'text).
|
int |
getRotation()
Gets the text rotation in degrees (1/360th of a full circle).
|
VerticalAlignmentStyle |
getVerticalAlignment()
Gets the vertical alignment.
|
boolean |
isDefault()
Gets a value indicating whether the referenced workbook style is default (
CellStyleCollection.getNormal() ) and there are no additional modifications of cell formatting. |
boolean |
isLocked()
Gets a value indicating whether the cell is locked.
|
boolean |
isShrinkToFit()
Gets a value indicating whether the displayed text in the cell should be shrunk to fit the cell width.
|
boolean |
isTextVertical()
Gets a value indicating whether text orientation is vertical.
|
boolean |
isWrapText()
Gets a value indicating whether the text in a cell should be line-wrapped within the cell.
|
void |
setBorders(CellBorders borders)
Sets the borders.
|
void |
setFillPattern(ExcelFillPattern fillPattern)
Sets the fill (cell background).
|
void |
setFont(ExcelFont font)
Sets the font.
|
void |
setFormulaHidden(boolean formulaHidden)
Sets a value indicating whether the contents of the cell will not be displayed in the formula bar.
|
void |
setHorizontalAlignment(HorizontalAlignmentStyle horizontalAlignment)
Sets the horizontal alignment.
|
void |
setIndent(int indent)
Sets the number of spaces (of the
CellStyleCollection.getNormal() style font) of indentation for text in a cell. |
void |
setLocked(boolean locked)
Sets a value indicating whether the cell is locked.
|
void |
setNumberFormat(String numberFormat)
Sets the number format which indicates how to format and render the numeric value of a cell.
|
void |
setQuotePrefix(boolean quotePrefix)
Sets a value indicating whether the text string in a cell should be prefixed by a single quote mark (e.g., 'text).
|
void |
setRotation(int rotation)
Sets the text rotation in degrees (1/360th of a full circle).
|
void |
setShrinkToFit(boolean shrinkToFit)
Sets a value indicating whether the displayed text in the cell should be shrunk to fit the cell width.
|
void |
setTextVertical(boolean textVertical)
Sets the text rotation in degrees (1/360th of a full circle).
|
void |
setVerticalAlignment(VerticalAlignmentStyle verticalAlignment)
Sets the vertical alignment.
|
void |
setWrapText(boolean wrapText)
Sets a value indicating whether the text in a cell should be line-wrapped within the cell.
|
String |
toString()
|
public CellStyle()
CellStyle
class not associated with any workbook.
Preferable way to modify formatting 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 to AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range.
public CellStyle(ExcelFile workbook)
CellStyle
class which references default (CellStyleCollection.getNormal()
) style from the specified workbook.
Preferable way to modify formatting 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 to AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range.
workbook
- The workbook from which default (CellStyleCollection.getNormal()
) style this CellStyle
inherits formatting.public final CellBorders getBorders()
Gets the borders.
If set to null
, borders will be resolved from referenced workbook style.
for an example on border formatting
public final ExcelFillPattern getFillPattern()
Gets the fill (cell background).
ExcelFillPattern for an example on fill formatting
public final ExcelFont getFont()
Gets the font.
ExcelFont for example on font formatting
public final boolean getFormulaHidden()
Gets a value indicating whether the contents of the cell will not be displayed in the formula bar.
Default value is false
.
When the cell is hidden and the workbook is protected
or the sheet on which the cell resides is protected
,
then the cell value will be displayed in the cell grid location, but the contents of the cell will not be displayed in the formula bar.
This is true for all types of cell content, including formula, text, or numbers.
true
if the contents of the cell will not be displayed in the formula bar; otherwise, false
.public final HorizontalAlignmentStyle getHorizontalAlignment()
Gets the horizontal alignment.
Default value is HorizontalAlignmentStyle.GENERAL
.
HorizontalAlignmentStyle for an example on alignment formatting
public final int getIndent()
Gets the number of spaces (of the CellStyleCollection.getNormal()
style font) of indentation for text in a cell.
The number of spaces to indent is calculated as following: Number of spaces to indent = getIndent()
* 3.
Default value is 0.
If isTextVertical()
is true
, Horizontal alignment
should be set to HorizontalAlignmentStyle.LEFT
, HorizontalAlignmentStyle.RIGHT
or HorizontalAlignmentStyle.DISTRIBUTED
.
If isTextVertical()
is false
, Vertical alignment
should be set to VerticalAlignmentStyle.BOTTOM
, VerticalAlignmentStyle.TOP
or VerticalAlignmentStyle.DISTRIBUTED
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
CellStyleCollection.getNormal()
style font) of indentation for text in a cell.IndexOutOfBoundsException
- Value must be greater than or equal to 0.public String getName()
public final String getNumberFormat()
Gets the number format which indicates how to format and render the numeric value of a cell.
Default value is General.
If set to null
, number format will be resolved from referenced workbook style.
If the value of this property is General or empty string and ExcelCell value
is of LocalDateTime
type, ISO date/time format will be used as number format.
public final String getNumberFormatLocal()
String
that represents the format code for the numeric value in the language of the user.String
that represents the format code for the numeric value in the language of the user.public final boolean getQuotePrefix()
Gets a value indicating whether the text string in a cell should be prefixed by a single quote mark (e.g., 'text). Use it to store numeric value of a cell as text.
Default value is false
.
true
if the text string in a cell should be prefixed by a single quote mark (e.g., 'text); otherwise, false
.public final int getRotation()
Gets the text rotation in degrees (1/360th of a full circle).
Value must be between -90 and 90 and specifies counterclockwise rotation of the text from the normal position. The first letter of the text is considered the center-point of the arc.
Default value is 0.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
IndexOutOfBoundsException
- Value must be between -90 and 90.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setTextVertical(boolean)
,
setWrapText(boolean)
,
setShrinkToFit(boolean)
public final VerticalAlignmentStyle getVerticalAlignment()
Gets the vertical alignment.
Default value is VerticalAlignmentStyle.BOTTOM
.
VerticalAlignmentStyle for an example on alignment formatting
public final boolean isDefault()
CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting.true
if the referenced workbook style is default (CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting; otherwise, false
.public final boolean isLocked()
Gets a value indicating whether the cell is locked.
Default value is true
.
When cells are marked as "locked" and the workbook is protected
or the sheet is protected
,
then the options specified in the protection settings
are prohibited for these cells.
true
if the cell is locked; otherwise, false
.for an example on protection formatting
,
getFormulaHidden()
,
ExcelFile.isProtected()
,
ExcelWorksheet.isProtected()
,
ExcelWorksheet.getProtectionSettings()
public final boolean isShrinkToFit()
Gets a value indicating whether the displayed text in the cell should be shrunk to fit the cell width. Not applicable when a cell contains multiple lines of text.
Default value is false
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
true
if the displayed text in the cell should be shrunk to fit the cell width; otherwise, false
.public final boolean isTextVertical()
Gets a value indicating whether text orientation is vertical.
Default value is false
.
true
if text orientation is vertical; otherwise, false
.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setRotation(int)
,
setWrapText(boolean)
,
setShrinkToFit(boolean)
public final boolean isWrapText()
Gets a value indicating whether the text in a cell should be line-wrapped within the cell.
Default value is false
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
true
if the text in a cell should be line-wrapped within the cell; otherwise, false
.public final void setBorders(CellBorders borders)
Sets the borders.
If set to null
, borders will be resolved from referenced workbook style.
Diagonal-up (IndividualBorder.DIAGONAL_UP
/ MultipleBorders.DIAGONAL_UP
) and diagonal-down (IndividualBorder.DIAGONAL_DOWN
/ MultipleBorders.DIAGONAL_DOWN
)
always share the same color and line style.
borders
- The borders.for an example on border formatting
public final void setFillPattern(ExcelFillPattern fillPattern)
Sets the fill (cell background).
If set to null
, fill will be resolved from referenced workbook style.
Fill can be either pattern or gradient.
Gradient fill is currently supported in XLSX.
fillPattern
- The fill (cell background).ExcelFillPattern for an example on fill formatting
public final void setFont(ExcelFont font)
Sets the font.
If set to null
, font will be resolved from referenced workbook style.
font
- The font.ExcelFont for example on font formatting
public final void setFormulaHidden(boolean formulaHidden)
Sets a value indicating whether the contents of the cell will not be displayed in the formula bar.
Default value is false
.
When the cell is hidden and the workbook is protected
or the sheet on which the cell resides is protected
,
then the cell value will be displayed in the cell grid location, but the contents of the cell will not be displayed in the formula bar.
This is true for all types of cell content, including formula, text, or numbers.
// 'Protection' formatting group
sheet.getCell("B27").setValue("Locked = ");
sheet.getCell("C27").setValue("false");
sheet.getCell("C27").getStyle().setLocked(false);
sheet.getCell("B28").setValue("FormulaHidden = ");
sheet.getCell("C28").setValue("true");
sheet.getCell("C28").getStyle().setFormulaHidden(true);
formulaHidden
- true
if the contents of the cell will not be displayed in the formula bar; otherwise, false
.setLocked(boolean)
,
ExcelFile.isProtected()
,
ExcelWorksheet.isProtected()
public final void setHorizontalAlignment(HorizontalAlignmentStyle horizontalAlignment)
Sets the horizontal alignment.
Default value is HorizontalAlignmentStyle.GENERAL
.
horizontalAlignment
- The horizontal alignment.HorizontalAlignmentStyle for an example on alignment formatting
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setRotation(int)
,
setTextVertical(boolean)
,
setWrapText(boolean)
,
setShrinkToFit(boolean)
public final void setIndent(int indent)
Sets the number of spaces (of the CellStyleCollection.getNormal()
style font) of indentation for text in a cell.
The number of spaces to indent is calculated as following: Number of spaces to indent = getIndent()
* 3.
Default value is 0.
If isTextVertical()
is true
, Horizontal alignment
should be set to HorizontalAlignmentStyle.LEFT
, HorizontalAlignmentStyle.RIGHT
or HorizontalAlignmentStyle.DISTRIBUTED
.
If isTextVertical()
is false
, Vertical alignment
should be set to VerticalAlignmentStyle.BOTTOM
, VerticalAlignmentStyle.TOP
or VerticalAlignmentStyle.DISTRIBUTED
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
indent
- The number of spaces (of the CellStyleCollection.getNormal()
style font) of indentation for text in a cell.IndexOutOfBoundsException
- Value must be greater than or equal to 0.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setRotation(int)
,
setTextVertical(boolean)
,
setWrapText(boolean)
,
setShrinkToFit(boolean)
public final void setLocked(boolean locked)
Sets a value indicating whether the cell is locked.
Default value is true
.
When cells are marked as "locked" and the workbook is protected
or the sheet is protected
,
then the options specified in the protection settings
are prohibited for these cells.
// 'Protection' formatting group
sheet.getCell("B27").setValue("Locked = ");
sheet.getCell("C27").setValue("false");
sheet.getCell("C27").getStyle().setLocked(false);
sheet.getCell("B28").setValue("FormulaHidden = ");
sheet.getCell("C28").setValue("true");
sheet.getCell("C28").getStyle().setFormulaHidden(true);
locked
- true
if the cell is locked; otherwise, false
.getFormulaHidden()
,
ExcelFile.isProtected()
,
ExcelWorksheet.isProtected()
,
ExcelWorksheet.getProtectionSettings()
public final void setNumberFormat(String numberFormat)
Sets the number format which indicates how to format and render the numeric value of a cell.
Default value is General.
If set to null
, number format will be resolved from referenced workbook style.
If the value is General or empty string and ExcelCell value
is of LocalDateTime
type, ISO date/time format will be used as number format.
Custom number format has to be in invariant culture format.
Example:
Format string | Value | Output |
---|---|---|
##### | 123 | 123 |
00000 | 123 | 00123 |
#,### | 1234567890 | 1,234,567,890 |
00.00 | 1.2 | 01.20 |
#,##0.00 | 1234567890 | 1,234,567,890.00 |
#0.##% | 0.092 | 9.2% |
For more information on number format strings consult Microsoft Excel documentation.
Following code demonstrates number formatting:// 'Number' formatting group
sheet.getCell("B3").setValue("NumberFormat");
sheet.getCell("C3").setValue(1234);
sheet.getCell("C3").getStyle().setNumberFormat("#.##0,00 [$Krakozhian Money Units]");
numberFormat
- The number format which indicates how to format and render the numeric value of a cell.public final void setQuotePrefix(boolean quotePrefix)
Sets a value indicating whether the text string in a cell should be prefixed by a single quote mark (e.g., 'text). Use it to store numeric value of a cell as text.
Default value is false
.
quotePrefix
- true
if the text string in a cell should be prefixed by a single quote mark (e.g., 'text); otherwise, false
.public final void setRotation(int rotation)
Sets the text rotation in degrees (1/360th of a full circle).
Value must be between -90 and 90 and specifies counterclockwise rotation of the text from the normal position. The first letter of the text is considered the center-point of the arc.
Default value is 0.
Rotation
and isTextVertical()
are mutually exclusive.
If Rotation
is set, isTextVertical()
is set to false
.
If isTextVertical()
is set, Rotation
is set to 0.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
rotation
- The text rotation in degrees.IndexOutOfBoundsException
- Value must be between -90 and 90.getHorizontalAlignment()
,
getVerticalAlignment()
,
getIndent()
,
isTextVertical()
,
isWrapText()
,
isShrinkToFit()
public final void setShrinkToFit(boolean shrinkToFit)
Sets a value indicating whether the displayed text in the cell should be shrunk to fit the cell width. Not applicable when a cell contains multiple lines of text.
Default value is false
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
shrinkToFit
- true
if the displayed text in the cell should be shrunk to fit the cell width; otherwise, false
.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setRotation(int)
,
setTextVertical(boolean)
,
setWrapText(boolean)
public final void setTextVertical(boolean textVertical)
Sets the text rotation in degrees (1/360th of a full circle).
Value must be between -90 and 90 and specifies counterclockwise rotation of the text from the normal position. The first letter of the text is considered the center-point of the arc.
Default value is 0.
Rotation
and isTextVertical()
are mutually exclusive.
If Rotation
is set, isTextVertical()
is set to false
.
If isTextVertical()
is set, Rotation
is set to 0.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
textVertical
- The text rotation in degrees.IndexOutOfBoundsException
- Value must be between -90 and 90.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setTextVertical(boolean)
,
setWrapText(boolean)
,
setShrinkToFit(boolean)
public final void setVerticalAlignment(VerticalAlignmentStyle verticalAlignment)
Sets the vertical alignment.
Default value is VerticalAlignmentStyle.BOTTOM
.
verticalAlignment
- The vertical alignment.VerticalAlignmentStyle for an example on alignment formatting
,
getHorizontalAlignment()
,
getIndent()
,
getRotation()
,
isTextVertical()
,
isWrapText()
,
isShrinkToFit()
public final void setWrapText(boolean wrapText)
Sets a value indicating whether the text in a cell should be line-wrapped within the cell.
Default value is false
.
See HorizontalAlignmentStyle
or VerticalAlignmentStyle
for an example on alignment formatting
wrapText
- true
if the text in a cell should be line-wrapped within the cell; otherwise, false
.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
,
setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
,
setIndent(int)
,
setRotation(int)
,
setTextVertical(boolean)
,
setShrinkToFit(boolean)
public String toString()
© GemBox d.o.o. — All rights reserved.