本文整理汇总了PHP中PHPExcel::getNamedRange方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel::getNamedRange方法的具体用法?PHP PHPExcel::getNamedRange怎么用?PHP PHPExcel::getNamedRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel
的用法示例。
在下文中一共展示了PHPExcel::getNamedRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSimple
public function testSimple()
{
$data = ['ROOT' => ['LEVEL1' => [['LEVEL1_CAPTION' => '1'], ['LEVEL1_CAPTION' => '2']]]];
$namedRange = $this->output->getNamedRange('ROOT');
$this->sut->write($data, $namedRange);
$this->output->setActiveSheetIndexByName('TEMPLATE');
$this->output->removeSheetByIndex($this->output->getActiveSheetIndex());
$excelWriter = \PHPExcel_IOFactory::createWriter($this->output, 'Excel2007');
$excelWriter->save(__DIR__ . '/../metadata/output/verticalrangewritertest.xlsx');
}
示例2: date
// 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');