Hi Support,
This message was posted using Email2Forum by Imran Rafique.
Hi Support,
Hi,
Cell cell=cells.get(“A1”);
style = cell.getDisplayStyle(); //Get the foreground/background color
Color foregroundColor = style.getForegroundColor();
Color backgroundColor = style.getBackgroundColor();
Thank you.
Thank you. I think this will just get the cell color before conditional formatting is applied ?
Getting the color of conditional formatting is very important to my project. I am using POI at the moment, but it does not support this feature. I will switch to Aspose if it support it.
Hi,
com.aspose.cells.Workbook workbook = null ;
try {
System.out.println("start open workbook");
workbook = new com.aspose.cells.Workbook("test.xlsx");
System.out.println("end open workbook");
} catch (Exception e) {
System.out.println("Failed to open workbook");
e.printStackTrace();
}
Please ignore my previous message - I had jar file load issues which I have sorted.
Hi,
For your information, Aspose.Cells is a class library/component that does not provide any user interface. It is spreadsheet management library used to create, manipulate, render or print Excel file formats (XLS, XLSX, XLSM, XLSB, CSV, ODS, SpreadsheetML, PDF etc.). It supports almost all the features that MS Excel (97-2007/2010) supports. If you need to view Excel files in WYSIWYG (visual) manner, Aspose.Cells for .NET also provides a suit of Grid like controls (independent controls i.e…, Aspose.Cells.GridDesktop and Aspose.Cells.GridWeb) that provides this capability to view/display, create and manipulate Excel files on the fly.
Please see the docs and demos of GridWeb for your reference:
Aspose.Cells.GridDesktop
Aspose.Cells.GridWeb
Aspose.Cells-for-.NET
See the docs for Aspose.Cells.GridDesktop that is similar control as GridWeb but it is used for desktop/winform applications:
PS: We don’t have such controls in JAVA though.
Let us know if you still have any confusion or issue.
Thank you.
OK, I have now got the colors:
Color foregroundColor = style.getForegroundColor();
Color backgroundColor = style.getBackgroundColor();
I want to see what these colors are in terms of RGB. How do I do that?(All the documentation seems to be about setting the color not getting it )
Hi,
The cell.getDisplayStyle() works well when the condition is an expression (for example, if cell value is > 10) . But when I use a TOP 10 condition, it just returns the original colors of the cell ignoring conditional formatting ?
Hi,
The code:
try {
workbook = new com.aspose.cells.Workbook(path);
Worksheet worksheet = workbook.getWorksheets().get(0);
com.aspose.cells.Cell cell = worksheet.getCells().get("A1");
String text = cell.getDisplayStringValue();
System.out.println("Text: " + text);
Style style = cell.getDisplayStyle();
Color color = style.getBackgroundColor();
System.out.println("Color BG: " + String.format("#%02x%02x%02x", color.getR(), color.getG() , color.getB()) );
color = style.getForegroundColor();
System.out.println("Color FG: " + String.format("#%02x%02x%02x", color.getR(), color.getG() , color.getB()) );
} catch (Exception e) {
System.out.println("Failed to open workbook");
e.printStackTrace();
}
Run 1 without TOP 10 conditional formatting:
Text: 5
Color BG: #ffffff
Color FG: #808080
Run 2 with TOP 10 conditional formatting (set to highlight top 3 - Excel spreadsheet attched)
Text: 5
Color BG: #ffffff
Color FG: #808080
Does not pick up conditional formatting background change.
Hi,
Thanks for your posting and using Aspose.Cells for Java.
You are right. Cell.getDisplayStyle() is not returning the color of TOP 10 conditional formatting. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as CELLSJAVA-40671.
Hi,
Thanks for using Aspose.Cells.
We have fixed this issue.
Please download and try the latest version: Aspose.Cells for Java (Latest Version) and let us know your feedback.
The issues you have found earlier (filed as CELLSJAVA-40671) have been fixed in this update.