Bug 64494 - CellStyles propagate unexpectedly and incorrectly
Summary: CellStyles propagate unexpectedly and incorrectly
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-03 12:39 UTC by Marco Barigazzi
Modified: 2020-08-27 19:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Barigazzi 2020-06-03 12:39:31 UTC
Hello, in the context of XSSF CellStyles this happens. If I write this very simple code:

XSSFCellStyle styleRight = workbook.createCellStyle();
XSSFCellStyle styleLeft = workbook.createCellStyle();
styleRight.setAlignment(HorizontalAlignment.RIGHT);
styleLeft.setAlignment(HorizontalAlignment.LEFT);

The cells that have their style set to styleLeft will also, incorrectly, be aligned to the right. 

If there is any other command that acts on either one of these styles, say for example a setFont or setDataFormat, at any other point in the code, the cells that have their style set to styleLeft will correctly be aligned to the left.

If BOTH styles have a, say, setFont applied to them, and the font put as argument is the same object for both styles, the alignment will break again and the supposedly left-aligned cells will align right (this doesn't happen if two identical objects are set as the setFont arguments in either style).

If the order in which the objects are created flips (so styleLeft is created before styleRight), so does the alignment (both will be aligned left). This applies also for >2 styles, the first style created will propagate to all the following ones.