ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VB.net ¦p¦ó­pºâExcel¤¤AÄæ¦ìxlDown?

[µo°Ý] VB.net ¦p¦ó­pºâExcel¤¤AÄæ¦ìxlDown?

½Ð°ÝVB.net­n¦p¦óºâExcel¤ºFor°j°éªºµ²§ô­È?
§Ú¥ÎVBAªº¤èªk³£Åã¥ÜxlDown¸òxlUp³£¬OµL®Ä

Wo                                  Op             Time
M123456789        OAG        01 10:00:00
M123456789        HAG        01 10:00:00
M123456789        SAG        01 10:00:00
M123456788        OAG        02 10:00:00
M123456788        SAG        02 10:00:00
  1.     Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  2.         Dim WB, XL, oSheet As Object
  3.         XL = CreateObject("Excel.Application")
  4.         XL.Visible = False
  5.         WB = XL.Workbooks.Open("\\Test\test.xlsx", True)
  6.         oSheet = XL.Workbooks("Test.xlsx").Sheets("Text1")
  7.         'For i As Long = 1 To oSheet.Range("A100").End(xlUp).Row
  8.         'Dim aa As String = Wo.Text
  9.         'Dim bb As String = oSheet.Range("A2").End(xlUp)
  10.         'Dim rng As Range
  11.         rng = XL.range(XL.cells(1, 1), XL.cells(1, 1).End(xlDown))
  12.         For i As Integer = 1 To rng'­n¦p¦ó­pºâExcel¤º·|°j°éÁ`¼Æ?
  13.             oSheet.cells(4, i).value = "Test"
  14.         Next
  15.         XL.Workbooks("Test.xlsx").Save()
  16.         XL.DisplayAlerts = True
  17.         MsgBox("OK")
  18.         XL.Workbooks("Test.xlsx").Close()
  19.         XL.Application.Quit()
  20.         XL = Nothing
  21.         WB = Nothing
  22.         oSheet = Nothing

  23.     End Sub
½Æ»s¥N½X
¤@¤À§V¤O¡A¤@¤À¦¬Ã¬¡C
µo°ÝÃD«e¥i¥H¥ý·j¯Á¤º¤å¬O§_¦³¬ÛÃö½d¨Ò¡C

¤w§ä¨ì¸Ñµª¤F¡A¤À¨Éµ¹¦U¦ì!

Constant        Value
xlDown        -4121
xlToLeft        -4159
xlToRight        -4161
xlUp        -4162
  1. Const xlUp = -4162
  2. Const xlDown = -4121
½Æ»s¥N½X
¤@¤À§V¤O¡A¤@¤À¦¬Ã¬¡C
µo°ÝÃD«e¥i¥H¥ý·j¯Á¤º¤å¬O§_¦³¬ÛÃö½d¨Ò¡C

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD