如何使用Merge_range函数使用Spreadsheet :: WriteExcel合并单元格? [英] How to merge cells using Spreadsheet::WriteExcel using Merge_range function?
问题描述
我使用了 Spreadsheet :: WriteExcel 用于创建电子表格报告.
I have used Spreadsheet::WriteExcel for creating spreadsheet report.
我尝试使用merge_range()函数合并某些单元格.
I tried to merge some cells using merge_range() function.
$ worksheet-> merge_range(3,5,9,4,$ title, $ format); [OR]
$worksheet->merge_range(3,5,9,4,$title, $format); [OR]
$ worksheet-> merge_range('E3:I4',$ title, $ format);
$worksheet->merge_range('E3:I4',$title, $format);
$ worksheet-> write('F6',"LANGUAGE",$ format);
$worksheet->write('F6',"LANGUAGE",$format);
它显示如下错误消息
错误:请参阅 文档.以前不能使用 非合并单元格中的合并格式
Error: refer to merge_range() in the documentation. Can't use previously merged format in non-merged cell
如何解决此问题.如果我使用write()
..那一次只显示错误.如果那时我没有使用任何写入功能,则不会显示上述错误消息,并且单元将合并.
How to solve this. if I used write()
.. that time only it shows the error. if I didn't used any write functions that time the above error message is not showing and the cells are merged.
推荐答案
If you see the documentation of Spreadsheet::WriteExcel module, it states :
警告::与merge_range()方法调用一起使用的format对象在内部被标记为与合并范围相关联.在非合并单元格中使用合并格式是致命错误.相反,您应该对合并的单元格和非合并的单元格使用单独的格式.此限制将在以后的版本中删除.
WARNING: The format object that is used with a merge_range() method call is marked internally as being associated with a merged range. It is a fatal error to use a merged format in a non-merged cell. Instead you should use separate formats for merged and non-merged cells. This restriction will be removed in a future release.
这意味着不要使用
$worksheet->write('F6',"LANGUAGE",$format);
为合并的单元格设置两种格式,对于非合并的单元格设置另一种格式.
Make two format one for merged cell other for non-merged cell.
问题将会解决.
这篇关于如何使用Merge_range函数使用Spreadsheet :: WriteExcel合并单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!