I am trying to use Apache POI to process some excel document.
I am trying to just come up with a simple test to make sure I set up the package correctly, by compiling and running the test code found on the quick guide page: Busy Developers' Guide to HSSF and XSSF Features
I need to make imports. According to the documentation (http://poi.apache.org/apidocs/index.html) and also I went into apache poi's src / jar directory,
I have to import:
import org.apache.poi.ss.usermodel.*;
The problem is : WorkbookFactory is located in the .jar file poi-ooxml-3.8-20120326.jar,
and other major classes are located in poi-3.8-20120326.jar
both jar files have exactly the same directory structure.
I put both .jar files in classpath, and with my import statement, I get the following error:
testRead.java:3: cannot find symbol
symbol : class WorkbookFactory
location: package org.apache.poi.ss.usermodel
import org.apache.poi.ss.usermodel.WorkbookFactory;
^
testRead.java:14: cannot find symbol
symbol : variable WorkbookFactory
location: class testRead
Workbook wb = WorkbookFactory.create(inp);
^
2 errors
What could I do to get the compilation?
I am trying to just come up with a simple test to make sure I set up the package correctly, by compiling and running the test code found on the quick guide page: Busy Developers' Guide to HSSF and XSSF Features
Code:
InputStream inp = new FileInputStream("workbook.xls");
//InputStream inp = new FileInputStream("workbook.xlsx");
Workbook wb = WorkbookFactory.create(inp);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);
if (cell == null)
cell = row.createCell(3);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("a test");
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
I need to make imports. According to the documentation (http://poi.apache.org/apidocs/index.html) and also I went into apache poi's src / jar directory,
I have to import:
import org.apache.poi.ss.usermodel.*;
The problem is : WorkbookFactory is located in the .jar file poi-ooxml-3.8-20120326.jar,
and other major classes are located in poi-3.8-20120326.jar
both jar files have exactly the same directory structure.
I put both .jar files in classpath, and with my import statement, I get the following error:
testRead.java:3: cannot find symbol
symbol : class WorkbookFactory
location: package org.apache.poi.ss.usermodel
import org.apache.poi.ss.usermodel.WorkbookFactory;
^
testRead.java:14: cannot find symbol
symbol : variable WorkbookFactory
location: class testRead
Workbook wb = WorkbookFactory.create(inp);
^
2 errors
What could I do to get the compilation?