You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/07/26 06:05:49 UTC

DO NOT REPLY [Bug 47581] New: XSSFSheet.setColumnWidth does not do anything

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

           Summary: XSSFSheet.setColumnWidth does not do anything
           Product: POI
           Version: 3.5-dev
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: prescindor@gmail.com


After being dissatisfied with the results of XSSFSheet.autoSizeColumn, I tried
to use XSSFSheet.setColumnWidth to implement my own crude attempt at column
width fitting. Nothing happened. The columns in the output .xlsx were all the
default width.

Armed with the knowledge that autoSizeColumn was able to do something, if not
what I wanted, but setColumnWidth was not, I looked at the source. Turns out
autoSizeColumn calls columnHelper.setColBestFit and columnHelper.setCustomWidth
when it sets the width it computed, whereas setColumnWidth does not.

Workaround: I was able to set my computed widths by calling the columnHelper
methods prior to the setColumnWidth call (easy to do from JRuby — from Java,
you probably need a reflection hack). Actually, it looks like you only need
either one of the columnHelper calls, not both.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581



--- Comment #2 from David Agnew <pr...@gmail.com> 2009-09-08 09:42:33 PDT ---
Created an attachment (id=24228)
Test case with code to generate good and bad files.

Attached is a Java app that generates good and bad test files.

The bad version of the file displays incorrectly in Excel 2008 for Mac 12.2.1
(090605) but correctly in the Mac Finder's preview display and correctly on
Windows, using Excel 2007.

The good version, produced using the workaround (calling
ColumnHelper.setCustomWidth) displays correctly in Excel Mac 2008. The good
version is a few bytes longer.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO


--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2009-08-05 10:15:55 PDT ---
Can you attach a sample code that demonstrates the problem? 

The following code works fine to me:

        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sh = wb.createSheet();
        sh.setColumnWidth(0, 256*5);  //5-character wide
        sh.setColumnWidth(1, 256*20); //20-character wide
        sh.setColumnWidth(2, 256*50); //50-character wide

        FileOutputStream out = new FileOutputStream("bug-47581.xlsx");
        wb.write(out);
        out.close();

I tested with current trunk and Excel 2007.

Yegor

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581


David Agnew <pr...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Yegor Kozlov <ye...@dinom.ru> 2009-09-13 10:53:02 PDT ---
I fixed XSSFSheet.setColumnWidth to always set the customWidth="true" attribute
of the CTCol bean. 

The fix was committed in r814358

Regards,
Yegor

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581



--- Comment #3 from David Fisher <df...@jmlafferty.com> 2009-09-08 09:51:44 PDT ---
You should upgrade your Mac Excel version.

Please see https://issues.apache.org/bugzilla/show_bug.cgi?id=47559

Microsoft was very responsive and quick with the patch. It was delivered about
one month ago.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47581] XSSFSheet.setColumnWidth does not do anything

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47581



--- Comment #4 from David Agnew <pr...@gmail.com> 2009-09-08 10:03:23 PDT ---
(In reply to comment #3)
> You should upgrade your Mac Excel version.
> 
> Please see https://issues.apache.org/bugzilla/show_bug.cgi?id=47559
> 
> Microsoft was very responsive and quick with the patch. It was delivered about
> one month ago.

I tested with 12.2.1. I just ran Check for Updates, and it didn't turn up any.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org