我试图使用PHP和symfony将数组导出为XLS文件,如下面的代码所示。创建XLS文件后,我只能得到数组的最后一行,并将其显示在我的文件的第一行。看来“lignes”变量不会增加。我无法弄清楚什么是错,任何人都可以帮忙吗?使用php和symfony从数组创建Excel文件
foreach ($adresses as $ad){
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('A' . $lignes, $ad->getId());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('E' . $lignes, $ad->getTypeVoie());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('F' . $lignes, $ad->getVoie());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('G' . $lignes, $ad->getTypeQuartier());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('H' . $lignes, $ad->getQuartier());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('I' . $lignes, $ad->getCodePostale());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('K' . $lignes, $ad->getPays());
$phpExcelObject->setActiveSheetIndex(0)->setCellValue('J' . $lignes, $ad->getVille());
$lignes++;
}
$writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel2007');
$writer->save($fichier->getWebPathOut());
'$法分++'你的循环里面....这是行号,你永远不会改变它在 –