foreach($objPHPExcel->getWorksheetIterator() as $worksheet)
{
echo '<table border ="1px" width ="50%" float:left overflow:auto>' . "\n";
foreach ($objWorksheet->getRowIterator() as $row) {
echo '<tr>' . "\n";
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$y =0;
foreach ($cellIterator as $cell) {
$promptData[$x][$y] = $cell->getValue();
$cellIndex = $cell->getCoordinate();
$promptData[$x][$y]['Index'] = $cellIndex;
echo '<td>' . $promptData[$x][$y] . '</td>' .'<td>' . $cell->getCalculatedValue() . '</td>' . "\n";
$y++;
}
$x++;
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
}
我想存儲單元的索引我使用 $ promptData [$ X] [$ y的] [ '索引'] = $ 2D陣列中添加鍵值爲2D陣列cellIndex; 但它不起作用任何人都可以幫忙。使用在PHP foreach循環
我得到錯誤作爲數組字符串轉換$ promptData [$ x] [$ y] ['Index'] = $ cellIndex; –
正如錯誤說試圖print_r它知道它的結構 – Osama