Beispiel #1
0
// Add some data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Lastname:');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Fullname:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Maarten');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Balliauw');
$objPHPExcel->getActiveSheet()->setCellValue('B3', '=B1 & " " & B2');
// Define named ranges
echo date('H:i:s') . " Define named ranges\n";
$objPHPExcel->addNamedRange(new PHPExcel_NamedRange('PersonName', $objPHPExcel->getActiveSheet(), 'B1'));
$objPHPExcel->addNamedRange(new PHPExcel_NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2'));
// Rename named ranges
echo date('H:i:s') . " Rename named ranges\n";
$objPHPExcel->getNamedRange('PersonName')->setName('PersonFN');
// Rename sheet
echo date('H:i:s') . " Rename sheet\n";
$objPHPExcel->getActiveSheet()->setTitle('Person');
// Create a new worksheet, after the default sheet
echo date('H:i:s') . " Create new Worksheet object\n";
$objPHPExcel->createSheet();
// Add some data to the second sheet, resembling some different data types
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Lastname:');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Fullname:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', '=PersonFN');
$objPHPExcel->getActiveSheet()->setCellValue('B2', '=PersonLN');
$objPHPExcel->getActiveSheet()->setCellValue('B3', '=PersonFN & " " & PersonLN');