zoukankan      html  css  js  c++  java
  • C#中如何防止Excel做科学计算法转换

        C#中如何防止Excel做科学计算法转换

         string style = @"<style>.text{mso-number-format:@;}</style>";//注意这是样式,不需要修改可直接使用


                Response.Clear();
                Response.Buffer = true;


                Response.Charset = "utf-8";
                Response.AppendHeader("Content-Disposition", "attachment;filename=plandetail.xls");
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 
                System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
                this.GridView2.RenderControl(oHtmlTextWriter);


                Response.Output.Write(style);//这里很重要不写到文件里是无法应用样式的。


                Response.Output.Write(oStringWriter.ToString());
                Response.Flush();
                Response.End();

  • 相关阅读:
    我容易么?
    意译和音译
    请教博客园高手:msn老是掉线的问题
    超市里最安全的食品
    两类人
    只要牵了手,就请不要轻易的说分手
    Palm Treo 650 .VS. Dopod P800
    强烈推荐一健康食品:紫红薯
    年底三篇
    奶奶,走好!
  • 原文地址:https://www.cnblogs.com/jesn/p/4208317.html
Copyright © 2011-2022 走看看