xhaixia
November 12, 2015, 12:31am
1
How to get the color of worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
cells or worksheet haven’t style property
I cant call cells.get(cells.getMaxRow() + 1, 0).getStyle()to get this color
But these code will make save method generate a extra row
Workbook wb = new Workbook(“C:/DefaultColor2.xlsx”);
Cells cells = wb.getWorksheets().get(0).getCells();
Cell cell = cells.get(cells.getMaxRow() + 1, 0);
System.out.println(Integer.toHexString(cell.getStyle().getForegroundArgbColor()));
wb.save(“C:/DefaultColor2.html”);
This will make html has a blank row
xhaixia
November 12, 2015, 12:40am
2
In fact I can call method by reflect to get these like
Cells cells = workbook.getWorksheets().get(0).getCells();
ColumnCollection columns = cells.getColumns();
Method method = columns.getClass().getDeclaredMethod(“a”);
method.setAccessible(true);
Column column = (Column) method.invoke(columns);
System.out.println(Integer.toHexString(column.getStyle().getForegroundArgbColor()));
Can you make these method to public without obfuscator
Hi, Thanks for your posting and using Aspose.Cells. You can get the default style of the entire workbook using the Workbook.getDefaultStyle() property.
xhaixia
November 12, 2015, 1:28am
4
It’s not work.
And two sheet can have difference default color.
Workbook wb = new Workbook(“C:/DefaultColor2.xlsx”);
System.out.println(“W:” + Integer.toHexString(wb.getDefaultStyle().getForegroundArgbColor()));
Cells cells = wb.getWorksheets().get(0).getCells();
ColumnCollection columns = cells.getColumns();
Method method = columns.getClass().getDeclaredMethod(“a”);
method.setAccessible(true);
Column column = (Column) method.invoke(columns);
System.out.println(“S:” + Integer.toHexString(column.getStyle().getForegroundArgbColor()));
wb.save(“C:/DefaultColor2.html”);
Output:
Hi, Thanks for your sample excel file and using Aspose.Cells. Please let us know how do you set default color of worksheet using Microsoft Excel. If you set the color of all cells then you can get the color of individual cell using Cell.getStyle() property.
xhaixia
November 12, 2015, 1:49am
6
In MS Excel, click top left corner of sheet, left to A, above 1, MS Excel display a triangle icon, this will make MS Excel select all cells.
And then set foreground color.
See my post above, Aspose has this method, but just obfuscation.
I need it change to public without obfuscation.
Hi, Thanks for your suggestion and using Aspose.Cells. We have logged a ticket for this feature in our database for product team investigation. We will look into it and implement this feature. In case, we need to unobfuscated some method relating to it, we will do it or implement a new method for it. Once there is some news for you, we will let you know asap. This issue has been logged as
CELLSJAVA-41560 - How to get default color of worksheet
Hi,
xhaixia:
But these code will make save method generate a extra row
Workbook wb = new Workbook("C:/DefaultColor2.xlsx");
Cells cells = wb.getWorksheets().get(0).getCells();
Cell cell = cells.get(cells.getMaxRow() + 1, 0);
System.out.println(Integer.toHexString(cell.getStyle().getForegroundArgbColor()));
wb.save("C:/DefaultColor2.html");
This will make html has a blank row
Well, you may try the sample code to remove the unnecessary row data:
e.g
Sample code:
............
System.out.println(Integer.toHexString(cell.getStyle().getForegroundArgbColor()));
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
htmlSaveOptions.setExportBogusRowData(false);
wb.save("e:\\test2\\DefaultColor.html", htmlSaveOptions);
Thank you.
Hi again,
This is to update you that we have fixed the problem logged earlier as CELLSJAVA-41560. We will shortly provide the fix here after insuring the quality of the build and incorporating other enhancements.
The issues you have found earlier (filed as CELLSJAVA-41560) have been fixed in this update .
This message was posted using Notification2Forum from Downloads module by Aspose Notifier .