Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Introduction To Apache POI – The Java API To Read Write Microsoft Documents – Excel

Posted on 02/19/2025 By admin

Apache POI provides pure Java libraries for reading and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel. It has different components for reading and writing different Microsoft Office files:

  1. POIFS for OLE 2 Documents
  2. HSSF and XSSF for Excel Documents
  3. HWPF and XWPF for Word Documents
  4. HSLF and XSLF for PowerPoint Documents
  5. HPSF for OLE 2 Document Properties
  6. HDGF and XDGF for Visio Documents
  7. HPBF for Publisher Documents
  8. HMEF for TNEF (winmail.dat) Outlook Attachments
  9. HSMF for Outlook Messages

Hope now you get to understand that Apache POI is not only to read and write Excel sheet. It provides different components to read different Microsoft office files. So, if interviewer asks you that how you read an excel file in Java, your answer should be – ” We use HSSF and XSSF component provided by Apache POI to read and write excel in Java”.

You will find excel with two extensions:-

  1. .xls ( Microsoft Excel 2003 file )
  2. .xlsx (Microsoft Excel 2007 file or later )

Apache POI provides different components for each type of extension of excel, which are given below:

  1. .xls – HSSF ( Horrible SpreadSheet Format )- You need to download “poi” jar files.
  2. .xlsx – XSSF ( XML SpreadSheet Format )- You need to download “poi-ooxml ” jar files.

If you do not want to read write excel based on its extension, you can use common spreadsheet usermodel which requires poi-ooxml and core poi libraries. Common spreadsheet is used widely now as it can read excel with any extension with same lines of code. No worries of using HSSF or XSSF for workbook and sheet.

Let’s update answer of above discussed question:

So, if interviewer asks you that how you read an excel file in Java, your answer should be – ” We use HSSF, XSSF or Common spreadsheet (SS) usermodel provided by Apache POI to read and write excel in Java”. Common SS usermodel can read/write excel with both extensions .xls and .xlsx.

In next post, we will explore more about it. Stay tuned.

In case of any doubt, suggestion or you find some mistake, feel free to let me know in comments.

#ThanksForReading

#DonateIfYouThinkMyPostsHelpYou

Uncategorized

Post navigation

Previous Post: TestNG Tutorials 29: Grouping Configuration Methods in TestNG
Next Post: REST Assured Tutorial 34 – Serialization – Java Object To JSON Object Using Gson API

Related Posts

ScrollInToView1 – Make Selenium Easy Uncategorized
window – Make Selenium Easy Uncategorized
Learn Selenium With Quiz – Basic Level 8 – CSS Selector Uncategorized
REST Assured Tutorial 73 – How to ignore node/s for JSON comparison in JSONassert Uncategorized
jackson api tutorial Uncategorized
API Testing – Postman Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark