PublicxxAsString
PublictempAsString
Publicfile_lengthAsLong
Publicfile_numberAsLong
PublictempAsString
Publicfile_lengthAsLong
Publicfile_numberAsLong
PrivateSubCommand1_Click()
ProgressBar1.Visible=True
DimH()AsString,L()AsString,iAsInteger,jAsInteger,a()AsString
DimSaveFileAsString
DimxlAppAsExcel.Application
DimxlBookAsExcel.Workbook
DimxlSheetAsExcel.Worksheet
SetxlApp=CreateObject("Excel.Application")'创建EXCEL对象
SetxlBook=xlApp.Workbooks.Add'打开已经存在的EXCEL工件簿文件
xlApp.Visible=True'设置EXCEL对象可见(或不可见)
SetxlSheet=xlBook.Worksheets("Sheet1")'设置活动工作表
'*************************************************************
OpenxxForInputAs#1'openthefile
xlSheet.Cells(1,1)="序号"
xlSheet.Cells(1,2)="时间"
xlSheet.Cells(1,3)="模式"
xlSheet.Cells(1,4)="电流(A)"
xlSheet.Cells(1,5)="总电压(V)"
xlSheet.Cells(1,6)="容量(AH)"
xlSheet.Cells(1,7)="告警类型"
xlSheet.Cells(1,8)="环境温度(C)"
xlSheet.Cells(1,9)="电池温度1"
xlSheet.Cells(1,10)="电池温度2"
xlSheet.Cells(1,11)="电池温度3"
xlSheet.Cells(1,12)="电池温度4"
xlSheet.Cells(1,13)="电池温度4"
xlSheet.Cells(1,14)="电压1"
xlSheet.Cells(1,15)="电压2"
xlSheet.Cells(1,16)="电压3"
xlSheet.Cells(1,17)="电压4"
xlSheet.Cells(1,18)="电压5"
xlSheet.Cells(1,19)="电压6"
xlSheet.Cells(1,20)="电压7"
xlSheet.Cells(1,21)="电压8"
xlSheet.Cells(1,22)="电压9"
xlSheet.Cells(1,23)="电压10"
xlSheet.Cells(1,24)="电压11"
xlSheet.Cells(1,25)="电压12"
xlSheet.Cells(1,26)="电压13"
xlSheet.Cells(1,27)="电压14"
xlSheet.Cells(1,28)="电压15"
xlSheet.Cells(1,29)="电压16"
xlSheet.Cells(1,1)="序号"
xlSheet.Cells(1,2)="时间"
xlSheet.Cells(1,3)="模式"
xlSheet.Cells(1,4)="电流(A)"
xlSheet.Cells(1,5)="总电压(V)"
xlSheet.Cells(1,6)="容量(AH)"
xlSheet.Cells(1,7)="告警类型"
xlSheet.Cells(1,8)="环境温度(C)"
xlSheet.Cells(1,9)="电池温度1"
xlSheet.Cells(1,10)="电池温度2"
xlSheet.Cells(1,11)="电池温度3"
xlSheet.Cells(1,12)="电池温度4"
xlSheet.Cells(1,13)="电池温度4"
xlSheet.Cells(1,14)="电压1"
xlSheet.Cells(1,15)="电压2"
xlSheet.Cells(1,16)="电压3"
xlSheet.Cells(1,17)="电压4"
xlSheet.Cells(1,18)="电压5"
xlSheet.Cells(1,19)="电压6"
xlSheet.Cells(1,20)="电压7"
xlSheet.Cells(1,21)="电压8"
xlSheet.Cells(1,22)="电压9"
xlSheet.Cells(1,23)="电压10"
xlSheet.Cells(1,24)="电压11"
xlSheet.Cells(1,25)="电压12"
xlSheet.Cells(1,26)="电压13"
xlSheet.Cells(1,27)="电压14"
xlSheet.Cells(1,28)="电压15"
xlSheet.Cells(1,29)="电压16"
Forj=0Tofile_number
LineInput#1,temp
H=Split(temp,vbTab)
Fori=0Tofile_length-1
xlSheet.Cells(j+2,i+1)=H(i)
ProgressBar1.Value=i+1
Nexti
Nextj
Close#1'closethefile
SaveFile="c:\yu.xls"
IfDir(SaveFile)<>""ThenKillSaveFile
xlBook.SaveAsFileName:=SaveFile'保存工作表,结束时一定别忘了保存
xlBook.Close(True)'关闭工作簿这里的True表示退出时保存修改
xlApp.Quit'结束EXCEL对象
SetxlApp=Nothing'释放xlApp对象
MsgBox"文件已成功导出到"&SaveFile
EndSub
LineInput#1,temp
H=Split(temp,vbTab)
Fori=0Tofile_length-1
xlSheet.Cells(j+2,i+1)=H(i)
ProgressBar1.Value=i+1
Nexti
Nextj
Close#1'closethefile
SaveFile="c:\yu.xls"
IfDir(SaveFile)<>""ThenKillSaveFile
xlBook.SaveAsFileName:=SaveFile'保存工作表,结束时一定别忘了保存
xlBook.Close(True)'关闭工作簿这里的True表示退出时保存修改
xlApp.Quit'结束EXCEL对象
SetxlApp=Nothing'释放xlApp对象
MsgBox"文件已成功导出到"&SaveFile
EndSub
PrivateSubCommand2_Click()
txt_file.FileName=""
txt_file.Flags=vbOFNFileMustExist
txt_file.Filter="AllFiles|*.*|(*.txt)|*.txt"
txt_file.FilterIndex=2
txt_file.DialogTitle="选择需要转换的Txt文件"
txt_file.Action=1
Iftxt_file.FileName=""Then
txt_file.FileName=""
txt_file.Flags=vbOFNFileMustExist
txt_file.Filter="AllFiles|*.*|(*.txt)|*.txt"
txt_file.FilterIndex=2
txt_file.DialogTitle="选择需要转换的Txt文件"
txt_file.Action=1
Iftxt_file.FileName=""Then
Else
xx=txt_file.FileName
xx=txt_file.FileName
OpenxxForInputAs#1'openthefile
LineInput#1,temp
a=Split(temp,vbTab)
file_length=UBound(a)-LBound(a)+1
ProgressBar1.Max=file_length
DoWhileNotEOF(1)
LineInput#1,temp
file_number=file_number+1
Loop
file_number=file_number
Close#1'closethefile
EndIf
EndSub
LineInput#1,temp
file_number=file_number+1
Loop
file_number=file_number
Close#1'closethefile
EndIf
EndSub
PrivateSubForm_Load() xx="" file_length=0 file_number=0 ProgressBar1.Visible=False EndSub