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

  • Home
  • SEARCH
  • 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 8176731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:18:42+00:00 2026-06-06T23:18:42+00:00

I have read an excel document using apache-poi. The excel document which have records

  • 0

I have read an excel document using apache-poi.
The excel document which have records like:

A1 A2 A3 A4

A1 A2 B3 B4

i want to convert them into JSON arrays like

{ A1 : {A2 : {A3 : {A4 : some_value } } , {B3 : {B4 : some_value } } } }

Actually its easy to convert to XML.
Please tell me how to solve this.
Only hints would suffice.

  • 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-06T23:18:44+00:00Added an answer on June 6, 2026 at 11:18 pm

    You can refer the following code:

    FileInputStream inp = new FileInputStream( file );
    Workbook workbook = WorkbookFactory.create( inp );
    
    // Get the first Sheet.
    Sheet sheet = workbook.getSheetAt( 0 );
    
        // Start constructing JSON.
        JSONObject json = new JSONObject();
    
        // Iterate through the rows.
        JSONArray rows = new JSONArray();
        for ( Iterator<Row> rowsIT = sheet.rowIterator(); rowsIT.hasNext(); )
        {
            Row row = rowsIT.next();
            JSONObject jRow = new JSONObject();
    
            // Iterate through the cells.
            JSONArray cells = new JSONArray();
            for ( Iterator<Cell> cellsIT = row.cellIterator(); cellsIT.hasNext(); )
            {
                Cell cell = cellsIT.next();
                cells.put( cell.getStringCellValue() );
            }
            jRow.put( "cell", cells );
            rows.put( jRow );
        }
    
        // Create the JSON.
        json.put( "rows", rows );
    
    // Get the JSON text.
    return json.toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to read an excel file using POI and then I wanted
I am trying to read an Excel in Perl which have values in format
I have an excel file and I want to read each column and create
I have an Excel document which makes a lot of calculations and shows the
I have exported excel 2007 document as CSV (separated by semicolon). I am using
I'm trying to read data from an Excel document in C# using Microsofts COM
I have an excel spread sheet (well, hundreds of them) which I need importing
I have a perl script read Excel file and parse using a perl module
I need to create an excel file via C#. I have read a few
I have a Excel File, i am able to read single row from Excel

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.