Excel xls檔案轉換xlsx

  • 1307
  • 0
  • C#
  • 2017-08-09

Excel xls檔案轉換xlsx

using Microsoft.Office.Interop.Excel;


string fileName = @"C:\Book2.xlsx";
string svfileName = @"C:\Book2.xls";
object oMissing = Type.Missing;
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(fileName, oMissing, oMissing,
             oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
wb.SaveAs(svfileName, XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
app.Quit();

補充說明,app.Quit() 後 excel.exe程式依舊存在工作管理員內,就需要以下語法呼叫GC來回收程式

app.Quit(ref missing, ref missing, ref missing);
app = null;
GC.Collect();
GC.WaitForPendingFinalizers();

可參考
http://www.kuqin.com/office/20070909/970.html

 

興滿逸筑2013年全新完工,位於恆春鎮外圍離市區只要2分鐘車程,有豪華的外觀、有美麗的庭院、也有溫馨舒適的房間,這裡車流量不多,空氣不錯,適合家族或成群結黨的朋友們一同旅遊的好地方。

http://sinmaniz.tw/index.html