kkreft
2/27/2014 - 1:56 PM

PHP PHPExcel

require_once('excels/PHPExcel.php');
require_once('excels/PHPExcel/Writer/Excel2007.php');
 
$objPHPExcel = new PHPExcel();
 
$objPHPExcel->getProperties()->setCreator("Ruukki");
$objPHPExcel->getProperties()->setLastModifiedBy("Ruukki");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
 
 
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'ID');
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Imię');
$objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Nazwisko');
$objPHPExcel->getActiveSheet()->SetCellValue('D1', 'Email');
$objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Nazwa firmy');
$objPHPExcel->getActiveSheet()->SetCellValue('F1', 'Miasto');
$objPHPExcel->getActiveSheet()->SetCellValue('G1', 'Stanowisko');
 
$row = 1;
 
foreach($to_dump as $user) {
            $row++;
            $objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $user['id']);
            $objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $user['imie']);
            $objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $user['nazwisko']);
            $objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, $user['email']);
            $objPHPExcel->getActiveSheet()->SetCellValue('E'.$row, $user['nazwa_firmy']);
            $objPHPExcel->getActiveSheet()->SetCellValue('F'.$row, $user['miasto']);
            $objPHPExcel->getActiveSheet()->SetCellValue('G'.$row, $user['stanowisko']);
}
 
 
$objPHPExcel->getActiveSheet()->setTitle('Simple');
 
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('zgloszenia.xlsx');