VB.NET2008代码:
滨江网站建设公司成都创新互联,滨江网站设计制作,有大型网站制作公司丰富经验。已为滨江1000+提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的滨江做网站的公司定做!
Dim xlapp1 As Excel.Application
Dim xlworksheet As Excel.Worksheet
Dim xlworkbk As Excel.Workbook
xlapp1 = New Excel.Application
xlworkbk = xlapp1.Workbooks.Open("Excel文件名")
xlworksheet = xlworkbk.Worksheets("Sheet名")
xlworksheet.Cells.Item(行编号, 列编号).value ="需要输入的数据"
xlworkbk.Close()
另外,xlworksheet.UsedRange.Rows.Count是最大行数,可以用这个算行编号。
注意,需要引用Microsoft Excel Object Library(在COM的那个选项卡里)。
您好,要实现非常简单。需要四个按钮,一个datagridview控件。代码如下
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'添加行
Me.DataGridView1.Rows.Add()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'添加列
Me.DataGridView1.Columns.Add("1", "on")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'删除行
Me.DataGridView1.Rows.RemoveAt(0)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'删除列
Me.DataGridView1.Columns.RemoveAt(0)
End Sub
End Class
以上如有不清楚,您可以继续追问。希望对您有用!
这样就可以的
DataGridView1.Rows(i).Cells(0).Value = i + 1
RowS指定行,Cells指定列