您好我其實這樣做是在那裏工作。我用下面的代碼寫入到一個特定的細胞中已經存在的Excel工作表:
http://rmanimaran.wordpress.com/2011/02/15/programmatically-insert-to-existing-excel-file-using-c/
:
string path = @"C:\ProjectTesting\TwsDde.xlsm";
oXL = new Microsoft.Office.Interop.Excel.Application();
oXL.Visible = true;
oXL.DisplayAlerts = false;
mWorkBook = oXL.Workbooks.Open(path, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
//Get all the sheets in the workbook
mWorkSheets = mWorkBook.Worksheets;
//Get the allready exists sheet
mWSheet1 = (Microsoft.Office.Interop.Excel.Worksheet)mWorkSheets.get_Item("Basic Orders");
Microsoft.Office.Interop.Excel.Range range= mWSheet1.UsedRange;
mWSheet1.Cells[12, 1] = "bla bla bla";
此代碼是從這篇文章也繼續保存Excel工作表中取
我希望這可以幫助別人。
感謝
伯納德
這可能會幫助你一點http://www.codeproject.com/Questions/156324/Saving-excel-workbook-in-windows-service-C – Sakthivel 2013-02-20 11:55:28
由於這是相當有幫助。我得到它的工作,但由於我的聲譽,無法發佈答案另外5個小時 – user1948787 2013-02-20 14:02:19
這聽起來不錯:) – Sakthivel 2013-02-21 05:21:32