本帖最后由 回家路上 于 2015-8-28 12:49 编辑
下次就直接描述要干嘛就行。要不楼上解析txt的不就白搞了。这样不好。
我电脑上没有Office,没有测,写一个练手而已。不好使就坐等。- @set @n=0; /* & echo off&setlocal enabledelayedexpansion
- ::excel文件名称
- set "excelFile=list.xlsx"
- for /f "delims=" %%i in ('echo;%excelFile%^|cscript -nologo -e:jscript "%~0"') do set "%%i"
- for /f "delims=" %%i in ('dir /b *.txt') do (
- (for /f "usebackq delims=" %%a in ("%%i") do (
- set "line=%%a"
- if "!line:~0,4!" equ "PDAT" (echo;!_%%~ni!) else echo;%%a
- ))>"$%%i$"
- move /y "$%%i$" "%%i"
- )
- del /q "$*$"
- pause & exit/b & rem */
-
- function readExcel(filePath) {
- var oXL = new ActiveXObject("Excel.application");
- var oWB = oXL.Workbooks.open(filePath);
- oWB.worksheets(1).select();
- var oSheet = oWB.ActiveSheet;
- var rows = oSheet.usedrange.rows.count;
- var tempStr = "";
- for (var i = 1; i <= rows; i++) {
- if (oSheet.Cells(i, 1).value == "null" || oSheet.Cells(i, 2).value == "null")
- break;
- tempStr+= "_"+oSheet.Cells(i, 1)+"="+oSheet.Cells(i, 2)+"\r\n"
- }
- WSH.Echo(tempStr)
- oXL.Application.Quit();
- CollectGarbage();
- }
- var filePath = WScript.StdIn.ReadAll();
- readExcel(filePath);
复制代码
|