首页 > 解决方案 > 将 html mysql 表导入到 php 中。大数字在excel文件中转换为指数

问题描述

我从 mysql 表中以 html 格式获取数据,然后使用 php 将其导出到 excel。Mysql 表包含 bigint stud_id,就像201927341302805000我导出到 excel 时一样,它会显示为2.01927E+17. 所有stud_id表格都将转换为与 相同的数字2.01927E+17

用于导出到 excel 的脚本:

  <script type="text/javascript">
var tableToExcel = (function() {
  var uri = 'data:application/vnd.ms-excel;base64,'
    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
  return function(table, name) {
    if (!table.nodeType) table = document.getElementById(table)
    var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
    window.location.href = uri + base64(format(template, ctx))
  }
})()
</script>

当我将 mysql 文件导出到 excel 时,我想发送 bigint 数字。

标签: phpmysql

解决方案


推荐阅读