构造函数XSSFWorkbook(FileInputStream)未定义

时间:2016-04-05 18:05:49

标签: java excel apache-poi

我试图从excel文件中读取数据,我使用以下代码:

    File Excel = new File("C:\\Users\\data.xlsx");
    FileInputStream fis = new FileInputStream(Excel);

    XSSFWorkbook wb = new XSSFWorkbook(fis);

但是我得到了编译错误 构造函数XSSFWorkbook(FileInputStream)未定义

2 个答案:

答案 0 :(得分:0)

尝试这个 它对我的工作 成功.........

at GeoFirePoint.get [as geoPoint] (/srv/node_modules/geofirex/dist/index.cjs.js:1390:43)
    at GeoFirePoint.get [as data] (/srv/node_modules/geofirex/dist/index.cjs.js:1411:32)
    at exports.bgLocation.functions.https.onRequest (/srv/lib/index.js:590:101)
    at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:49:9)
    at /worker/worker.js:783:7
    at /worker/worker.js:766:11
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

尝试{



try (FileInputStream file = new FileInputStream(new File(filename))) {
                **Workbook workbook = WorkbookFactory.create(file);**




`

答案 1 :(得分:-1)

public static void setExcelFile(String Path, String SheetName) throws IOException, InvalidFormatException {
        try {

            // Open the Excel file

            FileInputStream ExcelFile = new FileInputStream(Path);

            // Access the required test data sheet

            ExcelWBook = new XSSFWorkbook("C:\\Users\\data.xlsx");
            ExcelWSheet = ExcelWBook.getSheet(SheetName);

        } catch (Exception e) {

            throw (e);

        }

    }