VB.NET2008代碼:
濱江網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),濱江網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為濱江1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營銷網(wǎng)站建設(shè)要多少錢,請找那個(gè)售后服務(wù)好的濱江做網(wǎng)站的公司定做!
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(行編號(hào), 列編號(hào)).value ="需要輸入的數(shù)據(jù)"
xlworkbk.Close()
另外,xlworksheet.UsedRange.Rows.Count是最大行數(shù),可以用這個(gè)算行編號(hào)。
注意,需要引用Microsoft Excel Object Library(在COM的那個(gè)選項(xiàng)卡里)。
您好,要實(shí)現(xiàn)非常簡單。需要四個(gè)按鈕,一個(gè)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
以上如有不清楚,您可以繼續(xù)追問。希望對您有用!
這樣就可以的
DataGridView1.Rows(i).Cells(0).Value = i + 1
RowS指定行,Cells指定列