Read an Excel spreadsheet from a file stored on the local filesystem or from some input stream

Read an Excel spreadsheet from a file stored on the local filesystem or from some input stream

Previous Home Next

 

In this tutorial we will learn how to read an Excel spreadsheet from a file stored on the local file system or from some input stream.

For reading an existing workbook, we have to use the jxl.read.biff package, which provides the various methods and interfaces to read the contents of that particular workbook. Also we have to take care of the exception which is caused during the reading of the workbook, i.e. BiffException, which can be done by using the try-catch blocks.
 For opening an existing excel file, first of all we have to open the file in which that particular workbook is contained. After that we can invoke the getWorkbook() method on the Workbook to read the contents of the desired excel file. It can be shown via the following code snippet,

File f1=new File("F:/JAVA PROJECTS/Jexcel/src/r4r/co/in/firstsheet.xls");
            WorkbookSettings ws=new WorkbookSettings();
            ws.setLocale(new Locale("er","ER"));
            Workbook workbook=Workbook.getWorkbook(f1,ws); //opening an existing workbook


 

Previous Home Next