gpt4 book ai didi

php - 尝试访问 int 类型值的数组偏移量 { DefaultValueBinder.php 第 82 行}

转载 作者:行者123 更新时间:2023-12-04 19:45:19 25 4
gpt4 key购买 nike

我有一个导出到 excel 按钮,可以下载 excel 文件。
但是,当我单击它时,它会显示错误为 试图访问 int 类型值的数组偏移量
我的代码是这样的:

public static function dataTypeForValue($pValue = null)
{
// Match the value against a few data types
if ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue[0] === '=' && strlen($pValue) > 1) { //error comes in this line
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($pValue, '+-');
if (is_string($pValue) && $tValue[0] === '0' && strlen($tValue) > 1 && $tValue[1] !== '.') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR;
}

return PHPExcel_Cell_DataType::TYPE_STRING;
}
}
有什么办法可以解决这个..?

最佳答案

在 PHPExcel 文件“DefaultValueBinder.php”中,替换第 82 行:

} elseif ($pValue[0] === '=' && strlen($pValue) > 1) {
具有以下内容:
} elseif (0 === strpos($pValue, '=') && strlen($pValue) > 1) {

关于php - 尝试访问 int 类型值的数组偏移量 { DefaultValueBinder.php 第 82 行},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62554098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com