public static function convertCellData(\PHPExcel_Cell $cell) { $ret = array(); $datatype = $cell->getDataType(); if ($datatype === \excel2sql\Type::EXCEL_NUMERIC) { $format = $cell->getStyle()->getNumberFormat()->getFormatCode(); if (array_key_exists($format, \excel2sql\Type::$numeric_convert_map)) { $format = \excel2sql\Type::$numeric_convert_map[$format]; } $ret['type'] = \excel2sql\Type::$numeric_to_sql_map[$format]; $ret['value'] = \PHPExcel_Style_NumberFormat::toFormattedString($cell->getValue(), $format); if ($format === \excel2sql\Type::EXCEL_DATE || $format === \excel2sql\Type::EXCEL_DATETIME || $format === \excel2sql\Type::EXCEL_TIME) { $ret['value'] = "'{$ret['value']}'"; } } else { $ret['type'] = \excel2sql\Type::$excel_to_sql_map[$datatype]; if ($ret['value'] = $cell->getFormattedValue()) { if ($datatype === \excel2sql\Type::EXCEL_STRING || $datatype === \excel2sql\Type::EXCEL_STRING2) { $ret['value'] = "\"" . preg_replace("[\"]", "''", $ret['value']) . "\""; } } else { $ret['value'] = "null"; } } return $ret; }
function getStrToUpper(PHPExcel_Cell $cell) { $b = false; try { $b = mb_strtoupper(trim($cell->getFormattedValue())); } catch (Exception $e) { $b = false; } return $b; }