getActiveS"/> getActiveS">
Home > Backend Development > PHP Tutorial > PHPExcel 中样式有关问题 求解答

PHPExcel 中样式有关问题 求解答

WBOY
Release: 2016-06-13 10:28:08
Original
988 people have browsed it

PHPExcel 中样式问题 求解答
使用 PHPExcel 打开一个模板

$PHPReader = new PHPExcel_Reader_Excel2007();
$PHPExcel = $PHPReader->load("c://muban.xlsx");

/*这样可以写进去数据*/
$PHPExcel->getActiveSheet()->setCellValue('B1', "B1");
$PHPExcel->getActiveSheet()->setCellValue('B2', "B2");
$PHPExcel->getActiveSheet()->setCellValue('B3', "B3");
$objWriter = new PHPExcel_Writer_Excel2007($PHPExcel);
$objWriter->save("c://test.xlsx");

/*效果如下图所示*/



我现在想知道 如果我想在B4以下的地方在插入数据的话 我怎么获取上面表格的样式呢?

如果数据有几千条 该怎么保留格式 让它循环下去?



------解决方案--------------------
http://www.pkwind.com/insight-into-application-of-php-classes-phpexcel/
------解决方案--------------------
$styleA = $PHPExcel->getActiveSheet()->getStyle("A1");

上面这句话是拷贝A1的样式

$PHPExcel->getActiveSheet()->duplicateStyle($styleA ,"X1");
上面这句是把A1你样式赋予给X1

来分

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template