不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行(需安装有微软的office办公软件)
/*&cls&echo off&mode con lines=5000
rem 读取/提取一个指定表格文件里的某一列的数据
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0"
set "file=表格.xlsx"
set "column=A"
if not exist "%file%" (echo;"%file%" not found&pause&exit)
cscript -nologo -e:jscript "%~f0" "%file%" "%column%"
echo;%#% +%$%%$%/%_% %z%
pause
exit
*/
var fso=new ActiveXObject('Scripting.FileSystemObject');
var file=fso.GetFile(WSH.Arguments(0)),column=WSH.Arguments(1);
var excel=null;
try{
excel=new ActiveXObject('Excel.Application');
}catch(e){WSH.StdErr.WriteLine('MS Excel is not installed');WSH.Quit();}
excel.DisplayAlerts=false;
excel.Visible=true;
var book=excel.Workbooks.Open(file.Path);
var sheet=book.Worksheets(1);
var rows=sheet.Range(column+sheet.Rows.Count.toString()).End(-4162).Row;
for(var i=1;i<=rows;i++){
var cell=column+i.toString();
WSH.StdErr.WriteLine(sheet.Range(cell).Value);
}
book.Close();
excel.Quit();
WSH.Quit();
/*&cls&echo off&mode con lines=5000
rem 读取/提取一个指定表格文件里的某一列的数据
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0"
set "file=表格.xlsx"
set "column=A"
if not exist "%file%" (echo;"%file%" not found&pause&exit)
cscript -nologo -e:jscript "%~f0" "%file%" "%column%"
echo;%#% +%$%%$%/%_% %z%
pause
exit
*/
var fso=new ActiveXObject('Scripting.FileSystemObject');
var file=fso.GetFile(WSH.Arguments(0)),column=WSH.Arguments(1);
var excel=null;
try{
excel=new ActiveXObject('Excel.Application');
}catch(e){WSH.StdErr.WriteLine('MS Excel is not installed');WSH.Quit();}
excel.DisplayAlerts=false;
excel.Visible=true;
var book=excel.Workbooks.Open(file.Path);
var sheet=book.Worksheets(1);
var rows=sheet.Range(column+sheet.Rows.Count.toString()).End(-4162).Row;
for(var i=1;i<=rows;i++){
var cell=column+i.toString();
WSH.StdErr.WriteLine(sheet.Range(cell).Value);
}
book.Close();
excel.Quit();
WSH.Quit();