第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么我的導(dǎo)出到 Excel 功能會(huì)導(dǎo)出整個(gè)頁面?

為什么我的導(dǎo)出到 Excel 功能會(huì)導(dǎo)出整個(gè)頁面?

C#
呼喚遠(yuǎn)方 2023-09-24 16:30:56
我正在嘗試導(dǎo)出顯示在窗口(模式)中的網(wǎng)格視圖,但它導(dǎo)出整個(gè)頁面。public void ExportToXLS(GridView gv){    gv.AllowPaging = false;    HttpContext.Current.Response.Buffer = true;    HttpContext.Current.Response.ClearContent();    HttpContext.Current.Response.ClearHeaders();    HttpContext.Current.Response.Clear();    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=GridView.xls");    HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";    System.IO.StringWriter stringWrite = new System.IO.StringWriter();    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);    GridView gvExp = new GridView();    gvExp = gv;    gvExp.RenderControl(htmlWrite);    HttpContext.Current.Response.Write(stringWrite.ToString());    HttpContext.Current.Response.Flush();    HttpContext.Current.Response.Close();    HttpContext.Current.Response.End();}
查看完整描述

1 回答

?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

問題是我在 gridview 中有一個(gè)鏈接按鈕,它導(dǎo)致頁面無法正確呈現(xiàn)。


解決方案很簡(jiǎn)單,我只是刪除了鏈接按鈕認(rèn)為我確實(shí)不需要它們的列。


public void ExportToXLS(GridView gv)

{


    GV.Columns[4].Visible = false;

    GV.Columns[5].Visible = false;


    gv.AllowPaging = false;

    HttpContext.Current.Response.Buffer = true;

    HttpContext.Current.Response.ClearContent();

    HttpContext.Current.Response.ClearHeaders();

    HttpContext.Current.Response.Clear();

    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=GridView.xls");

    HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

    System.IO.StringWriter stringWrite = new System.IO.StringWriter();

    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

    GridView gvExp = new GridView();

    gvExp = gv;

    gvExp.RenderControl(htmlWrite);

    HttpContext.Current.Response.Write(stringWrite.ToString());

    HttpContext.Current.Response.Flush();

    HttpContext.Current.Response.Close();

    HttpContext.Current.Response.End();

}

GV.Columns[ ].Visible = false;一開始的代碼行剛剛解決了我的整個(gè)問題。


查看完整回答
反對(duì) 回復(fù) 2023-09-24
  • 1 回答
  • 0 關(guān)注
  • 232 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)