I'm working with eeplus and I'm having some problems when it comes to importing information
>To use as an example, I have an excel document with the following characteristics:
A |B |C |D
1 |Id | Nombre | Apellido
2 |0 | Juan | Martinez
3 |1 | Jorge | Perez
And I would like to obtain a list that will adapt, for example, to the following:
class Persona
{
string Id { get; set; }
string Apellido { get; set; }
}
I managed to get closer by doing something like the following
var m = xls.Workbook.Worksheets.FirstOrDefault(x => x.Name == "Hoja1")
.Cells.Where(x => (x.Address.StartsWith("A") && x.Address.Length==2 ) ||
(x.Address.StartsWith("C") && x.Address.Length==2));
The problem is that in this way I get an object of type ExcelRange
, where when going through each cell, I have a value, independently of the row to which it belongs
In this way, I can go through it with a foreach
and go adding elements to the list, although I am sure that it is not the correct method to reach the result I am looking for ..
What would be the right way to get to what I'm looking for?
Thank you very much!
EDITO
To make the problem clearer ... I am looking for the following (Implemented with LinqToExcel
):
var Lista = book.Worksheet("Hoja1").Select(x => new
{
Id = x["Id"],
Apellido = x["Apellido"]
});
But without LinqToExcel
, because it should be functional in pc, which will not have Office
Greetings!