How to make a simple Excel Spreadsheet?

Home Forums SpreadsheetML How to make a simple Excel Spreadsheet?

Tagged: , ,

This topic contains 2 replies, has 2 voices, and was last updated by  Eric White 8 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3571

    rogersb
    Participant

    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

    #3582

    rogersb
    Participant

    https://closedxml.codeplex.com/ Seems like to those wanting to find solutions, this is the place to go

    #3687

    Eric White
    Keymaster

    I also have heard good things about https://closedxml.codeplex.com/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.