answersLogoWhite

0


Best Answer

The Apache POI project is a Java API to read and write Microsoft Documents.


The API allows you can read and write MS Excel files using Java.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar
More answers
User Avatar

Vinod Raju

Lvl 2
3y ago

I have used below listed libraries for writing/reading excel files in my java project.

Those libraries are supporting even bigger excel files, I am using more than one lakh records for uploading and downloading without any issue.

  • poi-ooxml-3.17.0.wso2v1.jar
  • poi-3.8.jar
  • xmlbeans-2.3.0.jar
  • commons-collections4-4.1.jar

Please find the sample code in Java

import Java.io.FileInputStream;

import Java.io.FileNotFoundException;

import Java.io.IOException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import org.apache.poi.ss.usermodel.Cell;

import org.apache.poi.ss.usermodel.Row;

import org.apache.poi.ss.usermodel.Sheet;

import org.apache.poi.ss.usermodel.Workbook;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelReadColumns {

public static void main(String[] args) {

excelReadColumns("C:\My Projects\TestSample.xlsx");

}

public static String excelReadColumns(String fileName){

String processStatusFlag="NULL";

List longURLList = new ArrayList();

FileInputStream fileInputStream = null;

try {

fileInputStream = new FileInputStream(fileName);

// Using XSSF for xlsx format, for xls use HSSF

Workbook workbook = new XSSFWorkbook(fileInputStream);

Sheet sheet = workbook.getSheetAt(0);

Iterator rowIterator = sheet.iterator();

for (int i = 1; i

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Fetching data from excel sheet from Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How to upload excel sheet data into a MySQL database using JSP and Servlets?

It is very easy to upload excel spreadsheet data into a MySQL database using JSP and servlets. Within Java there is a tool where you can designate the name and location of the file you would like to import. Once you furnish the file name Java server pages will do the work for you.


The process of obtaining a program instruction or data item from memory is called?

Fetching


What is true about Excel checker?

Excel Checker is an Excel add-on that can find every occurrence of cells containing Data Validation or Conditional formatting and list them out on a separate sheet.


Can you sort files in ascending and descending orders?

no only data can be sort from the excel sheet.. not in the file


How do you use the hasNext method in java but not have it block waiting for input?

hasNext() is a method of different classes in Java. If you mean java.util.Iterator.hasNext() or java.util.Scanner.hasNext(), it shouldn't block while waiting for input. That is part of the purpose of the hasNext() method - so that the caller can determine if there is more data without actually fetching the data.


What is a chart sheet in chart in excel?

A chart sheet just shows a chart by itself, so you don't see the data and there are no rows and columns visible.


How do you get nse data in excel sheet?

hopefully your answer can be found hereExcel Tips and Tricks - How to Automatically Download Index Data from NSE - Part One


How do you link data in a row on excel master sheet to row on another sheet on Mac Excel 2011?

Use the name of a sheet, followed by an exclamation mark and a cell reference. The following would take the value in cell C21 on Sheet2 and put it wherever the formula is typed. =Sheet2!C21


How do you transfer data between worksheets in excel for automatic formulas?

To transfer data, enter them in sheet 1, go to sheet 2 and the cell in which you want the linked number to appear and enter the equal "=" sign. Then go back to sheet 1 and the source cell and press Enter.


What is the minimum data value in a data set?

The minimum data value in a data set is simply the lowest value of the set (easily found by arranging the set from lowest-highest values in an excel sheet or by hand).


What is the Excel feature that allows the Excel data sheet to be broken into different columns?

Use the Text to Columns option.Select the column where you have the data you want to split.Go to Data, Text to Columns.Select Delimited.Ensure that the comma checkbox is activated.Select a destination cell (default is current cell).Click Finish.


What is a Datasheet?

The data sheet view in Microsoft SharePoint is a useful tool for quickly editing several list items. It functions similar to an Excel spreadsheet and can be exported to or imported from an Excel spreadsheet.