1、新增引用
Microsoft.Office.Interop.Excel;
2、使用名稱空間
using Microsoft.Office.Interop.Excel;
3、填充EXCEL單元格方法
private void OpenExcel()
{
Microsoft.Office.Interop.Excel.Application excel = new ApplicationClass();
excel.Visible = true;
excel.DisplayAlerts = false;
excel.Workbooks.Open(@”D:EXCELIQC檢驗報表.xlsx”);
((_Worksheet) excel.Worksheets[1]).Activate();
excel.get_Range(“F7”,Type.Missing).Value = “測試Excel寫入資料”;
excel.get_Range(“F7”, Type.Missing).Font.Color = Color.Blue;
excel.ActiveWorkbook.Save();
excel.Application.Workbooks.Close();
excel.Application.Quit();
excel.Quit();
GC.Collect();
}