Apache POI XSSF reading in excel files

前端 未结 8 2111
北恋
北恋 2021-02-13 00:00

I just have a quick question about how to read in an xlsx file using the XSSF format from Apache.

Right now my code looks like this:

InputStream fs = ne         


        
8条回答
  •  忘掉有多难
    2021-02-13 00:38

    public class ExcelReader{
       public String path;
       public static FileInputStream fis;
    
       public ExcelReader(){
          System.out.println("hello");
       }
    
       public ExcelReader(String path){
          this.path=path;
          fis=new FileInputStream(path);
          XSSFWorkbook workbook=new XSSFWorkbook(fis);
          XSSFSheet sheet=workbook.getSheet("Sheet1");//name of the sheet
          System.out.println(sheet.getSheetName());
          System.out.println(sheet.getLastRowNum());
          System.out.println(sheet.getRow(2).getCell(3));
      }
      public static void main(String[] args) throws IOException {
          ExcelReader excel=new ExcelReader("path of xlsx");
      }
    }
    

提交回复
热议问题