讀取xlsl檔案的資料
阿新 • • 發佈:2018-12-20
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); }
}