DOCUMENTS 5 - PortalScripting API
|
The XLSXFormat class allows formatting cells in Excel. More...
Public Member Functions | |
String | getLastError () |
Function to get the description of the last error that occurred. More... | |
boolean | setAlign (number alignment) |
Set the alignment for data in a cell. More... | |
boolean | setBackgroundColor (number color) |
Set the background color of the pattern for a cell. More... | |
boolean | setBackgroundPattern (number pattern) |
Set the background fill pattern for a cell. More... | |
boolean | setBorderColor (String border, number color) |
Set the color of the cell border. More... | |
boolean | setBorderStyle (String border, number style) |
Set the cell border style. More... | |
boolean | setFontColor (number color) |
Set the color of the font used in the cell. More... | |
boolean | setFontName (String name) |
Set the font used in the cell. More... | |
boolean | setFontScript (String style) |
Set the script style of the font. More... | |
boolean | setFontSize (number size) |
Set the size of the font used in the cell. More... | |
boolean | setFontStyle (String style) |
Set the font style for the format. More... | |
boolean | setForegroundColor (number color) |
Set the foreground color of the pattern for a cell. More... | |
boolean | setIndent (number level) |
Set the cell text indentation level. More... | |
boolean | setNumberFormat (String numFormat) |
Set the number format for a cell. More... | |
boolean | setShrink () |
Turn on the text "shrink to fit" for a cell. More... | |
boolean | setTextWrap () |
Wrap text in a cell. More... | |
The XLSXFormat class allows formatting cells in Excel.
An XLSXFormat object isn't created directly. Instead an XLSXFormat is created by calling the XLSXWriter.addFormat(String name) function from an XLSXWriter object. The properties of a cell that can be formatted include: fonts, colors, patterns, borders, alignment and number formatting.
String XLSXFormat::getLastError | ( | ) |
Function to get the description of the last error that occurred.
boolean XLSXFormat::setAlign | ( | number | alignment | ) |
Set the alignment for data in a cell.
As in Excel, vertical and horizontal alignments can be combined. Text can be aligned across two or more adjacent cells using the center_across property. However, for genuine merged cells it is better to use the XLSXWorksheet.mergeRange()
method.
The vertical justify option can be used to provide automatic text wrapping in a cell. The height of the cell will be adjusted to accommodate the wrapped text.
alignment | The horizontal or vertical alignment direction (see "Text alignments"). |
true
if successful, false
in case of any error boolean XLSXFormat::setBackgroundColor | ( | number | color | ) |
Set the background color of the pattern for a cell.
color | The cell pattern background color being a RGB integer value. |
true
if successful, false
in case of any error boolean XLSXFormat::setBackgroundPattern | ( | number | pattern | ) |
Set the background fill pattern for a cell.
pattern | Pattern index from "Background patterns". |
true
if successful, false
in case of any error boolean XLSXFormat::setBorderColor | ( | String | border, |
number | color | ||
) |
Set the color of the cell border.
border | String specifying which cell border(s) the color to be set for. The following values are available:
|
color | The desired cell border color being a RGB integer value. |
true
if successful, false
in case of any error boolean XLSXFormat::setBorderStyle | ( | String | border, |
number | style | ||
) |
Set the cell border style.
border | String specifying which cell border(s) the style to be set for. The following values are available:
|
style | Border style index from "Cell border styles". |
true
if successful, false
in case of any error boolean XLSXFormat::setFontColor | ( | number | color | ) |
Set the color of the font used in the cell.
color | The cell font color being a RGB integer value. |
true
if successful, false
in case of any error boolean XLSXFormat::setFontName | ( | String | name | ) |
Set the font used in the cell.
name | Optional String containing the cell font name. The default value is "Calibri". |
true
if successful, false
in case of any error boolean XLSXFormat::setFontScript | ( | String | style | ) |
Set the script style of the font.
style | Script style. The following styles are available:
|
true
if successful, false
in case of any error boolean XLSXFormat::setFontSize | ( | number | size | ) |
Set the size of the font used in the cell.
size | The cell font size. |
true
if successful, false
in case of any error XLSXWorksheet.setRow()
function. boolean XLSXFormat::setFontStyle | ( | String | style | ) |
Set the font style for the format.
style | String containing the font style. The following font styles are available:
|
true
if successful, false
in case of any error boolean XLSXFormat::setForegroundColor | ( | number | color | ) |
Set the foreground color of the pattern for a cell.
color | The cell pattern foreground color being a RGB integer value. |
true
if successful, false
in case of any error boolean XLSXFormat::setIndent | ( | number | level | ) |
Set the cell text indentation level.
level | Integer indentation level. |
true
if successful, false
in case of any error boolean XLSXFormat::setNumberFormat | ( | String | numFormat | ) |
Set the number format for a cell.
This method is used to define the numerical format of a number in Excel. It controls whether a number is displayed as an integer, a floating point number, a date, a currency value or some other user defined format. For more information about number formats in Excel refer to the Microsoft documentation for number formats.
numFormat | The numerical format of a cell specified by using a format string. |
true
if successful, false
in case of any error boolean XLSXFormat::setShrink | ( | ) |
Turn on the text "shrink to fit" for a cell.
true
if successful, false
in case of any error boolean XLSXFormat::setTextWrap | ( | ) |
Wrap text in a cell.
If you wish to control where the text is wrapped you can add newline characters to the string. Excel will adjust the height of the row to accommodate the wrapped text. A similar effect can be obtained without newlines using the XLSXFormat.setAlign(number alignment) function with XLSXWriter.ALIGN_VERTICAL_JUSTIFY.
true
if successful, false
in case of any error