我有以下代码(使用 PHPExcel):
$inputFileType = 'Excel2007';
$sheetname = 'Upload';
$objReader = PHPExcel_IOFactory::createReader( $inputFileType );
$objReader->setLoadSheetsOnly( $sheetname );
$objPHPExcel = $objReader->load( $fileName );
foreach( $objPHPExcel->_workSheetCollection as $columnMeta )
{
foreach( $columnMeta->_cellCollection->_cellCache as $columnHeader )
{
echo $columnHeader->_value;
}
}
当然,我不能实际使用这些属性或遍历它们,因为它们是 $objPHPExcel 的私有属性......我如何才能真正从这个数组中获取一些东西?
从 print_r 返回的数组片段:
[_workSheetCollection:PHPExcel:private] => Array
(
[0] => PHPExcel_Worksheet Object
(
[_parent:PHPExcel_Worksheet:private] => PHPExcel Object
*RECURSION*
[_cellCollection:PHPExcel_Worksheet:private] => PHPExcel_CachedObjectStorage_Memory Object
(
[_parent:protected] => PHPExcel_Worksheet Object
*RECURSION*
[_currentObject:protected] =>
[_currentObjectID:protected] => AG1
[_currentCellIsDirty:protected] => 1
[_cellCache:protected] => Array
(
[A1] => PHPExcel_Cell Object