public Sheet getc(int num,String FilePath) {
Workbook workbook;
Sheet sheet=null;
try {
File file = new File(FilePath);
if (!file.exists()) {
throw new RuntimeException("文件不存在");
}
InputStream inputStream = null;
inputStream = new FileInputStream(file);
workbook = new XSSFWorkbook(inputStream);
//num=第几个sheet表
sheet=workbook.getSheetAt(num);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return sheet;
}
public void get_value(){
Sheet sheet =getc(0,"ddddd");
// //获取第一行
// Row row1 = sheet.getRow(0);
// //第一行第一列
// Cell cell0 = row1.getCell(0);
// //第一行第二列
// Cell cell1 = row1.getCell(1);
// System.out.println(cell1.toString());
// //获取第二行
// Row row2= sheet.getRow(1);
// //第二行第1列
// Cell cell2_1=row2.getCell(0);
// System.out.println(cell2_1.toString());
}
java通过poi读取excel文件
最新推荐文章于 2024-05-01 23:10:25 发布