当前位置: 首页 > news >正文

[Asp.Net]GridView导出Excel长数字显示成科学计数

类似身份证纯数字的格式时 ,excel默认是数字格式 变成了科学计数法 ,

GridView:RowDataBound

添加e.Row.Cells[2].Attributes.Add(“style”, “vnd.ms-excel.numberformat:@;”);

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //你的身份证是第3列,只需将其格式化为字符即可。 e.Row.Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:@;");        } 
}

Repeater

添加:
style=“vnd.ms-excel.numberformat:@”

<th scope="col"><%# DataBinder.Eval(Container.DataItem,"[性别]") %></th><th scope="col" style="vnd.ms-excel.numberformat:@"><%# DataBinder.Eval(Container.DataItem,"[出生日期]") %></th>
<th scope="col" style="vnd.ms-excel.numberformat:@"><%# (DataBinder.Eval(Container.DataItem,"[身份证号码]")).ToString() %></th><th scope="col"><%#(DataBinder.Eval(Container.DataItem,"[手机号码]")).ToString()  %></th>

相关文章:

  • 深度剖析 MCP SDK 最新版:Streamable HTTP 模式
  • 【自定义类型-结构体】--结构体类型,结构体变量的创建和初始化,结构体内存对齐,结构体传参,结构体实现位段
  • 云管理深度解析:资源限额、监控策略与多厂商适配方案
  • C++ 忘掉std::cout吧,fmt和spdlog的结合
  • Python爬虫设置IP代理
  • 无法选择最佳操作符(APP) 目录
  • 电子电路:什么是滤波器,什么优势高通滤波器?
  • Photo Sphere Viewer 的迷你地图插件map-plugin
  • 特殊的完全平方数
  • 常见激活函数
  • 表面遮盖显示需要提取器官吗
  • 通过vue-pdf和print-js实现PDF和图片在线预览
  • Cookie、Session、JWT
  • AUTOSAR图解==>AUTOSAR_SRS_MCUDriver
  • 17、Python对象操作全解析:同一运算符、成员运算符与整数缓存机制实战
  • 论文学习记录之《DiffusionVel》
  • Python+requests实现接口自动化测试
  • Linux中的tty与login之间的关系
  • RHCSA Linux 系统 硬盘管理
  • AI编程对传统软件开发的冲击和思考
  • 网站推销策划方案/拉新平台哪个好佣金高
  • 免费做封面网站/宜兴百度推广
  • wordpress子目录 多站点/360seo
  • 小男孩做爰网站/企业seo排名
  • 电子业网站建设/杭州排名推广
  • 国外优秀个人网站欣赏/域名注册信息查询