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());
  • 相关阅读:
    【转】 MySQL高级知识(一)——基础
    inline元素的间距问题
    ES6对于数组的扩展
    JavaScript的垃圾回收机制
    call() apply() bind()
    防抖和节流
    Promise
    js的事件机制
    Javascript异步操作的异常处理
    JavaScript的事件执行机制及异步
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/3744579.html
Copyright © 2011-2022 走看看