我正在编写一个非常简单的程序。它运行没有任何错误。但是没有任何东西写入 Excel 文件。我在某个地方错了吗?
using Excel = Microsoft.Office.Interop.Excel;
// I already add this reference into my project
public Write()
{
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(Directory.GetCurrentDirectory() + "\\KKK.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
// This is all I want to write to my Excel file
xlWorkSheet.Cells[1, 1] = "input";
xlWorkBook.SaveAs(Directory.GetCurrentDirectory() + "\\KQ" + ThoiGian(), Excel.XlFileFormat.xlWorkbookDefault, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlApp);
releaseObject(xlWorkBook);
releaseObject(xlWorkSheet);
}