Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7563761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:44:46+00:00 2026-05-30T13:44:46+00:00

I need java code to read data for specific column from excel sheet. –

  • 0

I need java code to read data for specific column from excel sheet. – (lo number, line, voucher no, stloc , quantity ,activity.)
These set of values for a particular column will be used for sql query (jdbc-odbc connection done).
The output for the query will be matched with a column in this sheet (this part ll be done later)
Kindly help.
sample excel sheet

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:44:47+00:00Added an answer on May 30, 2026 at 1:44 pm
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package excelfilereading;
    
    /**
     *
     * @author vkantiya
     */
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.List;
    import java.util.ArrayList;
    
    public class Main {
    
        @SuppressWarnings("unchecked")
        public static void main(String[] args) throws Exception {
    //
    // An excel file name. You can create a file name with a full
    // path information.
    //
            String filename = "FirstExcel.xls";
    
    
    // Create an ArrayList to store the data read from excel sheet.
    //
            List sheetData = new ArrayList();
    
            FileInputStream fis = null;
            try {
    //
    // Create a FileInputStream that will be use to read the
    // excel file.
    //
                fis = new FileInputStream(filename);
    
    //
    // Create an excel workbook from the file system.
    //
                HSSFWorkbook workbook = new HSSFWorkbook(fis);
    //
    // Get the first sheet on the workbook.
    //
                HSSFSheet sheet = workbook.getSheetAt(0);
    
    //
    // When we have a sheet object in hand we can iterator on
    // each sheet's rows and on each row's cells. We store the
    // data read on an ArrayList so that we can printed the
    // content of the excel to the console.
    //
                Iterator rows = sheet.rowIterator();
                while (rows.hasNext()) {
                    HSSFRow row = (HSSFRow) rows.next();
                    Iterator cells = row.cellIterator();
    
                    List data = new ArrayList();
                    while (cells.hasNext()) {
                        HSSFCell cell = (HSSFCell) cells.next();
                        data.add(cell);
                    }
    
                    sheetData.add(data);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (fis != null) {
                    fis.close();
                }
            }
    
            showExelData(sheetData);
        }
    
        private static void showExelData(List sheetData) {
    //
    // Iterates the data and print it out to the console.
    //
            for (int i = 0; i < sheetData.size(); i++) {
                List list = (List) sheetData.get(i);
                for (int j = 0; j < list.size(); j++) {
                    HSSFCell cell = (HSSFCell) list.get(j);
                    System.out.print(
                            cell.getRichStringCellValue().getString());
                    if (j < list.size() - 1) {
                        System.out.print(", ");
                    }
                }
                System.out.println("");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need code in java for Excel to XML conversion. where Excel sheet will
I need sample code to read rows of data from a mysql table using
I need to ship some Java code that has an associated set of data.
I need to run an external application from within my Java code. I can
In my Android application I need to read a large amount of data from
I need to read the data from a table every minute through thread &
I need the java code snippet for the below logic: Following is a string
I need to convert a python code into an equivalent java code. Python makes
I have existing java code and need to create Design Document based on that.
I need to play a part of an MP3 file in my java code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.