0
下面是我的代碼,我複製工作表,並保存爲新的文件,它實際上節省了沒有我的地方,我們有環境 Office 2003的宏,在Windows Server 2003C#:工作簿另存爲以宏保存在它
但在服務器將其與宏撲救,我不想 環境中的Office 2003,Windows Server 2008的
C#:
try
{
wBook = xCel.Workbooks.Open(ExcelPath);
wSheet = (Excel.Worksheet)wBook.Worksheets.get_Item(1);
wSheet.Copy(Type.Missing, Type.Missing);
wSheet = (Excel.Worksheet)wBook.Sheets[1];
wSheet.SaveAs(ExcelCopyPath);
}
catch {}
finally
{
if (wBook != null)
{
wBook.Close();
wSheet = null;
wBook = null;
Thread.Sleep(500);
}
if (Excel.ProcessID > 0)
{
Process pxCel = Process.GetProcessById(Excel.ProcessID);
pxCel.Kill();
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
try { Marshal.FinalReleaseComObject(wSheet);}
catch {}
try { Marshal.FinalReleaseComObject(wBook);}
catch {}
}
請檢查我的問題......並提出了一些答案。 感謝