1. 程式人生 > >讀取xlsl檔案的資料

讀取xlsl檔案的資料

package com.sxf;

import java.io.FileInputStream; import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReadExcel { @SuppressWarnings(“resource”) public static void main(String[] args) throws IOException {

 XSSFWorkbook excelbook;
 XSSFSheet excelSheet;
 XSSFCell cell;
 
 String path="C:\\Users\\20433\\Desktop\\demo.xlsx";
 String sheetName="info";
 FileInputStream excelfile=new FileInputStream(path);
 excelbook=new XSSFWorkbook(excelfile);
 excelSheet=excelbook.getSheet(sheetName);
 cell=excelSheet.getRow(0).getCell(0);
 String data=cell.getStringCellValue();
 System.out.println(data);
}

}