是文本文件,你这个应该是软件中导出的吧,我就碰到一个软件是这样的,导出的是xls,其实就是txt文件
试试这个代码
#Include <File.au3>
$file1=@ScriptDir&"\11.xls"
$file2=@ScriptDir&"\11_0.xls"
build($file1,$file2)
MsgBox(0,"","生成")
Func build($file_read,$file_build)
Dim $count_str
$lines=_FileCountLines($file_read)
For $i=2 To $lines
$read=FileReadLine($file_read,$i)
$count_str_1=mid($read)
$count_str=$count_str&$count_str_1
Next
$all_str=top($lines)&$count_str&end()
$f=FileOpen($file_build,138)
FileWrite($f,$all_str)
FileClose($f)
EndFunc
Func top($line)
$str='<?xml version="1.0"?>'&@CRLF
$str=$str&'<?mso-application progid="Excel.Sheet"?>'&@CRLF
$str=$str&'<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"'&@CRLF
$str=$str&' xmlns:o="urn:schemas-microsoft-com:office:office"'&@CRLF
$str=$str&' xmlns:x="urn:schemas-microsoft-com:office:excel"'&@CRLF
$str=$str&' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"'&@CRLF
$str=$str&' xmlns:html="http://www.w3.org/TR/REC-html40">'&@CRLF
$str=$str&' <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">'&@CRLF
$str=$str&' <Created>1996-12-17T01:32:42Z</Created>'&@CRLF
$str=$str&' <LastSaved>2014-04-16T15:37:49Z</LastSaved>'&@CRLF
$str=$str&' <Version>11.5606</Version>'&@CRLF
$str=$str&' </DocumentProperties>'&@CRLF
$str=$str&' <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">'&@CRLF
$str=$str&' <RemovePersonalInformation/>'&@CRLF
$str=$str&' </OfficeDocumentSettings>'&@CRLF
$str=$str&' <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">'&@CRLF
$str=$str&' <WindowHeight>4530</WindowHeight>'&@CRLF
$str=$str&' <WindowWidth>8505</WindowWidth>'&@CRLF
$str=$str&' <WindowTopX>480</WindowTopX>'&@CRLF
$str=$str&' <WindowTopY>120</WindowTopY>'&@CRLF
$str=$str&' <AcceptLabelsInFormulas/>'&@CRLF
$str=$str&' <ProtectStructure>False</ProtectStructure>'&@CRLF
$str=$str&' <ProtectWindows>False</ProtectWindows>'&@CRLF
$str=$str&' </ExcelWorkbook>'&@CRLF
$str=$str&' <Styles>'&@CRLF
$str=$str&' <Style ss:ID="Default" ss:Name="Normal">'&@CRLF
$str=$str&' <Alignment ss:Vertical="Bottom"/>'&@CRLF
$str=$str&' <Borders/>'&@CRLF
$str=$str&' <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>'&@CRLF
$str=$str&' <Interior/>'&@CRLF
$str=$str&' <NumberFormat/>'&@CRLF
$str=$str&' <Protection/>'&@CRLF
$str=$str&' </Style>'&@CRLF
$str=$str&' <Style ss:ID="s21">'&@CRLF
$str=$str&' <NumberFormat ss:Format="@"/>'&@CRLF
$str=$str&' </Style>'&@CRLF
$str=$str&' <Style ss:ID="s22">'&@CRLF
$str=$str&' <NumberFormat ss:Format="Short Date"/>'&@CRLF
$str=$str&' </Style>'&@CRLF
$str=$str&' <Style ss:ID="s23">'&@CRLF
$str=$str&' <NumberFormat ss:Format="General Date"/>'&@CRLF
$str=$str&' </Style>'&@CRLF
$str=$str&' </Styles>'&@CRLF
$str=$str&' <Worksheet ss:Name="Sheet1">'&@CRLF
$str=$str&' <Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="35" x:FullColumns="1"'&@CRLF
$str=$str&' x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">'&@CRLF
$str=$str&' <Row>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">生产单位</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">生产单位编码</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">物料条码</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">物料代码</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">物料名称</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">版本</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">版本号</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">生产日期</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">注册时间</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">注册人</Data></Cell>'&@CRLF
$str=$str&' </Row>'&@CRLF
Return $str
EndFunc
Func mid($strings)
$arr=StringSplit($strings,@TAB)
$str=' <Row>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">'&$arr[1]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell ss:StyleID="s21"><Data ss:Type="String">'&StringTrimLeft($arr[2],1)&'</Data></Cell>'&@CRLF
$str=$str&' <Cell ss:StyleID="s21"><Data ss:Type="String">'&StringTrimLeft($arr[3],1)&'</Data></Cell>'&@CRLF
$str=$str&' <Cell ss:StyleID="s21"><Data ss:Type="String">'&StringTrimLeft($arr[4],1)&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">'&$arr[5]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">'&$arr[6]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="Number">'&$arr[7]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">'&$arr[8]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="String">'&$arr[9]&'</Data></Cell>'&@CRLF
$str=$str&' <Cell><Data ss:Type="Number">'&$arr[10]&'</Data></Cell>'&@CRLF
$str=$str&' </Row>'&@CRLF
Return $str
EndFunc
Func end()
$str='</Table>'&@CRLF
$str=$str&' <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">'&@CRLF
$str=$str&' <Selected/>'&@CRLF
$str=$str&' <ProtectObjects>False</ProtectObjects>'&@CRLF
$str=$str&' <ProtectScenarios>False</ProtectScenarios>'&@CRLF
$str=$str&' </WorksheetOptions>'&@CRLF
$str=$str&' </Worksheet>'&@CRLF
$str=$str&'</Workbook>'&@CRLF
Return $str
EndFunc
|