zoukankan      html  css  js  c++  java
  • Gridview导出成Excel

    在aspx里面加上

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AAAAAAA.aspx.cs" Inherits="AAAAAA" EnableEventValidation="false" %>

    重载一个方法

        public override void VerifyRenderingInServerForm(Control control)
        {
            //这个必不可少
        }

    //先隐藏一些列

            GridView_AdvancePaymentChange.AllowPaging = false;
            bindData();
            GridView_AdvancePaymentChange.Columns[0].Visible = false;
            DateTime dt = System.DateTime.Now;
            string str = dt.ToString("yyyyMMddhhmmss");
            str = "预付款调整表" + str + ".xls";
            Response.ClearContent();
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(str, Encoding.UTF8).ToString());
            Response.ContentType = "application/excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            GridView_AdvancePaymentChange.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();
            GridView_AdvancePaymentChange.AllowPaging = true;
  • 相关阅读:
    toj 2975 Encription
    poj 1797 Heavy Transportation
    toj 2971 Rotating Numbers
    zoj 2281 Way to Freedom
    toj 2483 Nasty Hacks
    toj 2972 MOVING DHAKA
    toj 2696 Collecting Beepers
    toj 2970 Hackle Number
    toj 2485 Card Tric
    js页面定位,相关几个属性
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090523.html
Copyright © 2011-2022 走看看