开发者

f#/.net read Excel: use ApplicationClass

If I use Microsoft.Office.Interop.Excel.ApplicationClass to read an excel file as below, do I need to explictly close/quit the Excel.applicationClass? like

let xlsread fileName =      
   let app = Microsoft.Off开发者_如何转开发ice.Interop.Excel.ApplicationClass(Visible = false)
   let book = app.Workbooks.Open(fileName)
   ...


I checked an old code of mine, using Interop of Excel 2003, ApplicationClass does have a member called Quit. If you still don't find it, go to MSDN and check for the specific version of Office you use (it might differ between versions).


Using 2007 here:

#r "Microsoft.Office.Interop.Excel.dll"

let xlsread fileName =      
   let app = Microsoft.Office.Interop.Excel.ApplicationClass(Visible = false)
   let book = app.Workbooks.Open(fileName)

   do book.Close()
   do app.Quit()

works fine

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜