https://issues.apache.org/bugzilla/show_bug.cgi?id=56981

            Bug ID: 56981
           Summary: vertical alignment ignored after first cell in a row
                    in XSSF
           Product: POI
           Version: 3.10-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: matt.engl...@autoknowledge.net

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();
    vertTop.setVerticalAlignment(CellStyle.VERTICAL_TOP);
    CellStyle vertBottom = workbook.createCellStyle();
    vertBottom.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM);
    Sheet sheet = workbook.createSheet("Sheet 1");
    Row row = sheet.createRow(0);
    Cell top = row.createCell(0);
    Cell bottom = row.createCell(1);
    top.setCellValue("Top");
    top.setCellStyle(vertTop); //comment this out to get all bottom-aligned
cells
    bottom.setCellValue("Bottom");
    bottom.setCellStyle(vertBottom);
    row.setHeightInPoints(85.75f); //make it obvious
    try {
      FileOutputStream out = new FileOutputStream("test.xlsx");
      workbook.write(out);
      out.flush();
      out.close();
    } catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to