We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set Color in Aspose Cells (excel)

Hi There,

I just wondering once you set a color to one cell say (Row:2 and Col: A), then you cant set the color other cells within that range?

Thanks

Kamiel


Hi,

Thanks for your posting and using Aspose.Cells for .NET.

You apply your Style object to range of cells using the ApplyStyle() method. ApplyStyle() method will apply your single Style object to all the cells inside your specific range.

Please see the following documentation article how to use the ApplyStyle() method for your needs.

http://www.aspose.com/docs/display/cellsnet/Copy+Range+Data+with+Style

Hi,


Thanks for the quick response.

I managed to be able to pick the cell and fill the color on the cell.

However, the problem that I am having is that once i have filled the color on one cell, I cant fill the next cell (next row but same column) using different color.

Example:

Row 1, Col 1: fill with Yellow
I tried to filled Row2, Col 1 with Blue, it still show yellow on the cells. When i debug the code, the style take blue color but when I print the workbook, it show blue on Row 2, Col 1.

The only think that I could think of is that maybe the cell was locked so we cant apply the style.

Any thoughts?

Thanks in advance for your help.

Regards,

Kamiel


Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please try creating a new Style object with your desired color and set it as a fill color of the cell using the Cell.SetStyle() method. It should resolve your issue.

Hi,


I did but still show up as yellow. below are the code:

Cell cell = cells.getCell(row, col);

Style style = cell.getStyle();
/*
* this.log.info(“before style:” + style.getColor().toString());
style.setColor©;
this.log.info(“after style:” + style.getColor().toString());
*/

style.setColor©;
cell.setStyle(style);

I even put a log and confirm that the style is changing color but it just does not apply the changes when creating the workbook.

Any thoughts?

Thanks

Kamiel



Hi,


I suspect you might be using some older version of the product, e.g. version before/prior to v2.5.4 etc. I am afraid, we might not help you much if you are using your older version because, Aspose.Cells for Java has been auto-ported from .NET version to make it more robust and feature rich component. Please see the document on how to migrate to latest Aspose.Cells for Java versions: http://www.aspose.com/docs/display/cellsjava/How+to+Migrate+to+Aspose.Cells+7.0.0+or+Higher

We recommend you to kindly try or upgrade to our latest version (if you are not already using it) of the product i.e. v7.5.2 and see the documents for your reference:

http://www.aspose.com/docs/display/cellsjava/Approaches+to+Format+Data+in+Cells
http://www.aspose.com/docs/display/cellsjava/Colors++and++Background+Patterns

Thank you.