我想用excel查询一个log文件
我是想在excel上想通过选择日志文件路径来对这个日志文件进行查询操作,然后将查询结果显示在excel上,谁会这样的功能阿? 给我做一个简单的类似的demo也行啊 谢谢了 万分着急中~~~~~
邮箱:kwantong2006@yahoo.com.cn
1楼的大哥你太NB了(膜拜中),我就想要这种效果,不过现在还有一个功能就是,选择完文件之后,还有一个text是输入用户名的,然后再点一个按钮进行查询,因为要按照用户名搜索记录,现在这样是将所有记录都显示出来了。
并且还有一点(不好意思我是做java的没有这方面的基础),显示出来的记录要按照一定格式输出,
每一条记录是这样的
2008-02-22 16:07:40,515 [6] INFO ClaimManager.BLL.BasePage [(null)] <(null)> - Id:admin 事件名:RBCMS_07_03 - btnSearch_Click 処理时间:14828.125ms END
//记录注释:
//操作日时:2008-02-22 16:07:40,515
//操作功能:[6] INFO ClaimManager.BLL.BasePage [(null)] <(null)>
//操作者:admin
//事件名: RBCMS_07_03 - btnSearch_Click
//処理时间:14828.125ms (可能没有此项)
//开始/终了:END
我现在要把查处的记录放到excel的表中,表的格式为
操作日时 操作者 操作内容 开始/终了 処理时间
//操作内容为 操作功能+事件名
帮帮我吧谢谢了,我又加了100分!!!
Dim a As String
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Show
a = .SelectedItems(1)
End With
If ActiveSheet.QueryTables.Count = 0 Then
ActiveSheet.QueryTables.Add Connection:="TEXT;" & a, Destination:=Range("A1")
Else
ActiveSheet.QueryTables(1).Connection = "TEXT;" & a
End If
With ActiveSheet.QueryTables(1)
.Name = "Log"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
.Destination = Range("A1")
End With
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Show
a = .SelectedItems(1)
End With
If ActiveSheet.QueryTables.Count = 0 Then
ActiveSheet.QueryTables.Add Connection:="TEXT;" & a, Destination:=Range("A1")
Else
ActiveSheet.QueryTables(1).Connection = "TEXT;" & a
End If
With ActiveSheet.QueryTables(1)
.Name = "Log"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
.Destination = Range("A1")
End With
2分到手