Hy i'm having a problem with my php excell, i'm having two rows in mydb, but he export only one row from db, if i will insert the thrd row in db it will show me always two....
this is the code
require_once 'Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// Set the active Excel worksheet to sheet 0
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Formulas');
// Initialise the Excel row number
//start of printing column names as names of MySQL fields
$rowNumber = 11;
// Loop through the result set
while ($row = mysql_fetch_object($result)) {
$objPHPExcel->getActiveSheet()
->setCellValue('B11','1')
->setCellValue('C11','2')
->setCellValue('D11','3')
->setCellValue('E11','4')
->setCellValue('F11','L.A')
->setCellValue('G11','L.C')
->setCellValue('H11','L.ING')
->setCellValue('B'.$rowNumber,$row->1)
->setCellValue('C'.$rowNumber,$row->2)
->setCellValue('D'.$rowNumber,$row->3)
->setCellValue('E'.$rowNumber,$row->4)
->setCellValue('F'.$rowNumber,$row->l_a)
->setCellValue('G'.$rowNumber,$row->l_c)
->setCellValue('H'.$rowNumber,$row->l_ing);
$rowNumber++;
}
/**autosize*/
for ($col = 'B'; $col != 'H'; $col++) {
$objPHPExcel->getActiveSheet()->getColumnDimension($col)->setAutoSize(true);
}
/** Borders for all data */
$objPHPExcel->getActiveSheet()->getStyle(
'B11:' .
$objPHPExcel->getActiveSheet()->getHighestColumn() .
$objPHPExcel->getActiveSheet()->getHighestRow()
)->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$gdImage = imagecreatefromjpeg('logo.jpg');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(150);
$objDrawing->setCoordinates('A3');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//end of adding column names
//start while loop to get data
$rowCount = 2;
while($row = mysql_fetch_row($result))
{
$column = 'A';
for($j=1; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, $value);
$column++;
}
$rowCount++;
}
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="piante.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
?>