Maatwebsite would lost precision when export long integer data, no matter string or int storaged in database.   Implementing \Maatwebsite\Excel\Concerns\WithCustomValueBinder can solve this issue in your export class. You should change dataTypeForValue method like following.

 /** Bind value to a cell.
*
* @param Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell
*
* @return bool
*/
public function bindValue(Cell $cell, $value)
{
// sanitize UTF-8 strings
if (is_string($value)) {
$value = StringHelper::sanitizeUTF8($value);
} elseif (is_object($value)) {
// Handle any objects that might be injected
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m-d H:i:s');
} elseif (!($value instanceof RichText)) {
$value = (string) $value;
}
} // Set value explicit
$cell->setValueExplicit($value, static::dataTypeForValue($value)); // Done!
return true;
} /**
* DataType for value.
*
* @param mixed $pValue
*
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public static function dataTypeForValue($pValue)
{
// Match the value against a few data types
if ($pValue === null) {
return DataType::TYPE_NULL;
} elseif ($pValue === '') {
return DataType::TYPE_STRING;
} elseif ($pValue instanceof RichText) {
return DataType::TYPE_INLINE;
} elseif ($pValue[0] === '=' && strlen($pValue) > 1) {
return DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
return DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) {
return DataType::TYPE_NUMERIC;
} elseif (preg_match('/^[\+\-]?(\d+\\.?\d*|\d*\\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($pValue, '+-');
if (is_string($pValue) && $tValue[0] === '0' && strlen($tValue) > 1 && $tValue[1] !== '.') {
return DataType::TYPE_STRING;
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return DataType::TYPE_STRING;
} return DataType::TYPE_STRING;
} elseif (is_string($pValue)) {
$errorCodes = DataType::getErrorCodes();
if (isset($errorCodes[$pValue])) {
return DataType::TYPE_ERROR;
}
} return DataType::TYPE_STRING;
}

The only one different is in line 60, author return  DataType::TYPE_NUMERIC

maatwebsite lost precision when export long integer data的更多相关文章

  1. C#,NPOI,Export Generic T Data

    1.Nuget 下载NPOI; Install-package NPOI -version 2.4.1 2.下载EF install-package entityframework -version ...

  2. NetSuite SuiteScript 2.0 export data to Excel file(xls)

    In NetSuite SuiteScript, We usually do/implement export data to CSV, that's straight forward: Collec ...

  3. Export SQLite data to Excel in iOS programmatically(OC)

    //For the app I have that did this, the SQLite data was fairly large. Therefore, I used a background ...

  4. Delphi Data Types

    http://docwiki.embarcadero.com/RADStudio/XE6/en/Delphi_Data_Types Integer Data Types Type Descriptio ...

  5. PE Header and Export Table for Delphi

    Malware Analysis Tutorial 8: PE Header and Export Table 2. Background Information of PE HeaderAny bi ...

  6. Data Mover Script Templates

    Datamover is probably the best way to export and import data between PeopleSoft databases and the sc ...

  7. module.exports与exports,export和export default

    还在为module.exports.exports.export和export default,import和require区别与联系发愁吗,这一篇基本就够了! 一.首先搞清楚一个基本问题: modu ...

  8. module.exports,exports,export和export default,import与require区别与联系【原创】

    还在为module.exports.exports.export和export default,import和require区别与联系发愁吗,这一篇基本就够了! 一.首先搞清楚一个基本问题: modu ...

  9. 工具函数判断data为整型字符串

    /** * 如果data是整型字符串,则转为整型,否则原样返回 * @param {*} data 整型字符串 */ export const stringToInt = (data) => { ...

随机推荐

  1. C#中子类对基类方法的继承、重写和隐藏

    提起子类.基类和方法继承这些概念,肯定大家都非常熟悉.毕竟,作为一门支持OOP的语言,掌握子类.基类是学习C#的基础.不过,这些概念虽然简单,但是也有一些初学者可能会遇到的坑,我们一起看看吧.   子 ...

  2. Bug--slfj4依赖冲突

    SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/F:/Spring%20p ...

  3. Spring 与 MyBatis 事务管理源码解析

    用到mybatis便由spring和myabtis集成,SqlSessionFactoryBean(直接负责对mybatis所需环境的创建) ,配置相应的datasource到springConfig ...

  4. 彻底弄懂angularJS表单验证

    常用的表单验证指令 (基本概念) 1. 必填项验证 某个表单输入是否已填写,只要在输入字段元素上添加HTML5标记required即可: <input type="text" ...

  5. Day01_企业权限管理(SSM整合)

    学于黑马程序员和传智播客联合做的教学项目 感谢 黑马程序员官网 传智播客官网 个人根据教程的每天的工作进度的代码和资料 密码:cti5 b站在线视频 微信搜索"艺术行者",关注并回 ...

  6. maven 一些高级用法命令

    发布本地jar到私服 命令 mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=D:\Downloads\OJDBC-Full\ojdbc6.ja ...

  7. 给定两个列表,转换为 DataFrame 类型

    import pandas as pd def get_data(): q1 = [] q2 = [] p1 = input("list 1:") p2 = input(" ...

  8. yield 复习

    1.协程,微型进程: yield 生成器 yield 会保存声明的变量,可以进行迭代 使用 接收函数返回的对象.__next__() next(接收函数返回的对象) .send() 方法 传递给函数中 ...

  9. timeit_list操作测试

    ''' timeit库Timer函数 ''' from timeit import Timer def test1(): l = list(range(1000)) def test2(): l = ...

  10. PHP xml_parse_into_struct() 函数

    定义和用法 xml_parse_into_struct() 函数把 XML 数据解析到数组中. 该函数把 XML 数据解析到 2 个数组中:高佣联盟 www.cgewang.com Value 数组 ...