保存excel文件的问题,没有在gridview中获取excel文件的更新值 [英] Problem to save excel file, not getting updated value of excel file in gridview

查看:92
本文介绍了保存excel文件的问题,没有在gridview中获取excel文件的更新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有excel文件,因为我正在进行一些计算,当我从用户那里获取值进行计算时,计算出的单元格我想在gridview的网页上显示,但我没有得到更新的单元格值(结果)它显示旧的。



调试时如果我打开excel文件然后保存并关闭然后我得到更新的单元格值,所以好像excel文件不是保存。



更新excel我在C#,ASP.net中使用OLEDB



这里是代码snap:



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.

推荐答案

C5:C5]设置F1 ='+ txtBeamLength.Text +';
cmd.ExecuteNonQuery();
//结果
// on显示结果按钮
string qry =SELECT * FROM [+ ddlSectionType.Text +
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();

我使用ASP.net和c#作为后端。
请帮助我,我试图解决这个问题从很长一段时间.....

我尝试过:

使用Interop excel文件对象在服务器上传网站后不保存文件,我不想向用户显示此excel。
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.


这篇关于保存excel文件的问题,没有在gridview中获取excel文件的更新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆