whyclxw
2024-02-29 0ddeae63c5ec1397b3cac2664e25b97ae2218568
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.lxw.test3d.Service;
 
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
 
public class Workexecise {
    public static void main(String[] args) throws IOException {
 
        FileInputStream in = null;
        Workbook workBook=null;
        try {
            in = new FileInputStream(new File("E:\\ffmpeg\\2.xls"));
            workBook= new XSSFWorkbook(in) ;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        Sheet sheet0 = workBook.getSheetAt(0);// 获取Sheet工作簿
        Row row = sheet0.getRow(0);// 获取行
        Cell cell = row.getCell(0);
        String str = cell.getStringCellValue();// 如果单元格中的数据时字符串
        double num = cell.getNumericCellValue();// 如果单元格中的数据时数字
        System.out.println(str);
 
    }
}