PhpExcel-如何在N行之后插入同一行? [英] PhpExcel - How insert the same row after row N?

查看:150
本文介绍了PhpExcel-如何在N行之后插入同一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有php模板.这是一个空表(T0行),底部有一些页脚. 从php我尝试填写表格,但是如果我有T1行(T1> T0),那么麻烦Appers.

I have php template. this is a empty table (T0 rows) with some footer at the bottom. From php i try to fill the table, but if i had T1 rows (T1 > T0) then trouble appers.

我相信空表应该包含一个空行.而且我们知道该行号. 然后,我们将此行复制(插入相同的行)T1次并填充空白表.页脚下降.一切都会好起来

I beleve that empty table should contains one empty row. And we know this row number. Then we copy this row (insert the same rows) T1 times and fill empty table. Footer goes down. And everything will be ok

给我一​​个例子,我该怎么做.谢谢.

Give me an example, how i can do this. Thank you.

PhpExcel 1.7.6

PhpExcel 1.7.6

推荐答案

只需复制@markBaker所说的内容(以便我们可以将解决方案设置为答案):

Just copying what @markBaker said (so that we can set the solution as an answer):

//Insert 10 new rows between rows 1 and 2 
$objPHPExcel->getActiveSheet()->insertNewRowBefore(2,10); 

现在将第2行的样式应用于插入的行:

Now applying the style of the row 2 to the inserted rows:

$objPHPExcel->getActiveSheet()->duplicateStyle($objPHPExcel->getActiveSheet()->getStyle('A1'),'A2:A10'); 

这篇关于PhpExcel-如何在N行之后插入同一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆