Answer the question
In order to leave comments, you need to log in
phpexcel. How to add a template?
Filling out an excel template. It is necessary to write down the line after the last filled one. But the data is entered in line 6. It turns out that i=6, although there are about 200 data in the table. How to do it right?
require_once 'PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load('files/client.xlsx');
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$i=0;
do{
$row=$worksheet->getCellByColumnAndRow($i,$i+1);
$i++;
}while($row!='');
};
echo $i;
$ad_name = 'АД';
$objPHPExcel->getActiveSheet()->setCellValue('A'.$i, $name);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$i, $phone);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$i, $mail);
$objPHPExcel->getActiveSheet()->setCellValue('D'.$i, $input);
$objPHPExcel->getActiveSheet()->setCellValue('E'.$i, $agent);
$objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $ad_name);
$objPHPExcel->getActiveSheet()->setCellValue('G'.$i, ($i + 1));
$objPHPExcel->getActiveSheet()->setCellValue('H'.$i, $date);
$objPHPExcel->getActiveSheet()->setCellValue('I'.$i, $srok);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
$excelFileName = "file.xlsx";
$excelFile = 'files/' . $excelFileName;
$objWriter->save($excelFile);
Answer the question
In order to leave comments, you need to log in
Did it like this:
$i=0;
do{
$row=$sheet->getCellByColumnAndRow('A', $i);
$i++;
}while($row!='');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question