Пример #1
0
    /// <summary>
    /// Order ListItem Buttton Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButOrderLineItemsDownload_Click(object sender, EventArgs e)
    {
        DataDownloadAdmin csv = new DataDownloadAdmin();
        OrderAdmin _OrderAdmin = new OrderAdmin();

        string Orderid = Convert.ToString(OrderNumber.Text);
        DataSet OrderLineItems = _OrderAdmin.GetOrderLineItemsByOrderId(Orderid);

        if (OrderLineItems.Tables[0].Rows.Count > 0)
        {
            string strData = csv.Export(OrderLineItems, true, tabDelimeter);

            byte[] data = ASCIIEncoding.ASCII.GetBytes(strData);

            Response.Clear();
            // Set as Excel as the primary format
            Response.AddHeader("Content-Type", "application/Excel");

            Response.AddHeader("Content-Disposition", "attachment;filename=OrderLineItems.csv");
            Response.ContentType = "application/vnd.xls";
            Response.BinaryWrite(data);

            Response.End();
        }
        else
        {
            ltrlError.Text = "* No Orders to download";
            return;
        }
    }