try {
                File file = new File(path);
                FileInputStream is =new FileInputStream(file);
                FileOutputStream  outputStream = new FileOutputStream(file);
                XSSFWorkbook workbook = new XSSFWorkbook(is);
                int index = workbook.getSheetIndex("Sheet1");
                XSSFSheet xssfSheet;
                if(index < 0)
                {
                        xssfSheet = workbook.createSheet();
                }
                else
                {
                  xssfSheet = workbook.getSheetAt(index);
                }
                XSSFRow xssfRow = xssfSheet.getRow(0);
                
                if(null == xssfRow)
                {
                        xssfRow = xssfSheet.createRow(0);
                }
                XSSFCell cell;
                
                XSSFCellStyle style = workbook.createCellStyle();
                style.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
                style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
                
                if(xssfRow.getLastCellNum() == -1)
                        cell = xssfRow.createCell(0);
                else
                        cell = xssfRow.createCell(xssfRow.getLastCellNum());
                
                cell.setCellType(XSSFCell.CELL_TYPE_STRING);
                cell.setCellValue("Result");
                cell.setCellStyle(style);
                /*
                for(int  i = 1 ; i<rowCount ; i++ )
                {
                        xssfRow = xssfSheet.getRow(i);
                        cell = xssfRow.createCell(3);
                        cell.setCellType(XSSFCell.CELL_TYPE_STRING);
                        cell.setCellValue("pass");
                }
                */
                        workbook.write(outputStream);
                        outputStream.flush();
                        outputStream.close();
                        is.close();
                } catch (IOException e) {
                        // TestExcel
                        e.printStackTrace();
                } catch (Exception e) {
                
                        e.printStackTrace();
                }
        

This is my code but still i'm getting the above exception. Can any one
please help me in this issue



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/org-apache-poi-POIXMLException-org-apache-poi-openxml4j-exceptions-InvalidFormatException-Package-sh-tp5711375p5714719.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