本帖最后由 Five66 于 2023-8-30 03:46 编辑
表格需要为microsoft office的xlsx
将表格改名为book1.xlsx
然后跟批处理一起放到需要改名的目录下运行
还有启动excel时间过长时代码可能出错,建议先启动一次excel然后立马关闭
改名时时表格里对不上可能会出现奇怪问题- @set @theCopyLeft=0;/*&echo off&pause
-
- rem 将表格改名为book1.xlsx然后跟 批处理一起放到需要的目录下运行
-
- set ttm=the-%date:~0,10%-temp
- set ttm=%ttm:/=-%
- md %ttm%
- if %errorlevel% EQU 1 echo can not create temp folder&exit /b
- for /f "skip=1 tokens=1,2 delims=/ " %%i in ('cscript //nologo //e:jscript "%~f0"') do (
- if exist "%%i" move "%%i" "%ttm%\%%j" 1>nul
- )
- for /d %%i in (*) do if "%%i" NEQ "%ttm%" rename "%%i" "___%%i"
- for /d %%i in ("%ttm%\*") do (1>nul move "%%i" .)
- rmdir %ttm%
- pause &exit/b
- rem */
-
- var thefile="book1.xlsx";
- var eee=new ActiveXObject("excel.application");
- var thepath=WScript.ScriptFullName.split("\\");
- thepath.pop();
- thepath=thepath.join("\\")+"\\";
- var wb=eee.Workbooks.Open(thepath+thefile);
- var sheet=wb.ActiveSheet;
- var a,b,i=1;
- while(1){
- a=sheet.Range("A"+i).text;
- b=sheet.Range("B"+i).text;
- if(!a || !b){break;}
- WScript.Echo(a,"/",b);
- i+=1;
- }
- wb.Close();
- eee.Quit();
复制代码 还有为啥这个帖子是倒序的? |