欧美色欧美亚洲高清在线观看,国产特黄特色a级在线视频,国产一区视频一区欧美,亚洲成a 人在线观看中文

  1. <ul id="fwlom"></ul>

    <object id="fwlom"></object>

    <span id="fwlom"></span><dfn id="fwlom"></dfn>

      <object id="fwlom"></object>

      C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)

      時(shí)間:2019-05-12 12:17:56下載本文作者:會(huì)員上傳
      簡(jiǎn)介:寫寫幫文庫(kù)小編為你整理了多篇相關(guān)的《C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)》,但愿對(duì)你工作學(xué)習(xí)有幫助,當(dāng)然你在寫寫幫文庫(kù)還可以找到更多《C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)》。

      第一篇:C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)

      C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)

      ///

      /// xml格式生成excel文件并存盤;

      ///

      ///

      生成報(bào)表的頁(yè)面,沒(méi)有傳null

      ///

      數(shù)據(jù)表

      ///

      報(bào)表標(biāo)題,sheet1名

      ///

      存盤文件名,全路徑

      ///

      生成文件后是否提示下載,只有web下才有效

      public static void CreateExcelByXml(System.Web.UI.Page page, DataTable dt, String TableTitle, string fileName, bool IsDown)

      {

      StringBuilder strb = new StringBuilder();

      strb.Append(“

      strb.Append(”xmlns:x=“urn:schemas-microsoft-com:office:excel”“);

      strb.Append(”xmlns=“");

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” “);

      //設(shè)置工作表 sheet1的名稱

      strb.Append(” “ + TableTitle + ” “);

      strb.Append(” “);

      strb.Append(” 285 “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” 3 “);

      strb.Append(” 1 “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” False “);

      strb.Append(” False “);

      strb.Append(” False “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(” 6750 “);

      strb.Append(” 10620 “);

      strb.Append(” 480 “);

      strb.Append(” 75 “);

      strb.Append(” False “);

      strb.Append(” False “);

      strb.Append(” “);

      strb.Append(” “);

      strb.Append(”“);

      strb.Append(” “);

      strb.Append(”

      “);

      //合格所有列并顯示標(biāo)題

      strb.Append(”

      ”);

      strb.Append(“

      ”);

      strb.Append(“

      ”);

      if(dt!= null)

      {

      //寫列標(biāo)題

      int columncount = dt.Columns.Count;

      for(int columi = 0;columi < columncount;columi++)

      {

      strb.Append(“

      ”);

      }

      strb.Append(“

      ”);

      //寫數(shù)據(jù)

      for(int i = 0;i < dt.Rows.Count;i++)

      {

      strb.Append(“

      ”);

      for(int j = 0;j < dt.Columns.Count;j++)

      {

      strb.Append(“

      ”);

      }

      strb.Append(“

      ”);

      }

      }

      strb.Append(“

      ”);

      strb.Append(TableTitle);

      strb.Append(“

      ” + dt.Columns[columi] + “
      ” + dt.Rows[i][j].ToString()+ “
      ”);

      strb.Append(“ ”);

      string ExcelFileName = fileName;

      //string ExcelFileName = Path.Combine(page.Request.PhysicalApplicationPath, path+“/guestData.xls”);

      //報(bào)表文件存在則先刪除

      if(File.Exists(ExcelFileName))

      {

      File.Delete(ExcelFileName);

      }

      StreamWriter writer = new StreamWriter(ExcelFileName, false);

      writer.WriteLine(strb.ToString());

      writer.Close();

      //如果需下載則提示下載對(duì)話框

      if(IsDown)

      {

      DownloadExcelFile(page, ExcelFileName);

      }

      }---------///

      /// web下提示下載

      ///

      ///

      ///

      文件名,全路徑

      public static void DownloadExcelFile(System.Web.UI.Page page, string FileName)

      {

      page.Response.Write(“path:” + FileName);

      if(!System.IO.File.Exists(FileName))

      {

      MessageBox.ShowAndRedirect(page, “文件不存在!”, FileName);

      }

      else

      {

      FileInfo f = new FileInfo(FileName);

      HttpContext.Current.Response.Clear();

      HttpContext.Current.Response.AddHeader(“Content-Disposition”, “attachment;filename=” + f.Name);

      HttpContext.Current.Response.AddHeader(“Content-Length”, f.Length.ToString());

      HttpContext.Current.Response.AddHeader(“Content-Transfer-Encoding”, “binary”);

      HttpContext.Current.Response.ContentType = “application/octet-stream”;

      HttpContext.Current.Response.WriteFile(f.FullName);

      HttpContext.Current.Response.End();

      }

      }

      下載C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式)word格式文檔
      下載C#導(dǎo)出生成excel文件的方法小結(jié)(xml,html方式).doc
      將本文檔下載到自己電腦,方便修改和收藏,請(qǐng)勿使用迅雷等下載。
      點(diǎn)此處下載文檔

      文檔為doc格式


      聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻(xiàn)自行上傳,本網(wǎng)站不擁有所有權(quán),未作人工編輯處理,也不承擔(dān)相關(guān)法律責(zé)任。如果您發(fā)現(xiàn)有涉嫌版權(quán)的內(nèi)容,歡迎發(fā)送郵件至:645879355@qq.com 進(jìn)行舉報(bào),并提供相關(guān)證據(jù),工作人員會(huì)在5個(gè)工作日內(nèi)聯(lián)系你,一經(jīng)查實(shí),本站將立刻刪除涉嫌侵權(quán)內(nèi)容。

      相關(guān)范文推薦