问题描述
我有一个程序可以在excel文件中输出报告.我在添加行时使用OLEDB连接.
I have a program that output a report in excel file. I use OLEDB Connection in adding rows.
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String
MyConnection = New System.Data.OleDb.OleDbConnection _
("provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + _
"'c:\test.xls';Extended Properties=Excel 8.0;")
MyConnection.Open()
myCommand.Connection = MyConnection
sql = "Insert into [Sheet1$] (id,name) values('5','e')"
myCommand.CommandText = sql
myCommand.ExecuteNonQuery()
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MsgBox("Row Added ")
在 http://www.java-samples.com/showtutorial.php?tutorialid=1051 [ ^ ]
我的问题是在该Excel文件中添加行之前,我必须具有标题作为字段名称.
''这是EXCEL文件中的内容
Found this in http://www.java-samples.com/showtutorial.php?tutorialid=1051[^]
My problem is before I add row in that excel file I must have a header as field names.
''THIS IS THE CONTENT IN EXCEL FILE
id | name
如何在没有该标题的excel文件中添加行.
谢谢...
How can I add row in excel file without that header.
Thanks...
推荐答案
在 http://www.java-samples.com/showtutorial.php?tutorialid=1051 [ ^ ]
我的问题是在该Excel文件中添加行之前,我必须具有标题作为字段名称.
''这是EXCEL文件中的内容
Found this in http://www.java-samples.com/showtutorial.php?tutorialid=1051[^]
My problem is before I add row in that excel file I must have a header as field names.
''THIS IS THE CONTENT IN EXCEL FILE
id | name
如何在没有该标题的excel文件中添加行.
谢谢...
How can I add row in excel file without that header.
Thanks...
这篇关于VB.NET使用OLDB连接将数据写入Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!