Example:
$workbook = new cells\Workbook(); $cell = $workbook->getWorksheets()->get(0)->getCells()->get("A1"); $style1 = $cell->getStyle(); $style1->getFont()->setName("Times New Roman"); $style1->getFont()->setColor(cells\Color::getBlue()); $cell->setStyle($style1);
Constructor Summary |
---|
Property Getters/Setters Summary | ||
---|---|---|
function | getBackgroundArgbColor() | |
function | setBackgroundArgbColor(value) | |
Gets and sets the background color with a 32-bit ARGB value. | ||
function | getBackgroundColor() | |
function | setBackgroundColor(value) | |
Gets or sets a style's background color. | ||
function | getBackgroundThemeColor() | |
function | setBackgroundThemeColor(value) | |
Gets and sets the background theme color. | ||
function | getBorders() | |
Gets the |
||
function | getCultureCustom() | |
function | setCultureCustom(value) | |
Gets and sets the culture-dependent pattern string for number format. If no number format has been set for this object, null will be returned. If number format is builtin, the pattern string corresponding to the builtin number will be returned. | ||
function | getCustom() | |
function | setCustom(value) | |
Represents the custom number format string of this style object. If the custom number format is not set(For example, the number format is builtin), "" will be returned. | ||
function | getFont() | |
Gets a |
||
function | getForegroundArgbColor() | |
function | setForegroundArgbColor(value) | |
Gets and sets the foreground color with a 32-bit ARGB value. | ||
function | getForegroundColor() | |
function | setForegroundColor(value) | |
Gets or sets a style's foreground color. | ||
function | getForegroundThemeColor() | |
function | setForegroundThemeColor(value) | |
Gets and sets the foreground theme color. | ||
function | hasBorders() | |
Checks whether there are borders have been set for the style.
|
||
function | getHorizontalAlignment() | |
function | setHorizontalAlignment(value) | |
Gets or sets the horizontal alignment type of the text in a cell. The value of the property is TextAlignmentType integer constant. | ||
function | getIndentLevel() | |
function | setIndentLevel(value) | |
Represents the indent level for the cell or range. Can only be an integer from 0 to 250. | ||
function | getInvariantCustom() | |
Gets the culture-independent pattern string for number format.
If no number format has been set for this object, null will be returned.
If number format is builtin, the pattern string corresponding to the builtin number will be returned.
|
||
function | isAlignmentApplied() | |
function | setAlignmentApplied(value) | |
Indicate whether the alignment formatting should be applied. | ||
function | isBorderApplied() | |
function | setBorderApplied(value) | |
Indicate whether the border formatting should be applied. | ||
function | isDateTime() | |
Indicates whether the number format is a date format.
|
||
function | isFillApplied() | |
function | setFillApplied(value) | |
Indicate whether the fill formatting should be applied. | ||
function | isFontApplied() | |
function | setFontApplied(value) | |
Indicate whether the font formatting should be applied. | ||
function | isFormulaHidden() | |
function | setFormulaHidden(value) | |
Represents if the formula will be hidden when the worksheet is protected. | ||
function | isGradient() | |
function | setGradient(value) | |
Indicates whether the cell shading is a gradient pattern. | ||
function | isJustifyDistributed() | |
function | setJustifyDistributed(value) | |
Indicates if the cells justified or distributed alignment should be used on the last line of text. | ||
function | isLocked() | |
function | setLocked(value) | |
Gets or sets a value indicating whether a cell can be modified or not. | ||
function | isNumberFormatApplied() | |
function | setNumberFormatApplied(value) | |
Indicate whether the number formatting should be applied. | ||
function | isPercent() | |
Indicates whether the number format is a percent format.
|
||
function | isProtectionApplied() | |
function | setProtectionApplied(value) | |
Indicate whether the protection formatting should be applied. | ||
function | isTextWrapped() | |
function | setTextWrapped(value) | |
Gets or sets a value indicating whether the text within a cell is wrapped. | ||
function | getName() | |
function | setName(value) | |
Gets or sets the name of the style. | ||
function | getNumber() | |
function | setNumber(value) | |
Gets or sets the display format of numbers and dates. The formatting patterns are different for different regions. | ||
function | getParentStyle() | |
Gets the parent style of this style.
|
||
function | getPattern() | |
function | setPattern(value) | |
Gets or sets the cell background pattern type. The value of the property is BackgroundType integer constant. | ||
function | getQuotePrefix() | |
function | setQuotePrefix(value) | |
Indicates whether the cell's value starts with single quote mark. | ||
function | getRotationAngle() | |
function | setRotationAngle(value) | |
Represents text rotation angle. | ||
function | getShrinkToFit() | |
function | setShrinkToFit(value) | |
Represents if text automatically shrinks to fit in the available column width. | ||
function | getTextDirection() | |
function | setTextDirection(value) | |
Represents text reading order. The value of the property is TextDirectionType integer constant. | ||
function | getVerticalAlignment() | |
function | setVerticalAlignment(value) | |
Gets or sets the vertical alignment type of the text in a cell. The value of the property is TextAlignmentType integer constant. |
Method Summary | ||
---|---|---|
function | copy(style) | |
Copies data from another style object
|
||
function | equals(obj) | |
Determines whether two Style instances are equal.
|
||
function | getTwoColorGradient() | |
Get the two-color gradient setting.
|
||
function | getTwoColorGradientSetting() | |
Get the two-color gradient setting.
|
||
function | hashCode() | |
Serves as a hash function for a Style object.
|
||
function | isModified(modifyFlag) | |
Checks whether the specified properties of the style have been modified.
Used for style of ConditionalFormattings to check whether the specified properties of this style should be used when applying the ConditionalFormattings on a cell.
|
||
function | setBorder(borderType, borderStyle, borderColor) | |
Sets the borders of the style.
|
||
function | setBorder(borderType, borderStyle, borderColor) | |
Sets the borders of the style.
|
||
function | setCustom(custom, builtinPreference) | |
Sets the Custom number format string of a cell.
|
||
function | setPatternColor(pattern, color1, color2) | |
Sets the background color.
|
||
function | setTwoColorGradient(color1, color2, gradientStyleType, variant) | |
Sets the specified fill to a two-color gradient.
|
||
function | toJson() | |
Convert |
||
function | update() | |
Apply the named style to the styles of the cells which use this named style.
It works like clicking the "ok" button after you finished modifying the style.
Only applies for named style.
|
function Style()
function getBackgroundThemeColor() / function setBackgroundThemeColor(value)
function getForegroundThemeColor() / function setForegroundThemeColor(value)
function getName() / function setName(value)
function getPattern() / function setPattern(value)
function getBorders()
function getBackgroundColor() / function setBackgroundColor(value)
function getBackgroundArgbColor() / function setBackgroundArgbColor(value)
function getForegroundColor() / function setForegroundColor(value)
function getForegroundArgbColor() / function setForegroundArgbColor(value)
function hasBorders()
function getParentStyle()
function isNumberFormatApplied() / function setNumberFormatApplied(value)
function isFontApplied() / function setFontApplied(value)
function isAlignmentApplied() / function setAlignmentApplied(value)
function isBorderApplied() / function setBorderApplied(value)
function isFillApplied() / function setFillApplied(value)
function isProtectionApplied() / function setProtectionApplied(value)
function getIndentLevel() / function setIndentLevel(value)
function getFont()
function getRotationAngle() / function setRotationAngle(value)
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
You can set 255 or value ranged from -90 to 90.function getHorizontalAlignment() / function setHorizontalAlignment(value)
function getVerticalAlignment() / function setVerticalAlignment(value)
function isTextWrapped() / function setTextWrapped(value)
function getNumber() / function setNumber(value)
Value | Type | Format String |
---|---|---|
0 | General | General |
1 | Decimal | 0 |
2 | Decimal | 0.00 |
3 | Decimal | #,##0 |
4 | Decimal | #,##0.00 |
5 | Currency | $#,##0_);($#,##0) |
6 | Currency | $#,##0_);[Red]($#,##0) |
7 | Currency | $#,##0.00_);($#,##0.00) |
8 | Currency | $#,##0.00_);[Red]($#,##0.00) |
9 | Percentage | 0% |
10 | Percentage | 0.00% |
11 | Scientific | 0.00E+00 |
12 | Fraction | # ?/? |
13 | Fraction | # ??/?? |
14 | Date | m/d/yyyy |
15 | Date | d-mmm-yy |
16 | Date | d-mmm |
17 | Date | mmm-yy |
18 | Time | h:mm AM/PM |
19 | Time | h:mm:ss AM/PM |
20 | Time | h:mm |
21 | Time | h:mm:ss |
22 | Time | m/d/yyyy h:mm |
37 | Accounting | #,##0_);(#,##0) |
38 | Accounting | #,##0_);[Red](#,##0) |
39 | Accounting | #,##0.00_);(#,##0.00) |
40 | Accounting | #,##0.00_);[Red](#,##0.00) |
41 | Accounting | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) |
42 | Currency | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) |
43 | Accounting | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) |
44 | Currency | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) |
45 | Time | mm:ss |
46 | Time | [h]:mm:ss |
47 | Time | mm:ss.0 |
48 | Scientific | ##0.0E+0 |
49 | Text | @ |
function isLocked() / function setLocked(value)
function getCustom() / function setCustom(value)
function getCultureCustom() / function setCultureCustom(value)
function getInvariantCustom()
function isFormulaHidden() / function setFormulaHidden(value)
function getShrinkToFit() / function setShrinkToFit(value)
function getTextDirection() / function setTextDirection(value)
function isJustifyDistributed() / function setJustifyDistributed(value)
function getQuotePrefix() / function setQuotePrefix(value)
function isGradient() / function setGradient(value)
function isPercent()
function isDateTime()
function setTwoColorGradient(color1, color2, gradientStyleType, variant)
color1: Color
- One gradient color.color2: Color
- Two gradient color.gradientStyleType: Number
- A variant: Number
- The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.function getTwoColorGradient()
function getTwoColorGradientSetting()
function toJson()
function setPatternColor(pattern, color1, color2)
pattern: Number
- A color1: Color
- The foreground color.color2: Color
- The background color. Only works when pattern is not BackgroundType.None and BackgroundType.Solid.function copy(style)
style: Style
- Source Style objectfunction update()
function isModified(modifyFlag)
modifyFlag: Number
- A function equals(obj)
obj: Object
- The Style object to compare with the current Style object. function hashCode()
function setBorder(borderType, borderStyle, borderColor)
borderType: Number
- A borderStyle: Number
- A borderColor: Color
- The color of the border.function setBorder(borderType, borderStyle, borderColor)
borderType: Number
- A borderStyle: Number
- A borderColor: CellsColor
- The color of the border.function setCustom(custom, builtinPreference)
custom: String
- Custom number format string, should be InvariantCulture pattern.builtinPreference: boolean
- If given Custom number format string matches one of the built-in number formats
corresponding to current regional settings, whether set the number format as built-in instead of Custom.