Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have excel file in that I am doing some calculation, when I take values from user on that values doing calculation, calculated cells I want to show back on web page in gridview, but I am not getting updated values of cells(result) it showing old one.

while debugging if I open excel file and save and close then I am getting updated values of cell so it seems like excel file is not saving.

to update excel I am using OLEDB in C#, ASP.net

here is code snap:

 if (strFileType.Trim() == ".xls")
                {
                    connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Npath + ";Extended Properties='Excel 12.0;HDR=No;'";

                }
                else if (strFileType.Trim() == ".xlsx")
                {
                    connString = "Provider=Microsoft.ACE.OLEDB.8.0;Data Source=" + Npath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";
                }

//Updating data 
//on Calculate Button
conn = new OleDbConnection(connString);
cmd.CommandText = "update [ROLLED SECTION$C5:C5] set F1='" + txtBeamLength.Text + "'";
            cmd.ExecuteNonQuery();
//result 
//on Show result button
string qry = "SELECT * FROM [" + ddlSectionType.Text + "$A20:F25]";
 cmd = new OleDbCommand(qry , conn);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

I am using ASP.net and c # for back end.
Please help me in this I am trying to resolve this issue from long time.....

What I have tried:

Using Interop excel file object its not saving file after uploading site on server and I don't want to show this excel to user.
Posted
Updated 24-Jan-18 0:36am
v3

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