Bug 57768 - CellStyle.cloneStyleFrom(...) does not copying background colors and borders
Summary: CellStyle.cloneStyleFrom(...) does not copying background colors and borders
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.12-dev
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-27 15:01 UTC by Michael
Modified: 2015-06-10 14:52 UTC (History)
1 user (show)



Attachments
Java code, excel template file, screenshots (94.26 KB, application/zip)
2015-03-27 15:01 UTC, Michael
Details
Java code (4.59 KB, text/plain)
2015-03-27 15:48 UTC, Michael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2015-03-27 15:01:35 UTC
Created attachment 32615 [details]
Java code, excel template file, screenshots

Method cloneStyleFrom(CellStyle cellStyle) does not copy all styles. For example: background color, borders.
If trying to copy background color after calling this method, getting Exception:
java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.apache.poi.xssf.model.StylesTable.getFillAt(StylesTable.java:269)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.getCTFill(XSSFCellStyle.java:1081)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.setFillPattern(XSSFCellStyle.java:1133)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.setFillPattern(XSSFCellStyle.java:1154)
	at TestCopyFileExcel.copyCellStyle(TestCopyFileExcel.java:133)
...

See attachment for details.
Comment 1 Dominik Stadler 2015-03-27 15:15:09 UTC
There have been a few fixes in that area lately which should make this work as expected. Please try a recent nightly build from https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/ and let us know if it works!
Comment 2 Michael 2015-03-27 15:48:48 UTC
Created attachment 32616 [details]
Java code
Comment 3 Michael 2015-03-27 15:53:59 UTC
With latest build (poi-3.12-beta2-20150326):

- Copying background colors for cells and rows, but doesn't - for columns;
- When opening resulting excel file in MS-Excel getting same errors (see screenshots in the initial attachment);
- Does not copy borders;
- If trying to copy borders manually after calling this method (cloneStyleFrom) receive exception:
java.lang.IndexOutOfBoundsException: Index: 10, Size: 2
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.apache.poi.xssf.model.StylesTable.getBorderAt(StylesTable.java:255)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.getCTBorder(XSSFCellStyle.java:1109)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.setBorderBottom(XSSFCellStyle.java:801)
	at org.apache.poi.xssf.usermodel.XSSFCellStyle.setBorderBottom(XSSFCellStyle.java:819)
	at TestCopyFileExcel.copyCellStyle(TestCopyFileExcel.java:134)
...
Comment 4 Michael 2015-03-31 15:27:17 UTC
Do you know (any idea) when the next stable build (v. 3.12) could be released?
Thanks.
Comment 5 chinafool 2015-04-27 08:40:55 UTC
I want to know if the last version has solved this problem,cause my program has met this problem,too.
When I use the "clonecellstylefrom()" function,the color of the font/background leave white.
Do you really change it in v3.12?
Looking forward to your reply.
                               from a china user
Comment 6 Michael 2015-06-10 14:52:17 UTC
In the version 3.12