I'm trying to extract data from a specific named range in Excel with ASP .NET/C#. Here is an exemple of what I'm trying to extract.
What I want is "B", "C", "D" by using the name "RANGE_NAMED". Is it possible to do this with OleDB ?
Best regards,
Alex.
You could try this code
using(OleDbConnection c = new OleDbConnection(con))
{
c.Open();
string selectString = "SELECT * FROM [RANGE_NAMED]";
using(OleDbCommand cmd1 = new OleDbCommand(selectString))
{
cmd1.Connection = c;
var result = cmd1.ExecuteReader();
while(result.Read())
{
Console.WriteLine(result[0].ToString());
}
}
}
Ok, It's was obvious and I don't know why it didn't work the first time...
SELECT * FROM RANGE_NAMED
And I get B, C, D.