{"id":5429,"date":"2023-09-22T01:31:51","date_gmt":"2023-09-22T00:31:51","guid":{"rendered":"https:\/\/www.baeldung.com\/java-convert-excel-data-into-list"},"modified":"2023-09-22T01:31:51","modified_gmt":"2023-09-22T00:31:51","slug":"how-to-convert-excel-data-into-list-of-java-objects","status":"publish","type":"post","link":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/2023\/09\/22\/how-to-convert-excel-data-into-list-of-java-objects\/","title":{"rendered":"How To Convert Excel Data Into List Of Java Objects"},"content":{"rendered":"<p><img src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" decoding=\"async\" style=\"float: left; margin-right: 5px;\" loading=\"lazy\" srcset=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png 1024w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-300x157.png 300w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-768x402.png 768w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-100x52.png 100w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured.png 1200w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<h2 id=\"bd-introduction\" data-id=\"introduction\">1. Introduction<\/h2>\n<div class=\"bd-anchor\" id=\"introduction\"><\/div>\n<p>Understanding data mapping is essential in software development. Excel is a widely used data management software, making it crucial for Java developers to know how to map data between Excel and Java objects.<\/p>\n<p>In this tutorial, we&#8217;ll explore converting Excel data into a list of Java objects.<\/p>\n<p>Several Java libraries are available on the Maven repository to work with Excel files in Java, with Apache POI being the most common. However, in this tutorial, <strong>we&#8217;ll use four Java Excel libraries, including Apache POI, Poiji, FastExcel, and JExcelApi (Jxl), to convert Excel data into a Java object list<\/strong>.<\/p>\n<h2 id=\"bd-model-setup\" data-id=\"model-setup\">2. Model Setup<\/h2>\n<div class=\"bd-anchor\" id=\"model-setup\"><\/div>\n<p>To get started, we need to create our object&#8217;s blueprint, the <em>FoodInfo<\/em> class:<\/p>\n<pre><code class=\"language-java\">public class FoodInfo {\r\n    private String category; \r\n    private String name; \r\n    private String measure;\r\n    private double calories; \r\n   \r\n    \/\/ standard constructors, toString, getters and setters\r\n}<\/code><\/pre>\n<h2 id=\"bd-apache-poi\" data-id=\"apache-poi\">3. Apache POI<\/h2>\n<div class=\"bd-anchor\" id=\"apache-poi\"><\/div>\n<p>Apache POI (Poor Obfuscation Implementation) is a Java API for Microsoft documents. <strong>It&#8217;s a collection of pure Java libraries used to read and write data from\/to Microsoft Office files<\/strong> such as Word, Outlook, Excel, and others.<\/p>\n<h3 id=\"bd-1-maven-dependency\" data-id=\"1-maven-dependency\">3.1. Maven Dependency<\/h3>\n<div class=\"bd-anchor\" id=\"1-maven-dependency\"><\/div>\n<p>Let&#8217;s add <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.apache.poi\"><strong>our Maven dependencies<\/strong><\/a> to the <em>pom.xml<\/em> file:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.apache.poi&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;poi&lt;\/artifactId&gt;\r\n    &lt;version&gt;5.2.3&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.apache.poi&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;poi-ooxml&lt;\/artifactId&gt;\r\n    &lt;version&gt;5.2.3&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.apache.poi&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;poi-ooxml-schemas&lt;\/artifactId&gt;\r\n    &lt;version&gt;4.1.2&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<h3 id=\"bd-2-converting-excel-data-into-a-list-of-objects\" data-id=\"2-converting-excel-data-into-a-list-of-objects\">3.2. Converting Excel Data into a List of Objects<\/h3>\n<div class=\"bd-anchor\" id=\"2-converting-excel-data-into-a-list-of-objects\"><\/div>\n<p>By using its <em>Workbook<\/em> interface, we can access various features to read the sheets and cells of an Excel file<b>. This interface has two implementations, one for each Excel format &#8211; <em>HSSFWorkbook<\/em> for<em> .xls<\/em> and <em>XSSFWorkbook<\/em> for <em>.xlsx<\/em>.<\/b><\/p>\n<p>This snippet reads and converts Excel data using the Apache POI library from a <em>.xlsx<\/em> file into a list of <em>FoodInfo<\/em> objects:<\/p>\n<pre><code class=\"language-java\">public static List&lt;FoodInfo&gt; excelDataToListOfObjets_withApachePOI(String fileLocation)\r\n  throws IOException {\r\n    FileInputStream file = new FileInputStream(new File(fileLocation));\r\n    Workbook workbook = new XSSFWorkbook(file);\r\n    Sheet sheet = workbook.getSheetAt(0);\r\n    List&lt;FoodInfo&gt; foodData = new ArrayList&lt;FoodInfo&gt;();\r\n    DataFormatter dataFormatter = new DataFormatter();\r\n    for (int n = 1; n &lt; sheet.getPhysicalNumberOfRows(); n++) {\r\n        Row row = sheet.getRow(n);\r\n        FoodInfo foodInfo = new FoodInfo();\r\n        int i = row.getFirstCellNum();\r\n        foodInfo.setCategory(dataFormatter.formatCellValue(row.getCell(i)));\r\n        foodInfo.setName(dataFormatter.formatCellValue(row.getCell(++i)));\r\n        foodInfo.setMeasure(dataFormatter.formatCellValue(row.getCell(++i)));\r\n        foodInfo.setCalories(row.getCell(++i).getNumericCellValue());\r\n       \r\n        foodData.add(foodInfo);\r\n    }\r\n    return foodData;\r\n}<\/code><\/pre>\n<p><strong>To determine the number of non-empty rows in the <em>sheet<\/em> object, we utilize the <em>getPhysicalNumberOfRows()<\/em> method<\/strong>. We then loop through the rows, excluding the header row (<em>i = 1<\/em>).<\/p>\n<p>Depending on the field of the food object that we need to populate, <strong>we either use the <em>dataFormatter<\/em> object or the <em>getNumericValue()<\/em> method to convert and assign the cell value to the appropriate data type<\/strong>.<\/p>\n<p>Let&#8217;s verify our code by writing a unit test to make sure it works as expected using an Excel file named <em>food_info.xlsx<\/em>:<\/p>\n<div>\n<pre><code class=\"language-java\">@Test\r\npublic void whenParsingExcelFileWithApachePOI_thenConvertsToList() throws IOException {\r\n    List&lt;FoodInfo&gt; foodInfoList = ExcelDataToListApachePOI\r\n      .excelDataToListOfObjets_withApachePOI(&quot;src\\\\main\\\\resources\/food_info.xlsx&quot;);\r\n    assertEquals(&quot;Beverages&quot;, foodInfoList.get(0).getCategory());\r\n    assertEquals(&quot;Dairy&quot;, foodInfoList.get(3).getCategory());\r\n}<\/code><\/pre>\n<\/div>\n<p><b>The Apache POI library offers assistance for both older and newer versions of Excel files, namely <em>.xls<\/em> and <em>.xlsx<\/em>.<\/b><\/p>\n<h2 id=\"bd-poiji\" data-id=\"poiji\">4. Poiji<\/h2>\n<div class=\"bd-anchor\" id=\"poiji\"><\/div>\n<p><strong>Poiji is a thread-safe Java library that provides an API for one-way data mapping from Excel sheets to Java classes<\/strong>. It&#8217;s built on top of the Apache POI library. But unlike Apache POI, it&#8217;s much simpler to use and directly converts each Excel row into a Java object.<\/p>\n<h3 id=\"bd-1-setting-up-the-maven-dependency\" data-id=\"1-setting-up-the-maven-dependency\">4.1. Setting Up the Maven Dependency<\/h3>\n<div class=\"bd-anchor\" id=\"1-setting-up-the-maven-dependency\"><\/div>\n<p>Here&#8217;s <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/com.github.ozlerhakan\/poiji\"><strong>the Poiji Maven dependency<\/strong><\/a> we need to add to the <em>pom.xml<\/em> file:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;com.github.ozlerhakan&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;poiji&lt;\/artifactId&gt;\r\n    &lt;version&gt;4.1.1&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<h3 id=\"bd-2-setting-up-the-class-with-annotations\" data-id=\"2-setting-up-the-class-with-annotations\">4.2. Setting Up the Class with Annotations<\/h3>\n<div class=\"bd-anchor\" id=\"2-setting-up-the-class-with-annotations\"><\/div>\n<p>The Poiji library<b> simplifies Excel data retrieval by requiring class fields to be annotated with either <em>@ExcelCellName(String cellName)<\/em> or <em>@ExcelCell(int cellIndex)<\/em>.<\/b><\/p>\n<p>Below, we&#8217;re setting up our <em>FoodInfo<\/em> class for the Poiji library by adding annotations:<\/p>\n<pre><code class=\"language-java\">public class FoodInfo { \r\n    \r\n    @ExcelCellName(&quot;Category&quot;) \r\n    private String category; \r\n    \r\n    @ExcelCellName(&quot;Name&quot;) \r\n    private String name;\r\n \r\n    @ExcelCellName(&quot;Measure&quot;) \r\n    private String measure;\r\n \r\n    @ExcelCellName(&quot;Calories&quot;) \r\n    private double calories;\r\n \r\n    \/\/ standard constructors, getters and setters \r\n}<\/code><\/pre>\n<p>The API offers support for mapping an Excel workbook that has multiple sheets. When our file has several sheets, <strong>we can employ the <em>@ExcelSheet(String sheetName)<\/em> annotation on our class to indicate which sheet we want to work with. Any other sheets will be disregarded<\/strong>.<\/p>\n<p>However, if we don&#8217;t use this annotation, only the first Excel sheet in the workbook will be taken into account.<\/p>\n<p>In certain situations, we may not need to extract data from every row in the Excel sheet we are targeting. To address this, <strong>we can include a <em>private int<\/em> <em>rowIndex <\/em>property that is annotated with <em>@ExcelRow in our class<\/em>. This will allow us to specify the index of the row items we want to access<\/strong>.<\/p>\n<h3 id=\"bd-3-converting-excel-data-into-a-list-of-objects\" data-id=\"3-converting-excel-data-into-a-list-of-objects\">4.3. Converting Excel Data into a List of Objects<\/h3>\n<div class=\"bd-anchor\" id=\"3-converting-excel-data-into-a-list-of-objects\"><\/div>\n<p><b>Unlike the libraries mentioned in this article, the Poiji library, by default, ignores the header row of the Excel sheet<\/b>.<\/p>\n<p>The following snippet extracts data from an Excel file and converts its data into a list of <em>FoodInfo:<\/em><\/p>\n<pre><code class=\"language-java\">public class ExcelDataToListOfObjectsPOIJI {\r\n    public static List&lt;FoodInfo&gt; excelDataToListOfObjets_withPOIJI(String fileLocation){\r\n        return Poiji.fromExcel(new File(fileLocation), FoodInfo.class);\r\n    }\r\n}<\/code><\/pre>\n<p>The program translates the first Excel sheet of the <em>fileLocation file<\/em> into a <em>FoodInfo<\/em> class<b>. Each row becomes an instance of the <em>FoodInfo<\/em> class, with the cell values representing the object&#8217;s properties. The output is a list of <em>FoodInfo<\/em> objects with a size equivalent to the number of rows (excluding the header row) in the original Excel sheet.<\/b><\/p>\n<p>There are some cases where a password may protect our Excel sheet. We can define the password via <em>PoijiOptionsBuilder<\/em>:<\/p>\n<pre><code class=\"language-java\">PoijiOptions options = PoijiOptionsBuilder.settings()\r\n  .password(&quot;&lt;excel_sheet_password&gt;&quot;).build();\r\nList&lt;FoodInfo&gt; foodData = Poiji.fromExcel(new File(fileLocation), FoodInfo.class, options);<\/code><\/pre>\n<p>To make sure our code works as expected, we write a unit test:<\/p>\n<pre><code class=\"language-java\">@Test\r\npublic void whenParsingExcelFileWithPOIJI_thenConvertsToList() throws IOException {\r\n    List&lt;FoodInfo&gt; foodInfoList = \r\n      ExcelDataToListOfObjectsPOIJI\r\n        .excelDataToListOfObjets_withPOIJI(&quot;src\\\\main\\\\resources\/food_info.xlsx&quot;);\r\n    assertEquals(&quot;Beverages&quot;, foodInfoList.get(0).getCategory());\r\n    assertEquals(&quot;Dairy&quot;, foodInfoList.get(3).getCategory());\r\n}<\/code><\/pre>\n<h2 id=\"bd-fastexcel\" data-id=\"fastexcel\">5. FastExcel<\/h2>\n<div class=\"bd-anchor\" id=\"fastexcel\"><\/div>\n<p><b>FastExcel is an efficient library that utilizes minimal memory and provides high performance for creating and reading basic Excel workbooks in Java. <\/b>It exclusively supports the newer version of Excel files (<em>.xlsx<\/em>) and <strong>has limited features compared to Apache POI.<\/strong><\/p>\n<p>It only reads cell content and does not include graphs, styles, or other cell formatting.<\/p>\n<h3 id=\"bd-1-setting-up-the-maven-dependency-1\" data-id=\"1-setting-up-the-maven-dependency-1\">5.1. Setting Up the Maven Dependency<\/h3>\n<div class=\"bd-anchor\" id=\"1-setting-up-the-maven-dependency-1\"><\/div>\n<p>Below are <strong><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.dhatim\/fastexcel\">the FastExcel<\/a> and <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.dhatim\/fastexcel-reader\">the FastExcel reader Maven dependencies<\/a><\/strong> added to <em>pom.xml<\/em>:<\/p>\n<div>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n      &lt;groupId&gt;org.dhatim&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;fastexcel&lt;\/artifactId&gt;\r\n      &lt;version&gt;0.15.7&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n      &lt;groupId&gt;org.dhatim&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;fastexcel-reader&lt;\/artifactId&gt;\r\n      &lt;version&gt;0.15.7&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<\/div>\n<h3 id=\"bd-2-converting-excel-data-into-a-list-of-objects-1\" data-id=\"2-converting-excel-data-into-a-list-of-objects-1\">5.2. Converting Excel Data into a List of Objects<\/h3>\n<div class=\"bd-anchor\" id=\"2-converting-excel-data-into-a-list-of-objects-1\"><\/div>\n<p><strong>When dealing with large files, the FastExcel reader is a great option despite its limited features<\/strong>. <strong>It&#8217;s easy to use, and<\/strong> <strong>we can access the entire Excel workbook using the <em>ReadableWorkbook<\/em> class.<\/strong><\/p>\n<p>This allows us to retrieve sheets individually, either by name or index.<\/p>\n<p>In the method below, we read data from an Excel sheet and convert it into a list of <em>FoodInfo<\/em> objects:<\/p>\n<pre><code class=\"language-java\">public static List&lt;FoodInfo&gt; excelDataToListOfObjets_withFastExcel(String fileLocation)\r\n   throws IOException, NumberFormatException {\r\n    List&lt;FoodInfo&gt; foodData = new ArrayList&lt;FoodInfo&gt;();\r\n    try (FileInputStream file = new FileInputStream(fileLocation);\r\n      ReadableWorkbook wb = new ReadableWorkbook(file)) {\r\n        Sheet sheet = wb.getFirstSheet();\r\n        for (Row row: sheet.read()) {\r\n            if (row.getRowNum() == 1) {\r\n                continue;\r\n            }\r\n            FoodInfo food = new FoodInfo();\r\n            food.setCategory(row.getCellText(0));\r\n            food.setName(row.getCellText(1));\r\n            food.setMeasure(row.getCellText(2));\r\n            food.setCalories(Double.parseDouble(row.getCellText(3)));\r\n            \r\n            foodData.add(food);\r\n        }\r\n    }\r\n    return foodData;\r\n}<\/code><\/pre>\n<p>Because <strong>the API reads all the rows(including the header row) <\/strong>in the <em>sheet<\/em>, we need to skip the first row(non-zero-based index) when looping through rows.<\/p>\n<p>Accessing a cell is done either by instantiating a <em>Cell<\/em> class: <em>Cell cell = row.getCell()<\/em>, which has two implementations, one that takes an <em>int cellIndex<\/em> and the other a <em>String cellAddress<\/em>(e.g., &#8220;C4&#8221;) arguments. Or by directly getting the data in the cell: e.g., <em>row.getCellText().<\/em><\/p>\n<p>Either way, after extracting each cell&#8217;s content, we need to make sure to cast it, where necessary, to the appropriate <em>food <\/em>object field type.<\/p>\n<p>Let&#8217;s write a unit test to make sure the conversion works:<\/p>\n<pre><code class=\"language-java\">@Test\r\npublic void whenParsingExcelFileWithFastExcel_thenConvertsToList() throws IOException {\r\n    List&lt;FoodInfo&gt; foodInfoList = ExcelDataToListOfObjectsFastExcel\r\n      .excelDataToListOfObjets_withFastExcel(&quot;src\\\\main\\\\resources\/food_info.xlsx&quot;);\r\n    assertEquals(&quot;Beverages&quot;, foodInfoList.get(0).getCategory());\r\n    assertEquals(&quot;Dairy&quot;, foodInfoList.get(3).getCategory());\r\n}<\/code><\/pre>\n<h2 id=\"bd-jexcelapijxl\" data-id=\"jexcelapijxl\">6. JExcelApi\u00a0(Jxl)<\/h2>\n<div class=\"bd-anchor\" id=\"jexcelapijxl\"><\/div>\n<p><strong>JExcelApi\u00a0(or Jxl) is a lightweight Java library for reading, writing, and modifying Excel spreadsheets<\/strong>.<\/p>\n<h3 id=\"bd-1-setting-up-the-maven-dependency-2\" data-id=\"1-setting-up-the-maven-dependency-2\">6.1. Setting Up the Maven Dependency<\/h3>\n<div class=\"bd-anchor\" id=\"1-setting-up-the-maven-dependency-2\"><\/div>\n<p>Let&#8217;s <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/net.sourceforge.jexcelapi\/jxl\"><strong>add the Maven dependency for JExcelApi<\/strong><\/a> to the <em>pom.xml<\/em> file:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;net.sourceforge.jexcelapi&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;jxl&lt;\/artifactId&gt;\r\n    &lt;version&gt;2.6.12&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<h3 id=\"bd-2-converting-excel-data-into-a-list-of-objects-2\" data-id=\"2-converting-excel-data-into-a-list-of-objects-2\">6.2. Converting Excel Data into a List of Objects<\/h3>\n<div class=\"bd-anchor\" id=\"2-converting-excel-data-into-a-list-of-objects-2\"><\/div>\n<p>Though <strong>it only supports the older Excel format(.<em>xls<\/em>) files, <\/strong>the JExcel library offers a range of classes for manipulating Excel files. The <em>Workbook<\/em> class is used to access the list of Excel sheets within the file.<\/p>\n<p>The code below uses the library to convert data from a <em>.xls<\/em> file to a list of <em>FoodInfo<\/em> objects, <em>foodData:<\/em><\/p>\n<pre><code class=\"language-java\">public static List&lt;FoodInfo&gt; excelDataToListOfObjets_withJxl(String fileLocation) \r\n  throws IOException, BiffException {\r\n    List&lt;FoodInfo&gt; foodData = new ArrayList&lt;FoodInfo&gt;();\r\n    Workbook workbook = Workbook.getWorkbook(new File(fileLocation));\r\n    Sheet sheet = workbook.getSheet(0);\r\n    int rows = sheet.getRows();\r\n    for (int i = 1; i &lt; rows; i++) {\r\n        FoodInfo foodInfo = new FoodInfo();\r\n        foodInfo.setCategory(sheet.getCell(0, i).getContents());\r\n        foodInfo.setName(sheet.getCell(1, i).getContents());\r\n        foodInfo.setMeasure(sheet.getCell(2, i).getContents());\r\n        foodInfo.setCalories(Double.parseDouble(sheet.getCell(3, i).getContents()));\r\n        \r\n        foodData.add(foodInfo);\r\n    }\r\n    return foodData;\r\n}<\/code><\/pre>\n<p>Since <strong>the header row is not ignored by the library, we must loop from <em>i = 1<\/em><\/strong>. The sheet object is a zero-based index list of rows.<\/p>\n<p><strong>Retrieving cell data using the JExcel library is quite similar to the FastExcel library. Both libraries use the <em>getCell()<\/em> method with two implementations<\/strong>.<\/p>\n<p>However, in JExcel, this method is directly accessed from a <em>Sheet<\/em> object rather than a <em>Row<\/em> object. Additionally, one of the implementations for the <em>getCell()<\/em> method in JExcel takes two arguments,\u00a0 <em>colNum<\/em> and <em>rowNum<\/em>, both of which are integers:<em> sheet.getCell(colNum, rowNum).<\/em><\/p>\n<p>To make sure the conversion works well, let&#8217;s write a unit test for our method:<\/p>\n<pre><code class=\"language-java\">@Test\r\npublic void whenParsingExcelFileWithJxl_thenConvertsToList()\r\n  throws IOException, BiffException {\r\n    List&lt;FoodInfo&gt; foodInfoList = ExcelDataToListOfObjectsJxl\r\n      .excelDataToListOfObjets_withJxl(&quot;src\\\\main\\\\resources\/food_info.xls&quot;);\r\n    assertEquals(&quot;Beverages&quot;, foodInfoList.get(0).getCategory());\r\n    assertEquals(&quot;Dairy&quot;, foodInfoList.get(3).getCategory());\r\n}<\/code><\/pre>\n<h2 id=\"bd-conclusion\" data-id=\"conclusion\">7. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion\"><\/div>\n<p>In this article, we explored the usage of several libraries, such as Apache POI, Poiji, FastExcel, and JExcelApi, to read and convert data from Excel files into Java objects. However, the choice of which library to use depends on the specific needs, considering the advantages and limitations of each of them.<\/p>\n<p>For instance, we might choose to use the Poiji library if we prioritize the simplest way to just read data from an Excel file and directly convert it into a list of Java objects.<\/p>\n<p>When it comes to performance and simplicity for two-way Excel data mapping in Java, FastExcel, and JExcelApi libraries are excellent options. However, they offer fewer features compared to Apache POI, which is a feature-rich library that supports styles and graphs.<\/p>\n<p>As always, the complete source code for this article is available <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/apache-poi-3\">over on GitHub<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/794276657\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/794276657\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-8-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-convert-excel-data-into-list#respond\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-convert-excel-data-into-list\/feed\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&#160;<\/div>\n\n<h2><b>Commercials Cooperation Advertisements:<\/b><\/h2>\r\n<p><br>(1) IT Teacher IT Freelance<br> <\/p>\r\n<a href=https:\/\/itteacheritfreelance.hk\/wordpress><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITTeacherITFreelance-Website.png alt=IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\/><\/a><p><a href=https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/findteacher>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427! <\/a><br>\r\n\r\n\u7535\u5b50\u8ba1\u7b97\u673a -\u6559\u80b2 -IT \u96fb\u8166\u73ed\u201d ( IT\u96fb\u8166\u88dc\u7fd2 ) \u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u7535\u5b50\u8ba1\u7b97\u673a \u6559\u80b2\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u4fe1\u606f\u6280\u672f, \u96fb\u8166 \u8001\u5e2b, IT freelance \u548c programming expert. \u8b93\u5927\u5bb6\u65b9\u4fbf\u5730\u5c31\u80fd\u627e\u5230\u5408\u9069\u7684\u96fb\u8166\u88dc\u7fd2, \u96fb\u8166\u73ed, \u5bb6\u6559, \u79c1\u4eba\u8001\u5e2b.  <br>\r\n\r\nWe are a education and information platform which you can find a IT private tutorial teacher or freelance. <br>\r\n\r\nAlso we provide different information about information technology, Computer, programming, mobile, Android, apple, game, movie, anime, animation\u2026 \r\n<\/p>\n<p><br>(2) ITSec<br> <\/p><a href=https:\/\/itsec.vip><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITSec-Main-Promotion-Image.png alt= https:\/\/itsec.vip\/\r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers.  \r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training.\/><\/a> \r\n<br><br> \r\n<p><a href=https:\/\/itsec.vip>www.ITSec.vip<\/a> <br> <br> \r\n<p><a href=https:\/\/sraa.com.hk>www.Sraa.com.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itsec.hk>www.ITSec.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/penetrationtest.hk>www.Penetrationtest.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itseceu.uk>www.ITSeceu.uk<\/a> <br> <br> \r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers. <br><br>\r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training. \r\n<br><br>Contact us right away. <br><br>Email (Prefer using email to contact us): <br>SalesExecutive@ITSec.vip<\/p>","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" loading=\"lazy\"><\/p>\n<p>Learn about the usage of several libraries, such as Apache POI, Poiji, FastExcel, and JExcelApi, to read and convert data from Excel files into Java objects.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>\u00a0<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/794276657\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-8-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>\u00a0<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>\u00a0<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>\u00a0<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/794276657\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>\u00a0<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-convert-excel-data-into-list#respond\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>\u00a0<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-convert-excel-data-into-list\/feed\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>\u00a0<\/div>\n","protected":false},"author":259,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[22],"tags":[61,122,127,129,124,128,125,132,131,133,126,130,123,66,94,88,97,56,64,65,60,112,40,75,95,104,33,120,105,101,98,115,30,29,41,86,70,69,68,72,71,26,118,108,87,46,55,48,52,54,51,50,83,62,58,57,2484,2485,109,35,59,63,85,79,82,96,80,27,81,114,44,42,43,45,38,39,110,117,100,111,116,73,89,90,92,91,93,84,78,37,102,34,36,77,67,74,99,113,119,28,121,32,47,49,53,103,31,76],"class_list":["post-5429","post","type-post","status-publish","format-standard","hentry","category-mobile","tag-airpods","tag-anime","tag-anime-characters","tag-anime-cosplay","tag-anime-edits","tag-anime-merchandise","tag-anime-movies","tag-anime-news","tag-anime-recommendations","tag-anime-reviews","tag-anime-series","tag-anime-streaming","tag-animes","tag-app-store","tag-app-store-samsung","tag-appgallery","tag-appgallery-oneplus","tag-apple","tag-apple-music","tag-apple-tv","tag-apple-watch","tag-bbc-sport","tag-best-mobile-games","tag-bixby","tag-bixby-xiaomi","tag-champions-league","tag-cyberpunk","tag-cyberpunk-2077","tag-fantasy-football","tag-fifa","tag-football","tag-formula-1","tag-fortnite","tag-free-fire","tag-free-mobile-games","tag-freebuds-pro","tag-galaxy-a52","tag-galaxy-note-20","tag-galaxy-s21","tag-galaxy-watch-4","tag-galaxy-z-fold-3","tag-game","tag-games","tag-golf","tag-harmonyos","tag-how-to-backup-iphone","tag-how-to-factory-reset-iphone","tag-how-to-reset-iphone","tag-how-to-restore-iphone","tag-how-to-unlock-iphone","tag-how-to-unlock-iphone-5","tag-how-to-unlock-iphone-6","tag-huawei","tag-ios","tag-ipad","tag-iphone","tag-java-collections","tag-java-list","tag-live-soccer","tag-lol","tag-macbook","tag-macos","tag-mate-40-pro","tag-mi-11-lite","tag-mi-home-security-camera-basic-1080p","tag-mi-home-security-camera-basic-1080p-huawei","tag-mi-smart-band-6","tag-minecraft","tag-miui","tag-mlb-scores","tag-mobile-game-design","tag-mobile-game-development","tag-mobile-game-marketing","tag-mobile-game-monetization","tag-mobile-games","tag-mobile-gaming","tag-nba-scores","tag-nba-standings","tag-nfl","tag-nfl-scores","tag-nhl-scores","tag-one-ui","tag-oneplus","tag-oneplus-9-pro","tag-oneplus-buds-pro","tag-oneplus-nord-ce-5g","tag-oxygenos","tag-p40-pro-plus","tag-poco-x3-pro","tag-pokemon","tag-premier-league","tag-pubg","tag-pubg-mobile","tag-redmi-note-10-pro","tag-samsung","tag-samsung-pay","tag-soccer","tag-sports","tag-steam","tag-steeam","tag-top-10-anime","tag-valorant","tag-when-do-the-iphone-7-come-out","tag-when-does-the-iphone-7-come-out","tag-when-is-the-iphone-7-coming-out","tag-world-cup","tag-xbox-series-x","tag-xiaomi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/users\/259"}],"replies":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/comments?post=5429"}],"version-history":[{"count":1,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5429\/revisions"}],"predecessor-version":[{"id":5430,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5429\/revisions\/5430"}],"wp:attachment":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/media?parent=5429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/categories?post=5429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/tags?post=5429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}