Skip to content

Subtotal Calculation #332

Closed
Closed
@cloelke

Description

@cloelke

This is:

  • [x ] a bug report

What is the expected behavior?

Subtotal 9 in a group that has other subtotal 9 should excluded the totals of the other subtotals in the range

What is the current behavior?

Subtotal does not skip other subtotals and includes it like a sum

What are the steps to reproduce?

If you run the below then delete A8 in excel then undo. Excel with provide the correct total of 4
the below is producing 6

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$objPhpSpreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$objPhpSpreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 2, 1);
$objPhpSpreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 3, 1);
$objPhpSpreadsheet->getActiveSheet()->setCellValue('A4','=SUBTOTAL(9,A2:A3)');

$objPhpSpreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 6, 1);
$objPhpSpreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 7, 1);
$objPhpSpreadsheet->getActiveSheet()->setCellValue('A8','=SUBTOTAL(9,A2:A7)');


$objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Xlsx');
$objWriter->save('php://output');

Which versions of PhpSpreadsheet and PHP are affected?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions