Hi,

I'm currently using apache 3.1 and I have made a java program that lets you
enter any query into a form and gives you a spreadsheet back.

I'd like to make it resize all of the columns after it is done making the
spreadsheet, but when I do this it makes the first column gigantic and
doesn't resize the other ones correctly either.

Here is the code for the printing and resizing:

HSSFRow headerRow = sheet.createRow(1);
                        //gathers header data and writes to workbook
                        for (int i=0; i<numberOfColumns; i++)
                        {
                                String header = rsMetaData.getColumnName(i+1);
                                HSSFCell cell = headerRow.createCell((short)i);
                                cell.setCellValue(header);
                        
                        }
                        
                        while (rs.next()) 
                        {
                                
                                HSSFRow row 
=sheet.createRow((short)rs.getRow()+2);
                                //gathers row results and writes to workbook
                                for (int j=0; j<numberOfColumns; j++)
                                {
                                        String st = rs.getString(j+1);
                                        HSSFCell cell =row.createCell((short)j);
                                        cell.setCellValue(st);
                                
                                }
                                
                        }
                        rs.close();
                
                        //resizes columns 
                        for (int k=0; k<numberOfColumns; k++)
                        {
                                sheet.autoSizeColumn((short)k);
                        }
                        
        

</raw>


Manually resizing isn't really an option as it is meant to take any query. I
have also tried putting the autosize logic right after the headers are made
and I get the same results. 

Any help is appreciated. 


--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/HSSF-Autosize-Column-Producing-Huge-1st-Column-POI-3-1-tp4613320p4613320.html
Sent from the POI - User mailing list archive at Nabble.com.

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

Reply via email to