Hi,
I am trying to access Excel Sheet .xlsx files in Java. I have tried various options available from internet. My program is using following jar files:
poi-ooxml-3.5-beta4.jar,
openxml4j-1.0-beta.jar
I have done following imports:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 | import java.io.*;
import java.io.File;
//import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.WorkbookFactory;
//import org.apache.poi.ss.usermodel.Cell;
//import org.apache.poi.ss.usermodel.CellType;
//import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.swing.*;
import java.util.*;
|
I am getting compilation error in the following code (because NetBeans is indicating red bulbs on Line 3 and Line 5):
?
1 2 3 4 5 6 7 8 9 10 11 12 | public void readExcel() {
String FILE_PATH = "D:\\book1.xlsx";
Sheet sheet = null; [b]// Error[/b]
try {
Workbook workbook = WorkbookFactory.create(new File(FILE_PATH)); [b]//Error[/b]
//FileInputStream inputFS = new FileInputStream(FILE_PATH);
//Workbook workbook = WorkbookFactory.create(inputFS);
//sheet = workbook.getSheetAt(0);
}
catch (Exception e) {
}
|
For Sheet, I am getting following error messages:
cannot find symbol
symbol: class Sheet
For Workbook, I am getting following error messages:
cannot find symbol
symbol: class Workbook
no suitable method found for create (String)
method WorkbookFactory.create(POIFSFileSystem) is not applicable
(argument mismatch; String cannot be converted to POIFSFileSystem)
method WorkbookFactory.create(Package) is not applicable
(argument mismatch; String cannot be converted to Package)
method WorkbookFactory.create(InputStream) is not applicable
(argument mismatch; String cannot be converted to InputStream)
Some body please guide me.
Zulfi.