I'm trying to do something like this:
I'm trying to add data in excel sheet. This is done correctly only if I add data to cells in first column. After that file name appears with the cells data. For example if the cell is C5, it'll append 4 file names to every input and then the data. Can someone help me with what I'm doing wrong?
public void Create()
{
string filepath = string.Empty;
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2016;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet namedSheet = workbook.Worksheets[0];
namedSheet.Range["A1"].Text = "Hey there";
namedSheet.Range["A2"].Text = "Good Morning";
namedSheet.Range["A6"].Text = "Here I am!";
namedSheet.Range["B5"].Text = "1";
MemoryStream ms = new MemoryStream();
workbook.SaveAs(ms, "0.xlsx");
byte[] bytes = ms.ToArray();
ms.Flush();
ms.Close();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=foo.xls");
Response.AddHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
}
}
Hey there0.xlsx
Good Morning0.xlsx
0.xlsx1
Here I am!0.xlsx
Created with a trial version of Syncfusion Essential XlsIO