<asp:gridview id="gvSDPLogDetail" width="100%" runat="server" allowpaging="true" font-size="10px" datakeynames="SDPCompliance" emptydatatext="No Record Found" pagesize="20" ="" cssclass="StandardCompactGridView" pagerstyle-cssclass="StandardGridViewPagination-left" pagersettings-position="TopAndBottom" headerstyle-cssclass="StandardGridViewHead" rowstyle-cssclass="StandardGridViewRow" footerstyle-cssclass="StandardGridViewFooterLight" autogeneratecolumns="False" pagerstyle-horizontalalign="Left" onrowdatabound="gvSDPLogDetail_RowDataBound"> <headerstyle horizontalalign="Center"> <columns> <asp:boundfield datafield="requestID" headertext="RequestID" sortexpression=""> <asp:boundfield datafield="OrderNumber" headertext="Order#" sortexpression=""> <asp:boundfield datafield="Whsecode" headertext="WareHouse" sortexpression=""> <asp:boundfield datafield="ItemID" headertext="ItemID" sortexpression=""> <asp:boundfield datafield="LocationPicked" headertext="LocationPicked" sortexpression=""> <asp:boundfield datafield="LotNo" headertext="Lot#" sortexpression=""> <%--<asp:templatefield> <headertemplate> <table class="table table-bordered table-sm"><thead style="background-color: rgba(139, 111, 78, 1); color: rgba(255, 255, 255, 1)"> <tr><th class="width-150">Location</th> <th class="width-150">Lot#</th> <th class="width-150">Qty</th> </tr></thead> </table> --%> <asp:templatefield> <headertemplate> <table class="table table-bordered table-sm"><tbody><tr style="background-color: rgba(139, 111, 78, 1); color: rgba(255, 255, 255, 1)"> <td style="width: 60px"> Location </td> <td style="width: 60px">Lot#</td> <td style="width: 60px">Qty</td> </tr> </tbody></table> <itemtemplate> <asp:gridview id="gvItem" cssclass="table table-bordered table-sm" runat="server" autogeneratecolumns="false" showheader="false"> <columns> <asp:boundfield itemstyle-cssclass="w-20" datafield="location"> <asp:boundfield itemstyle-cssclass="w-20" datafield="lotno"> <asp:boundfield itemstyle-cssclass="w-20" datafield="qty"> <asp:boundfield datafield="QtyPacked" headertext="QtyPacked" sortexpression=""> <asp:boundfield datafield="PackedOn" headertext="PackedOn" sortexpression=""> <asp:boundfield datafield="Packedby" headertext="PackedBy" sortexpression=""> <asp:boundfield datafield="Status" headertext="Status" sortexpression=""> <asp:boundfield datafield="SDPCompliance" headertext="SDPCompliance" sortexpression="">
void GetDataInExcel(DataSet ds) { var workbook = new ClosedXML.Excel.XLWorkbook(); //foreach (DataTable dt in ds.Tables) { var worksheet = workbook.Worksheets.Add("DetailsData"); worksheet.Cell(1, 1).InsertTable(ds.Tables[0]); worksheet.Columns().AdjustToContents(); worksheet.Columns("13").Hide(); // worksheet.Columns("13").Delete(); } //Export the Excel file. Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment;filename=Details.xlsx"); try { using (MemoryStream MyMemoryStream = new MemoryStream()) { workbook.SaveAs(MyMemoryStream); MyMemoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.End(); } } catch { } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)