title image


Smiley Re: .NET Excel Range oder Cells
Hi,



brauchst ja nur den Spaltennamen.

Das hier müsste auch unter .NET funktionieren:







Private Function GetColumnLetter(Byval nRow As Long, ByVal nCol As Integer) As String

Dim n AS Long

Dim m As Long



n = nCol \ 26

m = nCol Mod 26

If n > 0 Then s = Chr(64 + n)

If m > 0 Then s = s + Chr(64 + m)

GetColumnLetter = s & CStr(nRow)

End Function



aber ob Du damit die Zeit aufholst glaube ich kaum.





Das gibt dann Simsalabim:





Private Declare Function GetTickCount Lib "kernel32.dll" () As Long



Private Sub Form_Load()

Dim xlsApp As New Excel.Application

Dim xlsWorkbook As Excel.Workbook

Dim xlsWorksheet As Excel.Worksheet

Dim c As Excel.Range

Dim str As String

Dim p As Long

Dim i As Integer





xlsApp.Visible = False

Set xlsWorkbook = xlsApp.Workbooks.Open("D:\Book1.xls")

Set xlsWorksheet = xlsWorkbook.Sheets(3)

Set c = xlsWorksheet.Cells(1, 1)



p = GetTickCount()

For i = 0 To 5000

'str = xlsWorksheet.Range(GetColumnLetter(3, 1)).Text

str = xlsWorksheet.Cells(3, 1).Text

Next





MsgBox GetTickCount - p



Set xlsApp = Nothing

Set xlsWorkbook = Nothing

Set xlsWorksheet = Nothing

End Sub



Private Function GetColumnLetter(ByVal nRow As Long, ByVal nCol As Integer) As String

Dim n As Long

Dim m As Long



n = nCol \ 26

m = nCol Mod 26

If n > 0 Then s = Chr(64 + n)

If m > 0 Then s = s + Chr(64 + m)

GetColumnLetter = s & CStr(nRow)

End Function



Cells Methode ist geringfügig langsamer ;) Kommt mit 3052 Ticks.


Programmierst Du noch frei oder wirst Du schon von Microsoft verwaltet ( .NET)?



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: