我正在一个项目中使用 PHPExcel 库来做一些事情。我今天遇到了第一个问题。从 Excel 中读取/写入效果很好,但后来我打算开始从 Excel 工作表中取出东西,然后进入 Mongo。我基本上从 Excel 将一些内容读入数组,然后尝试将该数组保存到 Mongo$collection->insert($array);
我有一个异常告诉我它不能用零字符键插入任何东西。我var_dum()
在我的阵列上做了一个,看看它在世界上的哪个地方得到一个空白键,这就是转储产生的。
array(10)
{
["um"]=> string(2) "EA"
["desc"]=> string(37) "FRAME WELDMENT, NITRATE REMOVAL TANKS"
["vws_num"]=> NULL
["part_num"]=> string(10) "SD-0408-01"
["manufac"]=> object(PHPExcel_RichText)#665 (1)
{
["_richTextElements" : "PHPExcel_RichText" : private]=> array(3)
{
[0]=> object(PHPExcel_RichText_TextElement)#184 (1)
{
["_text":"PHPExcel_RichText_TextElement":private]=> string(23) "VEOLIA WATER SOLUTIONS "
}
[1]=> object(PHPExcel_RichText_Run)#179 (2)
{
["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#183 (12)
{
["_name":"PHPExcel_Style_Font":private]=> string(5) "SWGDT"
["_size":"PHPExcel_Style_Font":private]=> string(2) "10"
["_bold":"PHPExcel_Style_Font":private]=> bool(false)
["_italic":"PHPExcel_Style_Font":private]=> bool(false)
["_superScript":"PHPExcel_Style_Font":private]=> bool(false)
["_subScript":"PHPExcel_Style_Font":private]=> bool(false)
["_underline":"PHPExcel_Style_Font":private]=> string(4) "none"
["_strikethrough":"PHPExcel_Style_Font":private]=> bool(false)
["_color":"PHPExcel_Style_Font":private]=> object(PHPExcel_Style_Color)#186 (4)
{
["_argb":"PHPExcel_Style_Color":private]=> string(8) "FF000000"
["_isSupervisor":"PHPExcel_Style_Color":private]=> bool(false)
["_parent":"PHPExcel_Style_Color":private]=> NULL
["_parentPropertyName":"PHPExcel_Style_Color":private]=> NULL
}
["_parentPropertyName":"PHPExcel_Style_Font":private]=> NULL
["_isSupervisor":"PHPExcel_Style_Font":private]=> bool(false)
["_parent":"PHPExcel_Style_Font":private]=> NULL
}
["_text":"PHPExcel_RichText_TextElement":private]=> string(1) " "
}
[2]=> object(PHPExcel_RichText_Run)#182 (2)
{
["_font":"PHPExcel_RichText_Run":private]=> object(PHPExcel_Style_Font)#189 (12)
{
["_name":"PHPExcel_Style_Font":private]=> string(14) "Century Gothic"
["_size":"PHPExcel_Style_Font":private]=> string(2) "10"
["_bold":"PHPExcel_Style_Font":private]=> bool(false)
["_italic":"PHPExcel_Style_Font":private]=> bool(false)
["_superScript":"PHPExcel_Style_Font":private]=> bool(false)
["_subScript":"PHPExcel_Style_Font":private]=> bool(false)
["_underline":"PHPExcel_Style_Font":private]=> string(4) "none"
["_strikethrough":"PHPExcel_Style_Font":private]=> bool(false)
["_color":"PHPExcel_Style_Font":private]=> object(PHPExcel_Style_Color)#188 (4)
{
["_argb":"PHPExcel_Style_Color":private]=> string(8) "FF000000"
["_isSupervisor":"PHPExcel_Style_Color":private]=> bool(false)
["_parent":"PHPExcel_Style_Color":private]=> NULL
["_parentPropertyName":"PHPExcel_Style_Color":private]=> NULL
}
["_parentPropertyName":"PHPExcel_Style_Font":private]=> NULL
["_isSupervisor":"PHPExcel_Style_Font":private]=> bool(false)
["_parent":"PHPExcel_Style_Font":private]=> NULL
}
["_text":"PHPExcel_RichText_TextElement":private]=> string(14) "& TECHNOLOGIES"
}
}
}
["vendor"]=> NULL
["unit_price"]=> NULL
["list_price"]=> NULL
["multiplier"]=> NULL
["times_req"]=> float(1)
}
为什么我的"manufac"
钥匙拿着一个看起来很疯狂的 PHPExcel 对象?我正在检索每个单元格的内容
$array[$rowIndex][$col] = $cell->getCalculatedValue();
我知道 Excel 工作表的特定单元格中有一个换行符,是这样吗?或者这是否告诉我该单元格上放置了某种奇怪的格式?
我只是想要这个单元格中的文本值,就像所有其他人给我的一样......
提前感谢您的帮助!