Hi
I have used openxml for making custom word documents before.
Now? The goal is to learn and create Excel spreadsheets. Here an MVC c# example to make an .xls that fails to open:
public ActionResult ExportData()
{
GridView gv = new GridView();
gv.DataSource = db.Studentrecord.ToList();
gv.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=Marklist.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
return RedirectToAction("StudentDetails");
}
So it can “make” what gets forced into an Excel file, it downloads but opening it gets an error message, have to click yes to open anyway. This is just 6 columns and maybe 100 rows/records based on whats in the database. I have searched for a couple hours on the site and anything I can find, but am not finding it, want to put MVC code in there and have it create an excel file.
How is this done?
thanks