Set the color of an entire row or column

Hi,

I want to set the color of an entire row or column,

The beginning of the row/column is the cell(0,0) and the end is not specified

can you help me,please.

I work with Aspose 7.1.0.3.

Thanks.


Hi,


See the sample code below:

Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);

Cells cells = sheet.getCells();
cells.get(“A1”).putValue(“Column1”);
cells.get(“B1”).putValue(“Column2”);
Style style = workbook.getStyles().get(workbook.getStyles().add());
style.setForegroundColor(Color.getYellow());
style.setPattern(BackgroundType.SOLID);
StyleFlag flag = new StyleFlag();
flag.setCellShading(true);

//Get the first column
Column column = cells.getColumns().get(0);

//Applying the style to the column
column.applyStyle(style, flag);


workbook.save(“range_style_book.xlsx”);

Similarly you may use Row.applyStyle() method to format complete row.


See a document for your further reference:
http://www.aspose.com/docs/display/cellsjava/Formatting+Rows++and++Columns



Thank you.

Thank you very much :slight_smile:

Hi,

Thanks for your feedback.

Let us know if you face any other issue, we will be glad to help you asap.

We also recommend you to download and try the Offline - Aspose.Cells for Java Demos. It will help you to get familiar with Aspose.Cells for Java API (s) quickly.