- @echo off&setlocal enabledelayedexpansion
- for /f "skip=1 tokens=1,2,3 delims= " %%a in (test.xls) do (
- if not defined flag >test.xls echo job money
- set flag=1
- if "%%b"=="total" (
- >>test.xls echo %%a:%%b !total:~0,-5!.!total:~-5!
- set total=0) else (
- >>test.xls echo %%b %%c
- call :count %%c
- set /a total=!total!+!money!
- )
- )
- test.xls
- exit
-
- :count
- for /f "tokens=1,2 delims=." %%i in ("%1") do (
- set money=%%j00000
- set money=!money:~0,5!
- set money=%%i!money!
- )
- goto :eof
复制代码 小数计算部分略作改善,5位小数内可行。其他地方不知如何再精简了。 |