C#中怎么導(dǎo)出數(shù)據(jù)到Excel,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
目前創(chuàng)新互聯(lián)已為上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、阿拉山口網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
public void CreateExcel1(DataSet ds, string typeid, string FileName) { HttpResponse resp = System.Web.HttpContext.Current.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName); resp.Charset = "UTF-8"; string colHeaders = "", ls_item = ""; int i = 0; DataTable dt = ds.Tables[0]; DataRow[] myRow = dt.Select(""); if (typeid == "1") { colHeaders += "
" + dt.Columns[i].Caption.ToString() + " | "; colHeaders += "" + dt.Columns[i].Caption.ToString() + " |
" + row[i].ToString().Replace("t", "") + " | "; ls_item += "" + row[i].ToString().Replace("t", "") + " |