//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Style style = workbook.createStyle();
//Setting the background color to Blue
style.setBackgroundColor(Color.getBlue());
//Setting the foreground color to Red
style.setForegroundColor(Color.getRed());
//setting Background Pattern
style.setPattern(BackgroundType.DIAGONAL_STRIPE);
//New Style Flag
StyleFlag styleFlag = new StyleFlag();
//Set All Styles
styleFlag.setAll(true);
//Get first row
Row row = worksheet.getCells().getRows().get(0);
//Apply Style to first row
row.applyStyle(style, styleFlag);
//Saving the Excel file
workbook.save("book1.xls");
Get the cell by specific index in the list.
NOTE: This member is now obsolete.
Instead, please use Row.GetEnumerator() method to iterate all cells in this row.
This property will be removed 12 months later since February 2015.
Aspose apologizes for any inconvenience you may have experienced.
Parameters:
index - The position.
Returns:
The Cell object.
iterator
public java.util.Iterator iterator()
Gets the cells enumerator
Returns:
The cells enumerator
Example:
Workbook workbook = new Workbook("template.xlsx");
Cells cells = workbook.getWorksheets().get(0).getCells();
Iterator en = cells.getRows().get(1).iterator();
while (en.hasNext())
{
Cell cell = (Cell)en.next();
System.out.println(cell.getName() + ": " + cell.getValue());
}
Returns the cell object if the cell exists.
Or returns null if the cell object does not exist.
copySettings
public void copySettings(Row source, boolean checkStyle)
Copy settings of row, such as style, height, visibility, ...etc.
Parameters:
source - the source row whose settings will be copied to this one
checkStyle - whether check and gather style.
Only takes effect and be needed when two row objects belong to different workbook and the styles of two workbooks are different.