Answer the question
In order to leave comments, you need to log in
How to configure excel upload on PHPEexcel so that mysql upload starts from the first element and not from the second?
Below code:
$link = mysqli_connect('localhost', 'root', '', 'eshop');
$query1 = mysqli_query($link, "SELECT * FROM goods");
$myrow = mysqli_fetch_array($query1);
require_once './PHPExcel/Classes/PHPExcel.php';
$phpexcel = new PHPExcel();
$page = $phpexcel->setActiveSheetIndex(0);
$page->setCellValue("A1", "id");
$page->setCellValue("B1", "name");
$page->setCellValue("C1", "cost");
$page->setCellValue("D1", "description");
$page->setCellValue("E1", "ord");
$page->setCellValue("F1", "img");
$s = 2;
while($row = mysqli_fetch_array($query1))
{
$s++;
$page->setCellValue("A$s", $row['id']);
$page->setCellValue("B$s", $row['name']);
$page->setCellValue("C$s", $row['cost']);
$page->setCellValue("D$s", $row['description']);
$page->setCellValue("E$s", $row['ord']);
$page->setCellValue("F$s", $row['img']);
}
$page->setTitle("Example");
$objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
$objWriter->save("example.xlsx");
Answer the question
In order to leave comments, you need to log in
$query1 = mysqli_query($link, "SELECT * FROM goods ORDER BY id");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question