ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Create(2); IWorksheet worksheet = workbook.Worksheets[0]; List<string[]> quarters = new List<string[]>(); string[] quarter1={"Jan","Feb","Mar"}; string[] quarter2 = { "Apr","May", "Jun" }; string[] quarter3 = { "jul", "aug","sep" }; string[] quarter4 = { "oct", "nov", "dec" }; quarters.Add(quarter1); quarters.Add(quarter2); quarters.Add(quarter3); quarters.Add(quarter4); for (int i = 0; i < quarters.Count; i++) { worksheet.ImportArray(quarters[i], 2 + i, 1, false); } workbook.Version = ExcelVersion.Excel2013; workbook.SaveAs(“Output.xlsx”); workbook.Close(); excelEngine.Dispose(); |