title: Excel creation with POI
body: <p>I was using Apache POI 3.7 to create Excel with <code>HSSF</code>. It was working fine. But during load test, I realized that it is very slow. So I Googled and found I can use <code>SXSSF</code>. I changed my existing code to <code>XSSF</code>. The result was awesome.</p>
  
  <p>But I stuck with a situation, <code>autorezisecolum()</code> is not functioning as expected. It displays large contents as <code>#####</code>, because the column width shrinks. I found it is a kind of a bug already raised.</p>
  
  <p>Now my point is, is there any solution so that i can use <code>SXSSF</code>(very important for performance) with a nice output.</p>
  
  <p>Note: I am using Windows 7, JDK 1.7.09 , POI-3.10.beta-2</p>
  
  <p>Please help me.</p>
  
  <p>Here is my code : </p>
  
  <p>Main Function : </p>
  
  <pre><code>sxssfWorkbook = new SXSSFWorkbook(5);        
  sxssfSheet = (SXSSFSheet) sxssfWorkbook.createSheet(sheetName); 
  try {
      // TO Write Header
      //ew.writeHeaderRow(sheet, headerNames);
      ew.writeHeaderRow(sxssfSheet, headerNames);
      int rowNum = headerRow + 1;
      for(Map.Entry&lt;String, List&lt;Object&gt;&gt; columnData : columnDataMap.entrySet()){
          ew.writeNonHeaderRow(sxssfSheet, columnData.getValue(), rowNum);
          rowNum++;
      }
  resizeXLSXColumns(sxssfSheet,rowNum-1);
  sxssfWorkbook.write(outputStream);
  outputStream.close();
  
  
  
  public void writeHeaderRow(Sheet sheet, List&lt;String&gt; headerNames ) {
  //public void writeHeaderRow(SXSSFSheet sxssfSheet, List&lt;String&gt; headerNames ) {
      // LinkedHashMap&lt;String,Object&gt; mp = getFieldNames(obj);
    //  ArrayList&lt;String&gt; colNames = (ArrayList&lt;String&gt;) getColumnNames();
  
      try {
          XSSFCellStyle hCellStyle = getHeaderStyle();
          SXSSFRow row = (SXSSFRow) sheet.createRow(headerRow);
          for (int hCellInd = 0; hCellInd &lt; headerNames.size(); hCellInd++) {
              SXSSFCell cell = (SXSSFCell) row.createCell(hCellInd);
              cell.setCellStyle(hCellStyle);
              cell.setCellValue(headerNames.get(hCellInd));
              //sheet.autoSizeColumn(hCellInd);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public void writeNonHeaderRow(SXSSFSheet sxssfSheet, List&lt;Object&gt; rowObj, int rowIndex)                     
  {    
  CreationHelper createHelper = sxssfWorkbook.getCreationHelper();        
  try {
          SXSSFRow row = (SXSSFRow)sheet.createRow(rowIndex);
          XSSFCellStyle normalStyle = getNormalStyle();
          int count = 0;
          for (int rCellInd = 0; rCellInd &lt; rowObj.size(); rCellInd++) {
              //Cell cell = row.createCell(rCellInd);
              SXSSFCell cell = (SXSSFCell)row.createCell(rCellInd);
              cell.setCellStyle(normalStyle);
              Object cellData = rowObj.get(rCellInd);
              if (cellData != null) {
                  if (cellData instanceof Double) {                                   
                      cell.setCellValue((Double) cellData);
                      if((Double)cellData &lt; 0){
                          cell.setCellStyle(getNegativeValueStyle());
                      }else if((Double)cellData == 0){
                          normalStyle.setDataFormat((short) SXSSFCell.CELL_TYPE_BLANK) ;
                          cell.setCellStyle(normalStyle);
                      }else
                          cell.setCellStyle(normalStyle);                    
              } else {
                  //normalStyle.setDataFormat((short) HSSFCell.CELL_TYPE_BLANK);
                  cell.setCellType(SXSSFCell.CELL_TYPE_BLANK);
              }
              //sxssfSheet.autoSizeColumn();
              //sxssfSheet.setColumnWidth(rCellInd, sxssfSheet.getColumnWidth(rCellInd));
              //resizeXLSXColumns(sheet);
          }
          //autoResizeColumns(sxssfSheet);
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  public static void resizeXLSXColumns(Sheet sheet ,int rowNum){
  
      SXSSFRow row = (SXSSFRow)sheet.getRow(rowNum);
      Iterator&lt;Cell&gt; itr = row.cellIterator();
      int max = 0;
      while(itr.hasNext()){
          Cell cell = itr.next();
          int width = sheet.getColumnWidth(cell.getColumnIndex());
          if(width &gt; max){
              max = width;
          }
          //sheet.setColumnWidth(cell.getColumnIndex(),max);
      }
      while(itr.hasNext()){
          Cell cell = itr.next();
          sheet.setColumnWidth(cell.getColumnIndex(),max);
      }
  }
  </code></pre>