Как экспортировать данные из C# в Excel
Код:
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;
object template = Missing.Value;
Excel.Application excel = new Excel.ApplicationClass();
excel.Visible = true;
Excel.Workbook workbook = excel.Workbooks.Add(template); // место ошибки
Excel.Worksheet sheet = (Excel.Worksheet)workbook.Sheets["Sheet1"];
sheet.Name = "QWERTY";
sheet.Cells[1, 2] = "asd"
using Excel = Microsoft.Office.Interop.Excel;
object template = Missing.Value;
Excel.Application excel = new Excel.ApplicationClass();
excel.Visible = true;
Excel.Workbook workbook = excel.Workbooks.Add(template); // место ошибки
Excel.Worksheet sheet = (Excel.Worksheet)workbook.Sheets["Sheet1"];
sheet.Name = "QWERTY";
sheet.Cells[1, 2] = "asd"