您好我其实这样做是在那里工作。我用下面的代码写入到一个特定的细胞中已经存在的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