exit /b :getLastIndex setlocal enabledelayedexpansion set /A len+=%2 set value= :strLen_LoopIndex set /A num=len-1 if not "!%1:~%num%,1!"=="" ( if"!%1:~%num%,1!"==";" ( echo"%value%" endlocal & set %3=%value% ) else ( set /A len=len-1 set value=!%1:~%num%,1!%value% goto :strLen_LoopIndex ) ) else ( endlocal & set %3=%value% ) exit /b
exit /b :getSubIndex setlocal enabledelayedexpansion :strLen_Loop set /A len+=1 set /A len1+=0 set /A num=len-1 ::判断传入第二个参数要查找的字符是否已经遍历到了结尾,如果结尾了就说明匹配到了 if not "!%2:~%len1%!"=="" ( ::判断第一个传入的字符串是否已经遍历到了结尾 if not "!%1:~%num%!"=="" ( if not "!%2:~%len1%!"=="" ( if"!%1:~%num%,1!"=="!%2:~%len1%,1!" ( set /A len1=len1+1 ) else ( set /A len1=0 ) goto :strLen_Loop ) else ( endlocal & set %3=%num% ) ) ) else ( endlocal & set %3=%num% ) exit /b
var objArgs = WScript.Arguments; if (objArgs.length < 2) { Abort("Usage: [CScript | WScript] diff-xls.js base.xls new.xls", "Invalid arguments"); }
var sBaseDoc = objArgs(0); var sNewDoc = objArgs(1);
var objScript = new ActiveXObject("Scripting.FileSystemObject");
if (objScript.GetBaseName(sBaseDoc) === objScript.GetBaseName(sNewDoc)) { Abort("File '" + sBaseDoc + "' and '" + sNewDoc + "' is same file name.\nCannot compare the documents.", "Same file name"); }
if (!objScript.FileExists(sBaseDoc)) { Abort("File '" + sBaseDoc + "' does not exist.\nCannot compare the documents.", "File not found"); }
if (!objScript.FileExists(sNewDoc)) { Abort("File '" + sNewDoc + "' does not exist.\nCannot compare the documents.", "File not found"); }
sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc); sNewDoc = objScript.GetAbsolutePathName(sNewDoc); var sTempFolder = objScript.GetSpecialFolder(2) var sTempFile = "D:\\temp.txt" objScript = null;
var fs = new ActiveXObject("Scripting.FileSystemObject"); var f = fs.CreateTextFile(sTempFile, 2, true) f.WriteLine(sBaseDoc) f.WriteLine(sNewDoc) f.close() fs = null f = null
WScript var objShell = new ActiveXObject("WScript.Shell"); objShell.run('"C:\\Program Files\\Microsoft Office\\root\\Client\\AppVLP.exe" "C:\\Program Files (x86)\\Microsoft Office\\Office16\\DCF\\SPREADSHEETCOMPARE.EXE" "D:\\temp.txt"', 0, true) objShell = null
Dim num num = objArgs.Count If num < 2Then MsgBox "Usage: [CScript | WScript] diff-xlsx.vbs base.xlsx new.xlsx", vbExclamation, "Invalid arguments" WScript.Quit 1 EndIf
Dim sBaseFile, sNewFile sBaseFile = objArgs(0) sNewFile = objArgs(1) Set objArgs = Nothing
Dim objFileSystem Set objFileSystem = CreateObject("Scripting.FileSystemObject") If objFileSystem.FileExists(sBaseFile) = FalseThen MsgBox "File " + sBaseFile + " does not exist. Cannot compare the files.", vbExclamation, "File not found" WScript.Quit 1 EndIf If objFileSystem.FileExists(sNewFile) = FalseThen MsgBox "File " + sNewFile + " does not exist. Cannot compare the files.", vbExclamation, "File not found" WScript.Quit 1 EndIf
'Compare file size Dim fBaseFile, fNewFile, sTempFolder, sTempFile Set fBaseFile = objFileSystem.GetFile(sBaseFile) Set fNewFile = objFileSystem.GetFile(sNewFile) sTempFolder = objFileSystem.GetSpecialFolder(2) sTempFile = sTempFolder + "\temp.txt" Set objFileSystem = Nothing
'Create temp.txt for save path of 2 xlsx files Dim fs, f Set fs = WScript.CreateObject("Scripting.FileSystemObject") Set f = fs.CreateTextFile(sTempFile, 2, True) f.WriteLine sBaseFile f.WriteLine sNewFile f.Close() Set fs = Nothing Set f = Nothing
'Compare files using SPREADSHEETCOMPARE.exe Dim WshShell, result Set WshShell = WScript.CreateObject("WScript.Shell") 'Old office version 2016? 'result = WshShell.Run("""C:\Program Files (x86)\Microsoft Office\Office16\DCF\SPREADSHEETCOMPARE.exe"" " & sTempFile, 0, True) 'Office 365 'Could be this result = WshShell.Run("""C:\Program Files\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft Office\Office16\DCF\SPREADSHEETCOMPARE.EXE"" " & sTempFile, 0, True) result = WshShell.Run("""C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office Tools\Spreadsheet Compare"" " & sTempFile, 0, True) Set WshShell = Nothing