Example:
//Instantiating a Workbook object var workbook = new aspose.cells.Workbook(); var sheet = workbook.getWorksheets().get(0); //Get Conditional Formattings var cformattings = sheet.getConditionalFormattings(); //Adds an empty conditional formatting var index = cformattings.add(); //Get newly added Conditional formatting var fcs = cformattings.get(index); //Sets the conditional format range. var ca = new aspose.cells.CellArea(); ca.StartRow = 0; ca.EndRow = 0; ca.StartColumn = 0; ca.EndColumn = 0; fcs.addArea(ca); ca = new aspose.cells.CellArea(); ca.StartRow = 1; ca.EndRow = 1; ca.StartColumn = 1; ca.EndColumn = 1; fcs.addArea(ca); //Add condition. var conditionIndex = fcs.addCondition(aspose.cells.FormatConditionType.CELL_VALUE, aspose.cells.OperatorType.BETWEEN, "=A2", "100"); //Add condition. var conditionIndex2 = fcs.addCondition(aspose.cells.FormatConditionType.CELL_VALUE, aspose.cells.OperatorType.BETWEEN, "50", "100"); //Sets the background color. var fc = fcs.get(conditionIndex); fc.getStyle().setBackgroundColor(aspose.cells.Color.getRed()); //Saving the Excel file workbook.save("Book1.xls");
Property Getters/Setters Summary | ||
---|---|---|
function | getCount() | |
function | get(index) | |
Gets the FormatConditions element at the specified index.
|
Method Summary | ||
---|---|---|
function | add() | |
Adds a FormatConditions to the collection.
|
||
function | add(value) | |
Reserved for internal use. |
||
function | clear() | |
function | contains(value) | |
Reserved for internal use. |
||
function | copy(cfs) | |
Copies conditional formatting.
|
||
function | get(index) | |
Reserved for internal use. |
||
function | indexOf(value) | |
Reserved for internal use. |
||
function | iterator() | |
function | removeArea(startRow, startColumn, totalRows, totalColumns) | |
Remove all conditional formatting in the range.
|
||
function | removeAt(index) | |
function getCount()
function get(index)
index
- The zero based index of the element.function removeArea(startRow, startColumn, totalRows, totalColumns)
startRow: Number
- The start row of the range.startColumn: Number
- The start column of the range.totalRows: Number
- The number of rows of the range.totalColumns: Number
- The number of columns of the range.function copy(cfs)
cfs: ConditionalFormattingCollection
- The conditional formattingfunction add()
function clear()
function removeAt(index)
function iterator()
function get(index)
function contains(value)
function add(value)
function indexOf(value)