我在 Excel Cell Value Return NULL? 這篇文章中有討論過用 OLEDB 來讀取 Excel 資料需要在 Registry 中動一些手腳,前幾天剛好有一個程式需要用到這個功能,而且需要把它包在 NSIS 安裝檔中,下面便是利用 NSIS Script 自動加機碼的語法:
;For Excel Importer (JAMES)
WriteRegStr HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "win32" "$WINDIR\System32\msexcl40.dll"
WriteRegStr HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "DisabledExtensions" "!xls"
WriteRegStr HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "ImportMixedTypes" "Text"
WriteRegBin HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "FirstRowHasNames" 01
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "AppendBlankRows" 0x00000001
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel" "TypeGuessRows" 0x00000000