Bug 56981

Summary: vertical alignment ignored after first cell in a row in XSSF
Product: POI Reporter: matt.england
Component: XSSFAssignee: POI Developers List <dev>
Severity: normal CC: matt.england
Priority: P2    
Version: 3.10-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Bug Depends on: 58224    
Bug Blocks:    
Attachments: demo snippet
Result of running the code and opening the file in MS Excel

Description matt.england 2014-09-14 01:50:18 UTC
Setting the vertical alignment of the style of the first cell in a row to CellStyle.VERTICAL_TOP, then subsequently attempting to set a later cell to CelLStyle.VERTICAL_BOTTOM results in both cells having TOP alignment (essentially, the second alignment is ignored). I've opened the result of executing the below demo snippet in both LibreOffice and OpenOffice (but not actual MS Excel, not sure if it would behave properly), and the problem appears in both, so I suspect it's a POI problem and not a bug common to both, though that is possible.

public class POITest {
  public static void main(String[] args) {
    //HSSFWorkbook exhibits correct behavior:
    Workbook workbook = new XSSFWorkbook(); 
    CellStyle vertTop = workbook.createCellStyle();
    CellStyle vertBottom = workbook.createCellStyle();
    Sheet sheet = workbook.createSheet("Sheet 1");
    Row row = sheet.createRow(0);
    Cell top = row.createCell(0);
    Cell bottom = row.createCell(1);
    top.setCellStyle(vertTop); //comment this out to get all bottom-aligned cells
    row.setHeightInPoints(85.75f); //make it obvious
    try {
      FileOutputStream out = new FileOutputStream("test.xlsx");
    } catch (IOException e) {
Comment 1 matt.england 2014-09-14 02:01:50 UTC
Created attachment 32019 [details]
demo snippet
Comment 2 Dominik Stadler 2015-04-30 14:18:12 UTC
Created attachment 32703 [details]
Result of running the code and opening the file in MS Excel
Comment 3 Dominik Stadler 2015-04-30 14:19:09 UTC
See the attached picture, it seems to work when opening the file with MS Excel, so I think this is rather a problem in LibreOffice/OpenOffice (which both share a common code-base so can easily have the same bug).