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 9010763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:32:59+00:00 2026-06-16T02:32:59+00:00

I need to read an Excel file that contains 3 sheets and I need

  • 0

I need to read an Excel file that contains 3 sheets and I need to represent the data as follows: each row spans across all 3 sheets, for example

row1 = sheet[0].getRow(1) +  sheet[1].getRow(1) + sheet[2].getRow(1)

Below is what I have done so far but as you can see, the row is defined per sheet, which is wrong, I need this to get data from the other sheets as well. How can this be elegantly done ?

LinkedHashMap<String, List<LinkedHashMap<String, Object>>> records = 
             new LinkedHashMap<String, List<LinkedHashMap<String, Object>>>();
for (int sIndex = 0; sIndex < wb.getNumberOfSheets(); sIndex++) {
                // System.out.println(sIndex);
                Sheet sheet = wb.getSheetAt(sIndex);
                String key;
                String value = null;
                List<LinkedHashMap<String, Object>> sheetRecords = new ArrayList<LinkedHashMap<String, Object>>();
                for (Row row : sheet) {

                    LinkedHashMap<String, Object> record = new LinkedHashMap<>();
                    for (Cell cell : row) {

                        switch (cell.getCellType()) {
                        case Cell.CELL_TYPE_STRING:
                            key = sheet.getRow(sheet.getFirstRowNum())
                                    .getCell(cell.getColumnIndex()).toString();
                            value = cell.getStringCellValue();
                            record.put(key, value);
                            sheetRecords.add(record);
                            break;
                        case Cell.CELL_TYPE_NUMERIC:
                            key = sheet.getRow(sheet.getFirstRowNum())
                                    .getCell(cell.getColumnIndex()).toString();
                            double number = cell.getNumericCellValue();

                            record.put(key, number);
                            sheetRecords.add(record);
                        case Cell.CELL_TYPE_BLANK:
                            break;
                        default:
                            break;
                        }

                    }

                }

                records.put(sheet.getSheetName(), sheetRecords);

            }
  • 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-06-16T02:33:00+00:00Added an answer on June 16, 2026 at 2:33 am

    You’ll have to use the outer for-loop to iterate the rows by index. In pseudo code:

    maxRows := firstSheetInWorkbook->getNumberOfRows();
    for (row := 0..maxRows)
       rowResult := new RowResult
       for (sheet := 0..maxSheets)
          rowResult->add(processRowForSheet(row, sheet))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to read data from XML to a List<>. The XML file contains
I need to read a table in an Excel file starting from 10th row
i need to read data from some excel sheets. The data in the excel
Excel file that is present on the local machine need to be read into
I need to create an excel file via C#. I have read a few
I need to create a script that extracts some data from a complex Excel
I need to retrieve data from an Excel file and insert the data into
I have a WPF-mvvm application. I need to read an excel file..and create a
how to read an excel file and change its column data type to string
I have a program that takes data from an excel file and manipulates it

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.