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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:10:07+00:00 2026-06-15T01:10:07+00:00

I am reading excel file using jxl library.But I am facing a problem when

  • 0

I am reading excel file using jxl library.But I am facing a problem when i want add the cell content into pojo class property . such I have Employee class;

public class Employee {

    private String id;
    private String name;
    private String email;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }




}



public static void read(String path) throws IOException {
        File inputWorkbook = new File(path);
        Workbook w;
        String[] excel_data  = new String[3]; 
        try {
            w = Workbook.getWorkbook(inputWorkbook);
            // Get the first sheet
            Sheet sheet = w.getSheet(0);
            // Loop over first 10 column and lines

            Vector<Employee> data = new Vector<Employee>();
            for (int j = 1; j < sheet.getRows(); j++) 
              { 

                          Employee emp = new Employee()
               for (int i = 0; i < sheet.getColumns(); i++) 
               { 
                   Cell cell = sheet.getCell(i, j);
                 //  d.add(cell.getContents());
                               emp.setId(cell.getContents());
                              emp.setName(cell.getContents());
                              emp.setEmail(cell.getContents());
                }
                 //  d.add("\n");
                   data.add(emp);   

                //insertEmployee(emp);
            }

here my code i can add cell content into vector object. but i want set cell content value into Employee class property.Please tell how I achieve this.I am not getting right value from emp object.What I was doing wrong in my code when i adding content into list

  • 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-15T01:10:09+00:00Added an answer on June 15, 2026 at 1:10 am

    You will have to set the values manually.

    You can write a switch statement and set the values for each column index like this:

    List<Employee> employees = new ArrayList<Employee>();
    ...
    Employee emp = new Employee();
    for (int i = 0; i < sheet.getColumns(); i++) 
    { 
        Cell cell = sheet.getCell(i, j);
        switch (i) {
        // column 0 = ID
        case 0:
            emp.setId(cell.getContents());
            break;
        // column 1 = Name
        case 1:
            emp.setName(cell.getContents());
            break;
        // column 2 = Email
        case 2:
            //... etc
            break;
        }
    
    }
    employees.add(emp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am reading an excel file using this code i found over the net:
I am using Microsoft.Office.Interop.Excel in a winform where I am reading one excel file,
I am having an problem, while java application reading Excel file .xlsx extention, The
I'm reading an Excel file with OLDB Connection using this code var connectionString =
I have a weird problem with reading .xls file using OleDbDataReader . Basically, it
I am reading an Excel file using good old OleDBConnections and OleDBCommands. How do
Hi I want to parse an excel file using zend framework. I went to
I am now using PyExcelerator for reading excel files, but it is extremely slow.
I want to read ms excel file from Ftp server(not in my network) using
I am reading an Excel file using xlrd . In one column I have

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.