Import and export using poi

POI structure

        HSSF - Provides the ability to read and write files in Microsoft Excel XLS format.
        XSSF - Provides the ability to read and write Microsoft Excel OOXML XLSX format files.
        HWPF - Provides the ability to read and write Microsoft Word DOC format files.
        HSLF - Provides the ability to read and write files in Microsoft PowerPoint format.
        HDGF - Provides the ability to read Microsoft Visio format files.
        HPBF - Provides the ability to read Microsoft Publisher format files.    
        HSMF - Provides the ability to read files in Microsoft Outlook format.

  get cell value

     private String getCellValue(HSSFCell cell) {  
            String cellValue = "";  
            DecimalFormat df = new DecimalFormat("#");  
            switch (cell.getCellType()) {  
            case HSSFCell.CELL_TYPE_STRING:  
                cellValue = cell.getRichStringCellValue().getString().trim();  
                break;  
            case HSSFCell.CELL_TYPE_NUMERIC:  
                cellValue = df.format(cell.getNumericCellValue()).toString();  
                break;  
            case HSSFCell.CELL_TYPE_BOOLEAN:  
                cellValue = String.valueOf(cell.getBooleanCellValue()).trim();  
                break;  
            case HSSFCell.CELL_TYPE_FORMULA:  
                cellValue = cell.getCellFormula();  
                break;  
            default:  
                cellValue = "";  
            }  
            return cellValue;  
        }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326354718&siteId=291194637