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. redis,rabbitmq,SqlAlchemy

    redis发布和订阅

  2. c++ string类find总结

    c++ string类的find:1.find string s = "My cat's breath smells like cat food."; int a=s.find(& ...

  3. LQB2013A01高斯日记

    诶,今天发生了点不是很开心的事.说实话挺影响心情的啊(谁遇见这种事不生气呢啊啊啊啊) 但是不能水更,还是得好好更新呀. 这个题居然直接用excel哈哈哈哈 那,,就这样吧!

  4. 2020HDU多校第三场 1005 Little W and Contest

    Little W and Contest Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/O ...

  5. PHP 中的字符串变量

    PHP 字符串变量 字符串变量用于存储并处理文本. PHP 中的字符串变量 字符串变量用于包含有字符的值. 在创建字符串之后,我们就可以对它进行操作了.您可以直接在函数中使用字符串,或者把它存储在变量 ...

  6. Unicode 字符串

    Unicode 字符串 Python 中定义一个 Unicode 字符串和定义一个普通字符串一样简单:高佣联盟 www.cgewang.com >>> u'Hello World ! ...

  7. Python程序设计pdf|网盘下载内附提取码

    点击此处下载提取码:5o7z 本书提出了以理解和运用计算生态为目标的Python语言教学思想,不仅系统讲解了Python语言语法,同时介绍了从数据理解到图像处理的14个Python函数库,向初学Pyt ...

  8. springMVC 获取request参数

    持续补充............ GET 常用的:@PathVariable  @RequestParam   request.getParameter POST 常用的:@ResponseBody  ...

  9. Kaggle-pandas(2)

    Intndexing-selecting-assigning 教程 介绍选择要处理的pandas DataFrame或Series的特定值是几乎将要运行的任何数据操作中的一个隐含步骤,因此在Pytho ...

  10. SpringBoot整合Shiro自定义Redis存储

    Shiro Shiro 主要分为 安全认证 和 接口授权 两个部分,其中的核心组件为 Subject. SecurityManager. Realms,公共部分 Shiro 都已经为我们封装好了,我们 ...