Click here to Skip to main content
15,888,100 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I know that is this question has dozen of answers and posts, but nothing works for me.

We have my MVC4 application and i deployed it to IIS7 to my server and one more machine where we don't have visual studio installed.

We are doing import/export data from/to excel for doing bulk entry.

we do have data around 20000 in one sheet with .xlsx format of Office 2007(File is save as Excel Work book).

Now when i read data by using following code it just read data around 4000-5000 rows only.

This whole below code working fine in my local machine where i do code and read all 20000 rows data from "Excel 97-2003 Workbook with .xls"
but not working with "Excel Workbook with .xlsx".

private void FillDataSet(HttpPostedFileBase file, DataSet ds)
    {
      using (
        var con =
          new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" File Path";Extended Properties=Excel 12.0"))
      {
          con.Open();
          var dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
          var strSheetName = "";
          strSheetName = dtSchema.Rows[0]["TABLE_NAME"].ToString();          
          var cmd = new OleDbCommand();
	  var da = new OleDbDataAdapter();
	  cmd.Connection = con;
	  cmd.CommandType = CommandType.Text;
	  cmd.CommandText = "SELECT * FROM [" + strSheetName + "]";
	  da = new OleDbDataAdapter(cmd);
	  da.Fill(ds);        
      }
    }


I have gone through the below steps and solutions but it's not working for me.

-Installing Microsoft Access Database Engine 2010 Redistributable
-Installing 2007 Office System Driver: Data Connectivity Components


we are confuse why it is working on my local machine and not working on server.
Please provide any idea or solution for this issue..

What I have tried:

I've tried this:
-From the solution explorer right-click your project then click Properties
-Click the Build tab
-Change Platform target from: Any CPU to x86 | Any CPU to x64
-Re-build your solution
-Also made changes on IIS in Advance setting with Enable 32-Bit application as True/False.
Posted
Comments
F-ES Sitecore 21-Jun-17 6:48am    
Would you phone a mechanic and ask "My car isn't working, how do I fix it?" If not then why do you think "not working" gives us enough information to help here?
JatinKhimani 21-Jun-17 7:17am    
Thanks for your concern..
Sorry if i missed anything
but There are 20000 records in Excel which i can able to read from above code in my local machine where i do code.
But when i deploy same dlls on server it is not read all 20000 rows it just read 4000-5000 rows.
More or less it read all 20000 rows when i do save as that excel file "Excel 97-2003 Workbook".

Please let me know if you want more information for this..

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