Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
FirstName
LastName
city
Dist
GeorgeDesh Pune Pune


This is my sample Excel file content.
I want to convert this excel file into following c# Object:
C#
public  class Name
{
 public string FirstName{get;set;}
 public string LastName{get;set;}
}
public  class Address
{
 public string city{get;set;}
 public string Dist{get;set;}
}
public class Employee
{
 public Name empName{get;set;}
 public Address empAddress{get;set;}
}


So how can I convert my Excel file into Employee object?
Posted
Comments
Mehdi Gholam 31-Aug-15 8:04am    
Which part reading form excel or setting properties on the object?
Member 10797183 1-Sep-15 0:17am    
@Mehdi I want to fetch that excel data and fill into c# object of Employee class.

Which will look like :

var objEmp=new Employee()
{
empName = new Name(){ FirstName="George",LastName="Desh"},
empAddress = new Address(){ city="Pune", Dist="Pune"}
}
Sinisa Hajnal 1-Sep-15 6:23am    
Which part is the problem? Reading the excel file? Or you already know how to do that, but not how to "convert" the data? What have you tried? What code have you already written?
sreeyush sudhakaran 2-Sep-15 5:06am    
refer : https://exceldatareader.codeplex.com/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900