编写xlsx Excel文件时出错。和apache poi

| 我正在打开并在Excel xlsx文件上书写,并且一切正常, 但是当我打开文件查看结果时,这些列没有信息 我期望。 仅前两列具有信息。并且第二第二列没有相应的值。 你能告诉我我的错误在哪里吗? POI上有bug吗? 这是我的代码。
String exceloutp = \"filename.xlsx\"; //File name where to write the values.
             File fileop = new File(exceloutp);
         FileInputStream fs = new FileInputStream(exceloutp);  
         XSSFWorkbook wb = new XSSFWorkbook( fs );

             // get a reference to the worksheet
         XSSFSheet sheet = wb.getSheetAt(0);

             Iterator it = dataResultados.iterator();
             BeanResultadosPaginaFormato27 b = null;
             XSSFCell cell = null;

//Create style for the cells

             XSSFCellStyle normalFormat = wb.createCellStyle();              
             normalFormat.setBorderBottom(CellStyle.BORDER_THIN);
             normalFormat.setBorderTop(CellStyle.BORDER_THIN);
             normalFormat.setBorderLeft(CellStyle.BORDER_THIN);
             normalFormat.setBorderRight(CellStyle.BORDER_THIN);
             normalFormat.setAlignment( CellStyle.ALIGN_LEFT );

             XSSFFont normalFont = wb.createFont();
             normalFont.setFontHeightInPoints((short) 8 );
             normalFont.setFontName(\"Arial\");

             normalFormat.setFont(normalFont);

//end create a style for the cells.                             


//Start filling the cells in every row  width data.
//starting from line 26.

             fila = 26;
             columna = 0;
             while( (fila < 47) &&  ( it.hasNext() ) )
             {
                 columna = 0;
                 b = (BeanResultadosPaginaFormato27) it.next();
                 cell = null;

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getParametro() );//String 1st column

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getUnidad() );//String 2nd column

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getMetodologia() );//String 3rd column

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getUsuario() );//String

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getConcentracion() );//String

                 cell = sheet.getRow(fila).createCell(columna++);
                 cell.setCellType( Cell.CELL_TYPE_STRING );
                 cell.setCellStyle( normalFormat );
                 cell.setCellValue( b.getLimites() ); //String

                 fila++; //Next row.

             }                           

//------End filling cells with data.

//Save the file and open.

             OutputStream out = response.getOutputStream();              
             response.setHeader(\"Pragma\", \"no-cache\");
             response.setContentType(\"application/vnd.ms-excel\");          
             response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"\"+  fileop.getName() +\"\\\"\");

             wb.write(out);
             out.flush();
             out.close();    
看到错误了吗? 谢谢您的帮助。     
已邀请:

bab

        我找到了问题所在。 我没有意识到有合并的列会影响结果。 因此,与其做
cell = sheet.getRow(fila).createCell(columna++);
例如,我将其更改为
cell = sheet.getRow(fila).createCell( 7 );
其中7是该列开始的实际列号。     

要回复问题请先登录注册