PHPExcel Sumif and Skip

ε祈祈猫儿з 提交于 2019-12-19 12:04:40

问题


I just want to ask if there's a function in excel/phpexcel that can SUM a range of cells but skip to add every one cell.

Ex. Range is A1:G1 and it will only sum A1+C1+E1+G1 skipping every 1 cell.

Or how can I do that? Please take note that range is dynamic. It could be a1:g1 or further or less.


回答1:


Build the formula dynamically in your PHP script:

$startCell = 'A';
$endCell = 'H';
$row = 1;

$formula = '=' . $startCell . $row;
while ($startCell++ != $endCell && $startCell++ != $endCell) {
    $formula .= '+' . $startCell . $row;
}

EDIT

Note that I've also added a pure Excel formula answer to your previous question



来源:https://stackoverflow.com/questions/17334919/phpexcel-sumif-and-skip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!