使用文本框更新Excel文件 [英] Updating an Excel File using a Textbox

查看:106
本文介绍了使用文本框更新Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我可以使用oledataadapter和文本框从excel文件中的单个单元格中提取数据。但是,当我使用文本框更改数据时,更改不会保存到Excel文件。下面是我的代码,如果有人能弄明白我如何保存文本框中的更改,我会欣喜若狂!

 MyCommand1 =  OleDbDataAdapter(  select * from [myWorksheet $ B3:B4],MyConnection)

ds1 = New System.Data.DataSet()
MyCommand3.Fill(ds1)






' ---这是向文本框显示数据的代码,
但是我还没有想出如何将数据保存回excel文件'
TextBoxView1。 Text = ds1.Tables( 0 )。行( 0 )( 0 )。ToString

解决方案

B3:B4],MyConnection)

ds1 = System.Data.DataSet()
MyCommand3.Fill(ds1)






' ---这是将数据显示到文本框的代码,
' 但是我还没有想出如何将数据保存回excel文件'
TextBoxView1.Text = ds1 .Tables( 0 )。行( 0 )( 0 )。的ToString


Right now I'm able to pull in data from a single cell in an excel file using the oledataadapter and a textbox. However when I change the data using the textbox the changes don't save to the excel file. Here is my code below, if anyone can figure out how I might save the changes made from the textbox I would be ecstatic!

MyCommand1 = New OleDbDataAdapter("select * from [myWorksheet$B3:B4]", MyConnection)

        ds1 = New System.Data.DataSet()
        MyCommand3.Fill(ds1)

        


       

        '---This is the code to display the data to the textbox,
        'however I still haven't figured out how to save the data back to the excel file'
        TextBoxView1.Text = ds1.Tables(0).Rows(0)(0).ToString

解决方案

B3:B4]", MyConnection) ds1 = New System.Data.DataSet() MyCommand3.Fill(ds1) '---This is the code to display the data to the textbox, 'however I still haven't figured out how to save the data back to the excel file' TextBoxView1.Text = ds1.Tables(0).Rows(0)(0).ToString


这篇关于使用文本框更新Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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