C#导出到excel前导零-堆栈溢出 最近30次来自stackoverflow.com 2024-06-29T08:15:25Z https://stackoverflow.com/feeds/question/20106794 https://creativecommons.org/licenses/by-sa/4.0/rdf https://stackoverflow.com/q/20106794 4 C#导出到excel前导零 用户406151 https://stackoverflow.com/users/406151 2013年11月20日20:54:18Z 2015年4月1日14:32:00Z <p>我有一个导出到excel的函数,但是,在导出到excel时,如何防止excel隐藏前导零?我有以下应用样式的代码,但它不起作用。。。有什么主意吗</p>(第页)<pre><code>响应。清除();回应。缓冲区=真;回应。AddHeader(“content-disposition”,“附件;文件名=GridViewExport.xls”);回应。Charset=“”;回应。ContentType=“application/vnd.ms-excel”;StringWriter sw=新的String Writer();HtmlTextWriter hw=新的HtmlTextWriter(sw);for(int i=0;i&lt;GridView1.Rows.Count;i++){//将文本样式应用于每行GridView1.行[i]。属性。添加(“类”、“文本模式”);}GridView1.渲染控制(hw);//将数字格式化为字符串的样式string style=@“&lt;style&gt;.text{mso-number-format:\@;}&lt;/style&gt;”;回应。书写(风格);回应。输出。写入(sw.ToString());回应。冲洗();回应。结束();</code></pre> https://stackoverflow.com/questions/20106794/-/20107749#20107749 2 Logarr对C#导出到excel前导零的回答 洛加尔 https://stackoverflow.com/users/1127924 2013年11月20日21:49:01Z 2013年11月20日21:49:01Z <p>向下发送脏值,将值作为字符串发送,并在开头使用<code>'</code>(单引号)</p>(第页) https://stackoverflow.com/questions/20106794/-/29393573#29393573 0 zoobiezoobie回答C#导出到excel前导零 动物园动物爱好者 https://stackoverflow.com/users/4596997 2015年4月1日14:32:00Z 2015年4月1日14:32:00Z <p>在字符串前添加“\t”。这将使字符串看起来像是在一个新选项卡中</p>