Keresés

Új hozzászólás Aktív témák

  • Kraptor

    őstag

    válasz kiskegyed #101 üzenetére

    Úgy simán sehogy, mert 65K a limit, de vannak okosságok amivel meglehet kerülni ezeket. Van egy progi amit Microsoft Office Spreadsheet 10.0 UserForm control-nak hívnak és ezzel elvileg létretudsz hozni 18,278 x 262,144-es lapokat.Ezt nem tudom, hogy mennyire igaz vagy nem.

    Vagy vannak különböző makrók amikkel megtudsz nyitnyi nagyobb fileokat, csak akkor több lapba fogja megnyitni őket automatikusan.

    Sub ImportLargeFile()
    'Imports text file into Excel workbook using ADO.
    'If the number of records exceeds 65536 then it splits it over more than one sheet.

    Dim strFilePath As String, strFilename As String, strFullPath As String
    Dim lngCounter As Long
    Dim oConn As Object, oRS As Object, oFSObj As Object


    'Get a text file name
    strFullPath = Application.GetOpenFilename(''Text Files (*.txt),*.txt'', , ''Please select text file...'')

    If strFullPath = ''False'' Then Exit Sub 'User pressed Cancel on the open file dialog
    Application.ScreenUpdating = False


    'This gives us a full path name e.g. C:\folder\file.txt
    'We need to split this into path and file name
    Set oFSObj = CreateObject(''SCRIPTING.FILESYSTEMOBJECT'')

    strFilePath = oFSObj.GetFile(strFullPath).ParentFolder.Path
    strFilename = oFSObj.GetFile(strFullPath).Name


    'Open an ADO connection to the folder specified
    Set oConn = CreateObject(''ADODB.CONNECTION'')
    oConn.Open ''Provider=Microsoft.Jet.OLEDB.4.0;'' & _
    ''Data Source='' & strFilePath & '';'' & _
    ''Extended Properties=''''text;HDR=Yes;FMT=Delimited''''''

    Set oRS = CreateObject(''ADODB.RECORDSET'')

    'Now actually open the text file and import into Excel
    oRS.Open ''SELECT * FROM '' & strFilename, oConn, 3, 1, 1
    While Not oRS.EOF
    Sheets.Add
    ActiveSheet.Range(''A1'').CopyFromRecordset oRS, 65536
    Wend

    oRS.Close
    oConn.Close

    Application.ScreenUpdating = True


    End Sub


    Itt egy másik is:

    Sub LoadData()
    Const cCol1 = 20, cCol2 = 20, cCol3 = 20, cLimit = 50000
    Dim intFreeFile As Integer, i As Long, j As Long, strTemp As String
    Dim arr() As String

    On Error Resume Next
    intFreeFile = FreeFile
    Open ''c:\test.txt'' For Input As #intFreeFile
    i = 0: j = 1
    ReDim arr(cLimit, 2)
    Do Until EOF(intFreeFile)
    Line Input #intFreeFile, strTemp
    arr(i, 0) = Trim(Mid(strTemp, 1, cCol1))
    arr(i, 1) = Trim(Mid(strTemp, cCol1, cCol2))
    arr(i, 2) = Trim(Mid(strTemp, cCol1 + cCol2, cCol3))
    i = i + 1
    If i > cLimit - 1 Then
    Cells(1, j).Resize(cLimit, 3).Value = arr
    i = 0: j = j + 3
    ReDim arr(cLimit, 2)
    End If
    Loop
    Close #intFreeFile
    End Sub

Új hozzászólás Aktív témák