How to export the web grid data in excel with formatted manner
After importing excel data is not coming in formatted manner
- WebGrid grid = new WebGrid(model.TicketReportDataModel, rowsPerPage: model.PageSize, canPage: true);
- string gridData = grid.GetHtml(
- columns: grid.Columns(
- grid.Column(columnName: "ticketNo", header: "Ticket No", canSort: false),
- grid.Column(columnName: "Summary", header: "Title", canSort: false),
- grid.Column(columnName: "Contact_Name", header: "Contact", canSort: false),
- grid.Column(columnName: "SR_Status", header: "Status", canSort: false),
- grid.Column(columnName: "Site_Name", header: "Site Name", canSort: false),
- grid.Column(columnName: "SR_Type_Description", header: "Type", canSort: false),
- grid.Column(columnName: "Company", header: "Company", canSort: false),
- grid.Column(columnName: "Board", header: "Board", canSort: false),
- grid.Column(columnName: "Discussion", header: "Discussion", canSort: false),
- grid.Column(columnName: "Resolution", header: "Resolution", canSort: false),
- grid.Column(columnName: "SubType_Description", header: "SubType", canSort: false),
- grid.Column(columnName: "Date_Entered", header: "Date Entered", canSort: false))).ToString();
-
- Response.ClearContent();
- Response.AddHeader("content-disposition", "attachment; filename=TicketList.xls");
- Response.ContentType = "application/octet-stream";
- Response.Write(gridData);
- Response.End();