diff --git a/samples/DefinedNames/AbsoluteNamedRange.php b/samples/DefinedNames/AbsoluteNamedRange.php index 450de667..30afc00d 100644 --- a/samples/DefinedNames/AbsoluteNamedRange.php +++ b/samples/DefinedNames/AbsoluteNamedRange.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -51,13 +44,11 @@ $worksheet ->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})") ->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})"); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'AbsoluteNamedRange.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/CrossWorksheetNamedFormula.php b/samples/DefinedNames/CrossWorksheetNamedFormula.php index b441e0f7..5ce76516 100644 --- a/samples/DefinedNames/CrossWorksheetNamedFormula.php +++ b/samples/DefinedNames/CrossWorksheetNamedFormula.php @@ -1,18 +1,11 @@ getCell("B{$row}")->getFormattedValue(); $profitGrowth = $worksheet->getCell("C{$row}")->getFormattedValue(); - echo "Growth for {$month} is {$growth}, with a Profit Growth of {$profitGrowth}", PHP_EOL; + $helper->log("Growth for {$month} is {$growth}, with a Profit Growth of {$profitGrowth}"); } -$outputFileName = 'CrossWorksheetNamedFormula.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/NamedFormulaeAndRanges.php b/samples/DefinedNames/NamedFormulaeAndRanges.php index b3f94efc..a5ca80e7 100644 --- a/samples/DefinedNames/NamedFormulaeAndRanges.php +++ b/samples/DefinedNames/NamedFormulaeAndRanges.php @@ -1,17 +1,10 @@ setActiveSheetIndex(0); @@ -62,13 +55,11 @@ $worksheet ->setCellValue("B{$row}", '=COLUMN_TOTALS') ->setCellValue("C{$row}", '=COLUMN_TOTALS'); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'NamedFormulaeAndRanges.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/RelativeNamedRange.php b/samples/DefinedNames/RelativeNamedRange.php index 1f712017..fac75a47 100644 --- a/samples/DefinedNames/RelativeNamedRange.php +++ b/samples/DefinedNames/RelativeNamedRange.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -54,13 +47,11 @@ $worksheet ->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})") ->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})"); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'RelativeNamedRange.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/RelativeNamedRange2.php b/samples/DefinedNames/RelativeNamedRange2.php index b6a6f8d1..b3e957fd 100644 --- a/samples/DefinedNames/RelativeNamedRange2.php +++ b/samples/DefinedNames/RelativeNamedRange2.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -57,13 +50,11 @@ $worksheet ->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)') ->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)'); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'RelativeNamedRange2.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/RelativeNamedRangeAsFunction.php b/samples/DefinedNames/RelativeNamedRangeAsFunction.php index 527cd43b..333d01ab 100644 --- a/samples/DefinedNames/RelativeNamedRangeAsFunction.php +++ b/samples/DefinedNames/RelativeNamedRangeAsFunction.php @@ -1,17 +1,10 @@ setActiveSheetIndex(0); @@ -60,13 +53,11 @@ $worksheet ->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)') ->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)'); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'RelativeNamedRangeAsFunction.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/ScopedNamedRange.php b/samples/DefinedNames/ScopedNamedRange.php index 5ea7e48a..aa71454d 100644 --- a/samples/DefinedNames/ScopedNamedRange.php +++ b/samples/DefinedNames/ScopedNamedRange.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -67,15 +60,13 @@ $worksheet ->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)') ->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)'); -echo sprintf( +$helper->log(sprintf( 'Worked %.2f hours at a rate of %s - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $chargeRateCellValue = $spreadsheet ->getSheetByName($spreadsheet->getNamedRange('CHARGE_RATE')->getWorksheet()->getTitle()) ->getCell($spreadsheet->getNamedRange('CHARGE_RATE')->getCellsInRange()[0])->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'ScopedNamedRange.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/ScopedNamedRange2.php b/samples/DefinedNames/ScopedNamedRange2.php index 8e610418..5f0898c9 100644 --- a/samples/DefinedNames/ScopedNamedRange2.php +++ b/samples/DefinedNames/ScopedNamedRange2.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -83,16 +76,14 @@ $worksheet ->setCellValue('B1', 4.5); foreach ($spreadsheet->getAllSheets() as $worksheet) { - echo sprintf( + $helper->log(sprintf( 'Worked %.2f hours for "%s" at a rate of %.2f - Charge to the client is %.2f', $worksheet->getCell("B{$row}")->getCalculatedValue(), $worksheet->getTitle(), $worksheet->getCell('B1')->getValue(), $worksheet->getCell("C{$row}")->getCalculatedValue() - ), PHP_EOL; + )); } $worksheet = $spreadsheet->setActiveSheetIndex(0); -$outputFileName = 'ScopedNamedRange2.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/SimpleNamedFormula.php b/samples/DefinedNames/SimpleNamedFormula.php index 8e0fc972..ea1f802d 100644 --- a/samples/DefinedNames/SimpleNamedFormula.php +++ b/samples/DefinedNames/SimpleNamedFormula.php @@ -1,17 +1,10 @@ setActiveSheetIndex(0); @@ -39,14 +32,12 @@ $worksheet ->setCellValue('B4', '=TAX') ->setCellValue('B5', '=PRICE+TAX'); -echo sprintf( +$helper->log(sprintf( 'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f', $worksheet->getCell('B1')->getCalculatedValue(), $worksheet->getCell('B3')->getValue(), $worksheet->getCell('B4')->getCalculatedValue(), $worksheet->getCell('B5')->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'SimpleNamedFormula.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']); diff --git a/samples/DefinedNames/SimpleNamedRange.php b/samples/DefinedNames/SimpleNamedRange.php index ee05c68f..7a7cdc94 100644 --- a/samples/DefinedNames/SimpleNamedRange.php +++ b/samples/DefinedNames/SimpleNamedRange.php @@ -1,16 +1,9 @@ setActiveSheetIndex(0); @@ -33,14 +26,12 @@ $worksheet ->setCellValue('B4', '=PRICE*TAX_RATE') ->setCellValue('B5', '=PRICE*(1+TAX_RATE)'); -echo sprintf( +$helper->log(sprintf( 'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f', $worksheet->getCell('B1')->getCalculatedValue(), $worksheet->getCell('B3')->getValue(), $worksheet->getCell('B4')->getCalculatedValue(), $worksheet->getCell('B5')->getCalculatedValue() -), PHP_EOL; +)); -$outputFileName = 'SimpleNamedRange.xlsx'; -$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); -$writer->save($outputFileName); +$helper->write($spreadsheet, __FILE__, ['Xlsx']);