Click here to Skip to main content
15,920,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have a project where i read the excel sheet and show on a grid view which is nicely working from my local system but when i host the application on the server , on the server it is not working.

Is there any solution then please help.
Posted

1 solution

I guess there are 3 steps in your solution.

1. Upload the Excel file to server
2. Use Microsoft.Office.Interop.Excel to read the content of Excel file
3. Populate the data to a GridView



The server needs the Excel to be installed, if you are using Microsoft.Office.Interop.Excel
 
Share this answer
 
Comments
Jimut123456789 15-Nov-13 2:44am    
I have use oledb connection

My code is

OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file_name + ";Extended Properties=Excel 12.0;Persist Security Info=False");
oconn.Open();
OleDbCommand ocmd = new OleDbCommand("select * from [Sheet1$]", oconn);
OleDbDataReader odr = ocmd.ExecuteReader();
string odrc = odr.FieldCount.ToString();
GridView1.DataSource = odr;
GridView1.DataBind();
Panel4.Visible = true;

oconn.Close();
insert();
kookaburracc 15-Nov-13 2:48am    
"Provider=Microsoft.ACE.OLEDB.12.0"
This is a Access provider

O_O
Jimut123456789 15-Nov-13 3:56am    
but it is working on my local system.
kookaburracc 15-Nov-13 3:59am    
Then you wanna to use Server.MapPath() to get the full file path for "Data Source=" + file_name"

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