Created attachment 34097 [details] File to reproduce issue Since r1706789 (POI 3.14 beta 1) In the attached example, all columns have the same style. Columns A:C have the same width, and get grouped together with sheet.groupColumns(0, 2). The group is uncollapsed. For columns E:G, column F has a different width. When grouping these columns, only the first 2 columns are grouped, and the column group is collapsed. sheet1.xml: > <cols> > <col min="1" max="5" width="13.42578125" style="1" customWidth="1"/> > <col min="6" max="6" width="31.7109375" style="1" customWidth="1"/> > <col min="7" max="7" width="13.42578125" style="1" customWidth="1"/> > </cols>
After executing the following code: Workbook wb = WorkbookFactory.create(new File("59932.xlsx")); Sheet sheet = wb.getSheetAt(0); sheet.groupColumn(0, 2); sheet.groupColumn(4, 6); wb.write(new FileOutputStream("59932 after.xlsx")); wb.close(); This is what POI writes: > <cols> > <col min="1" max="3" customWidth="true" style="1" width="13.42578125" collapsed="false" outlineLevel="1"/> > <col min="4" max="4" customWidth="true" style="1" width="13.42578125" collapsed="true"/> > <col min="5" max="5" customWidth="true" style="1" width="13.42578125" collapsed="false" outlineLevel="1"/> > <col min="6" max="6" customWidth="true" style="1" width="31.7109375" collapsed="false" outlineLevel="1"/> > <col min="6" max="7" collapsed="false" outlineLevel="1"/> > <col min="7" max="7" customWidth="true" style="1" width="13.42578125" collapsed="false"/> > </cols> Should be: > <cols> > <col min="1" max="3" width="13.42578125" style="1" customWidth="1" outlineLevel="1"/> > <col min="4" max="4" width="13.42578125" style="1" customWidth="1"/> > <col min="5" max="5" width="13.42578125" style="1" customWidth="1" outlineLevel="1"/> > <col min="6" max="6" width="31.7109375" style="1" customWidth="1" outlineLevel="1"/> > <col min="7" max="7" width="13.42578125" style="1" customWidth="1" outlineLevel="1"/> > </cols>
Created attachment 34098 [details] Disabled unit test, currently failing
Created attachment 34944 [details] File to reproduce maybe the same error Hi, I have also the problem that the function groupColumn not working correctly. And the size of the columns are also not correct after groupColumn. If I call groupColumn after changing the size of the columns I have the problem. If I call groupColumn before changing the size of the columns it seems to be good. In my application it is very difficult to change the position of the function call. I have tested the current version 3.16.
I ran into the same mistake. First use groupColumn, then setColumnWidth and it works. The order is important. version 4.0.1