c# - When exporting gridview to xls, the entire row is formatted. How can I limit this to my gridview columns -
I have the gridview that I am exporting in Excel file. When I open Excel file, the color of the optional line Excel spreads to the end of the table, but I only want to format my 6 data columns. How can I limit the formatting?
My export method:
Private Zero Export Grid view () {string attachment = "attachment; filename = activity report.xls"; Response.ClearContent (); Response.AddHeader ("Content-Properties", Attachments); Response.ContentType = "App / MS-Excel"; Stringwright SW = new stringwriter (); HtmlTextWriter htw = new HtmlTextWriter (sw); GrdExportable.Visible = True; GrdExportable.RenderControl (HTW); GrdExportable.Visible = false; Response.Write (sw.ToString ()); Response.End (); }
Well you are not really "exported for excellence", you Sending an HTML table to open it in the browser with the content type of App / MS-Excel, and to take advantage of the fact that Excel will show it as a spreadsheet. If you want this good level of control of Excel formatting you need to create a real Excel file.
Comments
Post a Comment