php - 将 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 数字。
解决方案
推荐阅读
- bash - 以防万一,通过修改重用函数
- spring - 如何忽略杰克逊添加的默认属性?
- python - 如何在 Azure 上安排 Python 脚本的执行
- java - 是否可以在抛出异常时自动调用内部异常方法?
- firebase - 如何安全地将经过身份验证的用户 UID 添加到 Firestore 文档中?
- javascript - 如何检查未定义的属性或更好地绕过它
- python - Django:如果字段是特定值,则腾出唯一名称
- bash - 用于发送 SMS 的 Zabbix 媒体类型脚本不起作用
- javascript - 或 javascript 中的短路无法按预期工作
- timer - zmq_poll 是如何详细工作的,在哪些情况下我需要它?