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

           Summary: autoSizeColumn sets column width beyond 255 character
                    limit for XSSF sheets
           Product: POI
           Version: 3.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Using version 3.7

XSSFSheet.autoSizeColumn calculates the size of a large column beyond the 255
character maximum.  The HSSFSheet.autoSizeColumn does not do this.  I noticed
that bug 50211 combined the XSSF and HSSF autoSizeColumn methods.  I have not
tried the latest developer release; however, I wanted to get this in there to
make sure this bug isn't carried over from the XSSF class.

To reproduce:

import org.apache.poi.xssf.usermodel.*;
import java.io.*;

public class AutoSizeTest {

    public static void main(String args[]) {
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet    sheet = workbook.createSheet("");
        XSSFRow      row = sheet.createRow(0);
        XSSFCell     cell0 = row.createCell(0);

        cell0.setCellValue("www.hostname.com, www.hostname.com,
www.hostname.com, www.hostname.com, www.hostname.com, www.hostname.com, 
www.hostname.com, www.hostname.com, www.hostname.com, www.hostname.com, 
www.hostname.com, www.hostname.com, www.hostname.com, www.hostname.com, 
www.hostname.com, www.hostname.com, www.hostname.com, www.hostname.com");

        sheet.autoSizeColumn(0);
        sheet.setColumnWidth(0, sheet.getColumnWidth(0)); // FAILS HERE

        try {
            FileOutputStream out = new FileOutputStream("working.xls");
            workbook.write(out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    } // main
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to