0

Here is my code part:

public static DataSet GetExcelTable(string FilePath, string Extension,string isHDR,string Sheetname=null)
{
    DataSet ds = new DataSet();
    DataSet dsData = new DataSet();
    ds.DataSetName = Path.GetFileName(FilePath);
    string conStr = "";
    conStr=ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString;
    conStr = String.Format(conStr, FilePath, isHDR);
    OleDbConnection connExcel = new OleDbConnection(conStr);
    OleDbCommand cmdExcel = new OleDbCommand();

    cmdExcel.Connection = connExcel;
    connExcel.Open();
}

My connection string is:

<add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'" />

Note: it's working fine for less than 10Mb files. Error occurs only when file size is greater than 10Mb, uploading file type is .xls & shows error on connExcel.Open();

Please provide me a solution for it. Thanks in advance.

ad1Dima
  • 3,185
  • 2
  • 26
  • 37
  • Possible duplicate of [Excel "External table is not in the expected format."](http://stackoverflow.com/questions/1139390/excel-external-table-is-not-in-the-expected-format) – SiD Feb 09 '16 at 05:45
  • It's working for me for <10Mb files but for large not working so I have posted again. – Waseem Akram Feb 09 '16 at 05:48
  • You know that Excel has a row limit, right? 64K rows for 2003 and earlier, 1M rows for 2007 and later. It's possible to construct your own files with more records than that, but official tools (Excel, Jet, Ace, and Ole) will choke on them. With 10MB files using the .xls format instead of .xlsx, it's conceivable you're over the limit. – Joel Coehoorn Feb 09 '16 at 06:16
  • ok, I got it. Thankyou Joel Coehoom. Actually, I have created file with .ods extension with 1M rows & then save as .xls. so, I forgot that for .xls files max rows limit is 64k. btw thanks again. – Waseem Akram Feb 09 '16 at 13:44

0 Answers0