public void WriteSample()
{
Excel.Application excelApp = new Excel.Application();
if (excelApp != null)
{
Excel.Workbook excelWorkbook = excelApp.Workbooks.Add();
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelWorkbook.Sheets.Add();
excelWorksheet.Cells[1, 1] = "Value1";
excelWorksheet.Cells[2, 1] = "Value2";
excelWorksheet.Cells[3, 1] = "Value3";
excelWorksheet.Cells[4, 1] = "Value4";
excelApp.ActiveWorkbook.SaveAs(@"C:\abc.xls", Excel.XlFileFormat.xlWorkbookNormal);
excelWorkbook.Close();
excelApp.Quit();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(excelWorksheet);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(excelWorkbook);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(excelApp);
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
https://www.codeproject.com/Questions/141434/How-to-save-excel-files-using-c
http://csharpexamples.com/c-write-data-excel-file/
https://www.cnblogs.com/wang_yb/archive/2010/06/03/1750419.html