zoukankan      html  css  js  c++  java
  • 【Vegas原创】导出Excel时,如何将数字格式转为文本格式?(07.12.13 Update)

    DataGrid:

    Asp.Net WebForm中DataGrid导出的时候,在ItemDataBound内 

    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 

    e.Item.Cells[
    0].Attributes.Add("style","vnd.ms-excel.numberformat:@"); 
    }
     

    如果在WinForm内则可以 
    Excel.Range range 
    = (Excel.Range)worksheet.Cells[1,1]; 
    range.NumberFormat 
    = Excel.XlParameterDataType.xlParamTypeUnknown; 

    VB:

     If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                e.Item.Cells(
    1).Attributes.Add("style""vnd.ms-excel.numberformat:@")
            
    End If





    如果是Label,则在<td>的style中加上:

    <td style="height: 22px; vnd.ms-excel.numberformat:@" bgcolor="#eff3fb">
         
    <asp:Label ID="Label2"  runat="server" Text="Label"></asp:Label></td>


    如果是Gridview,(07.12.13 Update)
    则需要在后台打印click事件代码中加两句话:


    //  More Codes


    string style = @"<style> .text { mso-number-format:\@; } </script> "

    Response.Write(style); 


    Response.Output.Write(oStringWriter.ToString());
  • 相关阅读:
    Intellij IDEA13 创建多模块Maven项目
    oracle锁
    oracle rac负载均衡
    awk命令
    政务外网、政务专网、政务内网和互联网
    图片切换实现选中-未选中效果
    生成带logo 的二维码
    控制input为number时样式
    移动端适配的解决方法?
    input-checkbox选中及非选中样式设置
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/3744579.html
Copyright © 2011-2022 走看看