问题描述
将数据导出到excel,但是excel上没有标题文本,您能帮我吗?我使用的是
将ExcelApp作为对象变暗,将ExcelBook作为对象变暗
将ExcelSheet变暗为对象
Dim i As Integer
Dim j As Integer
'创建excel对象
ExcelApp = CreateObject("Excel.Application")
ExcelBook = ExcelApp.WorkBooks.Add
ExcelSheet = ExcelBook.WorkSheets(1)
使用ExcelSheet
对于我= 1 To Me.DataGridView1.RowCount
.cells(i,1)= Me.DataGridView1.Rows(i-1).Cells(0).Value
对于j = 1到DataGridView1.Columns.Count-1
.cells(i,j + 1)= DataGridView1.Rows(i-1).Cells(j).Value
下一个
下一个
结尾为
ExcelApp.Visible =真
'
ExcelSheet =没什么
ExcelBook =没什么
ExcelApp =什么都没有
此编码
Data export to excel but header text is not come on the excel, can you help me. i use the
Dim ExcelApp As Object, ExcelBook As Object
Dim ExcelSheet As Object
Dim i As Integer
Dim j As Integer
'create object of excel
ExcelApp = CreateObject("Excel.Application")
ExcelBook = ExcelApp.WorkBooks.Add
ExcelSheet = ExcelBook.WorkSheets(1)
With ExcelSheet
For i = 1 To Me.DataGridView1.RowCount
.cells(i, 1) = Me.DataGridView1.Rows(i - 1).Cells(0).Value
For j = 1 To DataGridView1.Columns.Count - 1
.cells(i, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value
Next
Next
End With
ExcelApp.Visible = True
'
ExcelSheet = Nothing
ExcelBook = Nothing
ExcelApp = Nothing
this coding
推荐答案
For colIndex As Integer = 0 To DataGridView1.Columns.Count - 1
Console.WriteLine(DataGridView1.Columns(colIndex).HeaderText)
Next
这篇关于数据导出到excel,但是excel上没有标题文本,请帮助我......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!