programing

int {DefaultValueBinder} 유형의 값에서 어레이 오프셋에 액세스하려고 합니다.php line 82 }

batch 2023. 6. 30. 22:12
반응형

int {DefaultValueBinder} 유형의 값에서 어레이 오프셋에 액세스하려고 합니다.php line 82 }

엑셀 파일을 다운로드하는 엑셀로 내보내기 버튼이 있습니다.그러나 클릭하면 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) {

(!is_int($pValue) && $pValue[0] === '=' && strlen($pValue) > 1)작동해야 합니다. $pValue[0]정수에서는 작동하지 않으므로 계속하기 전에 int인지 확인하십시오.

라이브러리에서 파일을 업데이트했는데 php 7.4에서 작동합니다. 업데이트된 코드 라이브러리를 확인하십시오.

Google 드라이브 링크

언급URL : https://stackoverflow.com/questions/62554098/trying-to-access-array-offset-on-value-of-type-int-defaultvaluebinder-php-line

반응형