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/05/16 17:24:00 UTC

DO NOT REPLY [Bug 47206] New: XSSFSheet autSizeColumn not considering all rows

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

           Summary: XSSFSheet autSizeColumn not considering all rows
           Product: POI
           Version: 3.5-dev
          Platform: PC
        OS/Version: Windows Vista
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: robstewart57@googlemail.com


Created an attachment (id=23670)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23670)
Zip file with 3 attachments

Hi there, I am experiencing some strange behaviour with the method
XSFFSheet.autoSizeColumn(i)

I have taken a spreadsheet with two rows. I have made two cells on the 2nd row
contain more text than the cell directly above that, on row one.

I saved the spreadsheet, one as Office 2003 format: 2003_Report.xls , and the
other as 2007 format: 2007_Report.xlsx

I attach a small Java program (Main.java attached). The intention is to adjust
the column widths on both sheets, so that all columns are correctly adjusted to
show all text as visible.

The application adjusts the 2003 (.xls) file just fine, but the 2007 (.xlsx)
file does not show all the text in the 2nd row.

Note this is a really simple example that I am using to illustrate a problem
I'm experiencing with poi-dev3.5. I am dealing with spreadsheets with 100's of
rows. Dealing with both xlsx and xls files, and the implementation of
XSFFSheet.autoSizeColumn(i) does not deal with column widths very well.

ATTACHMENTS:
- autoSizeColumn.zip
- - 2003_Report.xls
- - 2007_Report.xlsx
- - Main.java

Thanks.

-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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





--- Comment #7 from ROb <ro...@googlemail.com>  2009-05-19 10:47:25 PST ---
Hi there,

I'm adding an attachment, this time only the Main.java as this is all that is
necessary.

Apologies for the red herrings in the previous email.

The Java code attached illustrates exactly the problem I'm having.

The code does:
1. Make a new XSSF workbook
2. Adds data to it
3. Tries to resize the columns, but fails

Thoughts ?

thanks.

Rob.

-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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





--- Comment #2 from Yegor Kozlov <ye...@dinom.ru>  2009-05-17 09:45:53 PST ---
Created an attachment (id=23673)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23673)
xssf screenshot

-- 
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


[Bug 47206] XSSFSheet autoSizeColumn not considering all rows

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

--- Comment #9 from Shubham <su...@gmail.com> ---
Hi Yegor ,

I am using 3.10 beta , but still i am having this issue. Please guide us how we
can get it worked.

Previously i was using 3.7 HSSF, which was not having facility to pass number
of rows.

// keep some rows in
memory, exceeding rows will be flushed to disk.

But when i changed it to SXSSF , speed was superb to write excel.

With ur previous comment , i am understanding that autoresizecolumn is not
possible in this way.  So i m looking for a way to use this with nice column
width.

Thanks
Shubham

-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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


ROb <ro...@googlemail.com> changed:

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




--- Comment #4 from ROb <ro...@googlemail.com>  2009-05-18 08:24:22 PST ---
Hi,

I am happy to give you additional information, as I have pinpointed why the
problem occurs. It is to do with the fact that I have applied a  XSSFCellStyle
to each cell before calling the autoSizeColumn.

I am creating a spreadsheet with multiple tabs (sheets). I am creating each
sheet as such:
----------
String[] columns = new String[]{"Column_1","Column_2", "Column_3"};
createSheet("Part Number Comparisons", columns);
----------

then....
--------------

 public void createSheet(String sheetName, String[] columns){
         XSSFCellStyle style = wb.createCellStyle();
        style.setFillForegroundColor(new XSSFColor(Color.lightGray));
        style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
        style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
        style.setBorderBottom(XSSFCellStyle.BORDER_THIN);

         XSSFSheet sheet = wb.createSheet(sheetName);
         sheet.createFreezePane( 0, 1, 0, 1 );
         XSSFRow row = sheet.createRow((short) 0);

         for(int i=0;i<columns.length;i++){
             XSSFCell cell = row.createCell(i);
         cell.setCellValue(columns[i].toString());
         cell.setCellStyle(style);
         }

         XSSFRow row2 = sheet.createRow((short) 1);
         XSSFCellStyle style2 = wb.createCellStyle();
         style2.setFillForegroundColor(new XSSFColor(Color.WHITE));
         style2.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
         style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
    }

-------------


FINALLY, the resizeXLSXColumns(String FILENAME) method is called AFTER the
above has taken place.

Simply, the autoSizeColumns() for XSSFSheet does not deal with XSSFCellSytle
very well, where as HSSFSheet seems to handle HSSFCellStyle Ok.

Hope that helps.


Rob Stewart

-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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





--- Comment #5 from Yegor Kozlov <ye...@dinom.ru>  2009-05-18 11:32:06 PST ---
Still can't get it. I combined createSheet() with Main.java and the output
looks OK. All columns are resized correctly. 

Can you post an isolated example which demonstrates the problem? Perhaps, a
version of Main.java including additional code. 

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 47206] XSSFSheet autoSizeColumn not considering all rows

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


ROb <ro...@googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|XSSFSheet autSizeColumn not |XSSFSheet autoSizeColumn
                   |considering all rows        |not considering all rows




-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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


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

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




--- Comment #8 from Yegor Kozlov <ye...@dinom.ru>  2009-05-23 01:22:50 PST ---
Fixed in r777834 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=777834 ). 
Excel JDBC Driver is the culprit. It inserts strings in a funny way and POI
couldn't read them. 

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 47206] XSSFSheet autoSizeColumn not considering all rows

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





--- Comment #6 from ROb <ro...@googlemail.com>  2009-05-19 10:47:10 PST ---
Created an attachment (id=23693)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23693)
Illustrates the incorrect behaviour

-- 
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 47206] XSSFSheet autoSizeColumn not considering all rows

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


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

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




--- Comment #3 from Yegor Kozlov <ye...@dinom.ru>  2009-05-17 09:51:30 PST ---
I can't reproduce the problem. Both HSSF and XSSF outputs look OK to me. See
attached screenshots. I'm using the latest trunk. 

The Bug report says that the platform is "Windows Vista". Did you run the Java
code on Windows or evaluated results only? If you run Java on *nix, make sure
that the fonts are available. You may need to copy them into
$JAVA_HOME/jre/lib/fonts


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 47206] XSSFSheet autoSizeColumn not considering all rows

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





--- Comment #1 from Yegor Kozlov <ye...@dinom.ru>  2009-05-17 09:44:55 PST ---
Created an attachment (id=23672)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23672)
hssf screenshot

-- 
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