Showing posts with label SeleniumOnExcel. Show all posts
Showing posts with label SeleniumOnExcel. Show all posts

Read/Write .xls and .xlsx with one set of code using POI - WorkbookFactory

As we discussed in earlier post Read/Write excel using Apache POI,
we have to use:
For handling .xls fileswe use HSSF (Horrible SpreadSheet Format) related POI classes.
For handling .xlsx files, we use XSSF (XML SpreadSheet Format) related POI classes.


On this post, how we can perform excel operations with one set code for both excel formats .xls and .xlsx.
For this we have a class provided from Apache POI WorkbookFactory, which auto detects appropriate kind of Workbook (HSSFWorkbook or XSSFWorkbook) depending on the excel formats .xls or .xlsx.
Let's jump to the code implementation