本文介绍了PHPExcel.如何检查当前单元格是否与另一个单元格合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用PHPExcel将Excel文件导入到我的网站.例如,有两个单元格A1和A2都合并了.有没有办法找出A1是否合并到另一个单元格(A2或其他)?
I use PHPExcel to import Excel files to my site. For example, there is two cells, A1 and A2, both merged. Is there a way to to find out is A1 merged to another cell (A2 or other) or not?
推荐答案
$workbook = new PHPExcel;
$sheet = $workbook->getActiveSheet();
$sheet->mergeCells('A1:E1');
$cell = $sheet->getCell('A1');
// Check if cell is merged
foreach ($sheet->getMergeCells() as $cells) {
if ($cell->isInRange($cells)) {
echo 'Cell is merged!'
break;
}
}
由于phpexcel存储有关合并单元格信息的方式,我认为没有更好的解决方案.
I think there isn't better solution because of the way phpexcel stores information about merged cells.
这篇关于PHPExcel.如何检查当前单元格是否与另一个单元格合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!