我有这个代码清单,它将数据导出到此处显示的 excel 文件!,我想使用一个循环来做同样的事情,而不是硬编码它,建议!
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("workbooks/" . $labref . "/" . $labref . ".xlsx");
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()
->setCellValue('I3', $heading)
->setCellValue('I5', 'Standard Preparation For Assay')
->setCellValue('B7', 'Weight')
…………
//Assay Standard Preparation desired
->setCellValue('A8', 'Desired Weight')
->setCellValue('B8', $weight)
->setCellValue('C8', $vf1)
…………………..
//Other values used
->setCellValue('D22', 'Label Claim')
->setCellValue('D23', 'Tabs or Caps Average')
……..
$objPHPExcel->getActiveSheet()->setTitle($heading);
$dir = "workbooks";
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save("workbooks/" . $labref . "/" . $labref . ".xlsx");
}
}