Read excel with a large number of columns in C #

0

Hello dear developers, I have a small problem, it turns out that I am reading excel sheets in a console program and I play an excel that has a lot of columns (Until the column ABT) and my excel dataset only reads up the column WZ and I do not know how to get him to read the whole sheet without leaving any column out. I have to do it in OLEDB because of my client's license issues. Here the code

OleDbConnection Econ;
Econ = new OleDbConnection(constr);
string qTotal = string.Format("Select * from[Sheet1$]");
string qTotalvalores = string.Format("Select * from[Sheet1$A12:ABT755]");
OleDbCommand ETotal = new OleDbCommand(qTotal, Econ);
OleDbCommand Etotal2 = new OleDbCommand(qTotalvalores, Econ);

termino = termino + 1;

Econ.Open(); //al procesar el archivo n° 120 //Se cae la conexion en Econ.Open();

// Creacion de Dataset para cada uno de los contructores
DataSet dsTotal = new DataSet();
DataSet dsTotal2 = new DataSet();
OleDbDataAdapter odaTotal = new OleDbDataAdapter(qTotal, Econ);
OleDbDataAdapter odaTotal2 = new OleDbDataAdapter(qTotalvalores, Econ);

Econ.Close();
    
asked by Joel Baez 12.11.2018 в 20:07
source

1 answer

-1

Can not read more than 256 columns with OLED, it is limited. One option is to split the table into several ranges of columns and then queries by ranges such as Select * From RangeName

The other option is to use ExcelDataReader DLL It is an open source library used to read Microsoft Excel files in .NET link

PD. I respond as an answer because with my score I still can not comment, just answer. I trust that I will not be penalized

    
answered by 12.11.2018 в 20:27