From 9810e7254acdce6446efa08a9de4a536300341f5 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 27 Mar 2023 03:13:50 +0200 Subject: [PATCH 1/5] Examples for using some of the new NumberFormat Wizards --- samples/Wizards/NumberFormat/Number.php | 61 +++++++++++++++++++++ samples/Wizards/NumberFormat/Percentage.php | 53 ++++++++++++++++++ samples/Wizards/NumberFormat/Scientific.php | 53 ++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 samples/Wizards/NumberFormat/Number.php create mode 100644 samples/Wizards/NumberFormat/Percentage.php create mode 100644 samples/Wizards/NumberFormat/Scientific.php diff --git a/samples/Wizards/NumberFormat/Number.php b/samples/Wizards/NumberFormat/Number.php new file mode 100644 index 000000000..9c0e55a55 --- /dev/null +++ b/samples/Wizards/NumberFormat/Number.php @@ -0,0 +1,61 @@ + +
+ + + + + + + + + + + + + + + + +
+ Sample Number Value + + +
+
+
+ Decimal Places + + +
+ > + + Use Thousands Separator +
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + $wizard = new Wizard\Number($_POST['decimals'], isset($_POST['thousands'])); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } +} diff --git a/samples/Wizards/NumberFormat/Percentage.php b/samples/Wizards/NumberFormat/Percentage.php new file mode 100644 index 000000000..1a8b53af9 --- /dev/null +++ b/samples/Wizards/NumberFormat/Percentage.php @@ -0,0 +1,53 @@ + +
+ + + + + + + + + + + + +
+ Sample Number Value + + +
+
+
+ Decimal Places + + +
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + $wizard = new Wizard\Percentage($_POST['decimals']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } +} diff --git a/samples/Wizards/NumberFormat/Scientific.php b/samples/Wizards/NumberFormat/Scientific.php new file mode 100644 index 000000000..74a2c84aa --- /dev/null +++ b/samples/Wizards/NumberFormat/Scientific.php @@ -0,0 +1,53 @@ + +
+ + + + + + + + + + + + +
+ Sample Number Value + + +
+
+
+ Decimal Places + + +
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + $wizard = new Wizard\Scientific($_POST['decimals']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } +} From 3c82cea8f0b417b5dbb1c49ad77849b72ff72c03 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 27 Mar 2023 03:13:50 +0200 Subject: [PATCH 2/5] Examples for using some of the new NumberFormat Wizards --- .../Basic/45_Quadratic_equation_solver.php | 8 ++ samples/Wizards/NumberFormat/Accounting.php | 103 ++++++++++++++++++ samples/Wizards/NumberFormat/Currency.php | 103 ++++++++++++++++++ samples/Wizards/NumberFormat/Number.php | 74 +++++++++++++ samples/Wizards/NumberFormat/Percentage.php | 64 +++++++++++ samples/Wizards/NumberFormat/Scientific.php | 64 +++++++++++ src/PhpSpreadsheet/Helper/Sample.php | 2 +- 7 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 samples/Wizards/NumberFormat/Accounting.php create mode 100644 samples/Wizards/NumberFormat/Currency.php create mode 100644 samples/Wizards/NumberFormat/Number.php create mode 100644 samples/Wizards/NumberFormat/Percentage.php create mode 100644 samples/Wizards/NumberFormat/Scientific.php diff --git a/samples/Basic/45_Quadratic_equation_solver.php b/samples/Basic/45_Quadratic_equation_solver.php index 83a2000ff..8e798da2f 100644 --- a/samples/Basic/45_Quadratic_equation_solver.php +++ b/samples/Basic/45_Quadratic_equation_solver.php @@ -1,9 +1,17 @@ isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} ?>
Enter the coefficients for the Ax2 + Bx + C = 0 diff --git a/samples/Wizards/NumberFormat/Accounting.php b/samples/Wizards/NumberFormat/Accounting.php new file mode 100644 index 000000000..e122a2d9f --- /dev/null +++ b/samples/Wizards/NumberFormat/Accounting.php @@ -0,0 +1,103 @@ +isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} +?> + +
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ > +
+
+
+ +
+ >Leading + >Trailing +
+
+
+ +
+ >Yes + >No +
+
+
+
+
+
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + try { + $wizard = new Wizard\Accounting($_POST['currency'], $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position'], (bool) $_POST['spacing']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Code:
'); + $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); + $helper->log( + "\$mask = Wizard\Accounting('{$_POST['currency']}', {$_POST['decimals']}, Wizard\Number::" . + (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . + (((bool) $_POST['position']) ? ', Wizard\Accounting::LEADING_SYMBOL' : ', Wizard\Accounting::TRAILING_SYMBOL') . + (((bool) $_POST['spacing']) ? ', Wizard\Accounting::SYMBOL_WITH_SPACING' : ', Wizard\Accounting::SYMBOL_WITHOUT_SPACING') . + ')
' + ); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } catch (Exception $e) { + $helper->log("Exception: {$e->getMessage()}"); + } + } +} diff --git a/samples/Wizards/NumberFormat/Currency.php b/samples/Wizards/NumberFormat/Currency.php new file mode 100644 index 000000000..05ccbb715 --- /dev/null +++ b/samples/Wizards/NumberFormat/Currency.php @@ -0,0 +1,103 @@ +isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} +?> +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ > +
+
+
+ +
+ >Leading + >Trailing +
+
+
+ +
+ >Yes + >No +
+
+
+
+
+
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + try { + $wizard = new Wizard\Currency($_POST['currency'], $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position'], (bool) $_POST['spacing']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Code:
'); + $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); + $helper->log( + "\$mask = Wizard\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\Number::" . + (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . + (((bool) $_POST['position']) ? ', Wizard\Currency::LEADING_SYMBOL' : ', Wizard\Currency::TRAILING_SYMBOL') . + (((bool) $_POST['spacing']) ? ', Wizard\Currency::SYMBOL_WITH_SPACING' : ', Wizard\Currency::SYMBOL_WITHOUT_SPACING') . + ')
' + ); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } catch (Exception $e) { + $helper->log("Exception: {$e->getMessage()}"); + } + } +} diff --git a/samples/Wizards/NumberFormat/Number.php b/samples/Wizards/NumberFormat/Number.php new file mode 100644 index 000000000..3b3850e69 --- /dev/null +++ b/samples/Wizards/NumberFormat/Number.php @@ -0,0 +1,74 @@ +isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} +?> +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ > +
+
+
+
+
+
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + try { + $wizard = new Wizard\Number($_POST['decimals'], isset($_POST['thousands'])); + $mask = $wizard->format(); + $example = NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Code:
'); + $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); + $helper->log( + "\$mask = Wizard\Number({$_POST['decimals']}, Wizard\Number::" . + (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . + ')
' + ); + $helper->log('
Mask:'); + $helper->log($mask); + $helper->log('Example:'); + $helper->log($example); + } catch (Exception $e) { + $helper->log("Exception: {$e->getMessage()}"); + } + } +} diff --git a/samples/Wizards/NumberFormat/Percentage.php b/samples/Wizards/NumberFormat/Percentage.php new file mode 100644 index 000000000..daa77908a --- /dev/null +++ b/samples/Wizards/NumberFormat/Percentage.php @@ -0,0 +1,64 @@ +isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} +?> +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + try { + $wizard = new Wizard\Percentage($_POST['decimals']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Code:
'); + $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); + $helper->log("\$mask = Wizard\Percentage({$_POST['decimals']})
"); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } catch (Exception $e) { + $helper->log("Exception: {$e->getMessage()}"); + } + } +} diff --git a/samples/Wizards/NumberFormat/Scientific.php b/samples/Wizards/NumberFormat/Scientific.php new file mode 100644 index 000000000..5ff99dec8 --- /dev/null +++ b/samples/Wizards/NumberFormat/Scientific.php @@ -0,0 +1,64 @@ +isCli()) { + $helper->log('This example should only be run from a Web Browser' . PHP_EOL); + + return; +} +?> +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +log('The Sample Number Value must be numeric'); + } elseif (!is_numeric($_POST['decimals']) || strpos($_POST['decimals'], '.') !== false || (int) $_POST['decimals'] < 0) { + $helper->log('The Decimal Places value must be positive integer'); + } else { + try { + $wizard = new Wizard\Scientific($_POST['decimals']); + $mask = $wizard->format(); + $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); + $helper->log('
Code:
'); + $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); + $helper->log("\$mask = Wizard\Scientific({$_POST['decimals']})
"); + $helper->log('
Mask:
'); + $helper->log($mask . '
'); + $helper->log('
Example:
'); + $helper->log($example); + } catch (Exception $e) { + $helper->log("Exception: {$e->getMessage()}"); + } + } +} diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index 5ca546e07..4ed0be400 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -195,7 +195,7 @@ class Sample public function log(string $message): void { $eol = $this->isCli() ? PHP_EOL : '
'; - echo date('H:i:s ') . $message . $eol; + echo($this->isCli() ? date('H:i:s ') : '') . $message . $eol; } public function titles(string $category, string $functionName, ?string $description = null): void From 378f12035d0ea4e84b49c26654d1254973b05484 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 28 Mar 2023 05:03:44 +0200 Subject: [PATCH 3/5] PHPCS fixes --- samples/Wizards/NumberFormat/Accounting.php | 8 ++++---- samples/Wizards/NumberFormat/Currency.php | 6 +++--- samples/Wizards/NumberFormat/Number.php | 2 +- samples/Wizards/NumberFormat/Percentage.php | 2 +- samples/Wizards/NumberFormat/Scientific.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/Wizards/NumberFormat/Accounting.php b/samples/Wizards/NumberFormat/Accounting.php index e122a2d9f..1d342de82 100644 --- a/samples/Wizards/NumberFormat/Accounting.php +++ b/samples/Wizards/NumberFormat/Accounting.php @@ -15,7 +15,7 @@ if ($helper->isCli()) { return; } ?> -
+
@@ -86,10 +86,10 @@ if (isset($_POST['submit'])) { $helper->log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log( - "\$mask = Wizard\Accounting('{$_POST['currency']}', {$_POST['decimals']}, Wizard\Number::" . + "\$mask = Wizard\\Accounting('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . - (((bool) $_POST['position']) ? ', Wizard\Accounting::LEADING_SYMBOL' : ', Wizard\Accounting::TRAILING_SYMBOL') . - (((bool) $_POST['spacing']) ? ', Wizard\Accounting::SYMBOL_WITH_SPACING' : ', Wizard\Accounting::SYMBOL_WITHOUT_SPACING') . + ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL') . + ', Wizard\Currency::' . (((bool) $_POST['spacing']) ? 'SYMBOL_WITH_SPACING' : 'SYMBOL_WITHOUT_SPACING') . ')
' ); $helper->log('
Mask:
'); diff --git a/samples/Wizards/NumberFormat/Currency.php b/samples/Wizards/NumberFormat/Currency.php index 05ccbb715..11b0bfc89 100644 --- a/samples/Wizards/NumberFormat/Currency.php +++ b/samples/Wizards/NumberFormat/Currency.php @@ -86,10 +86,10 @@ if (isset($_POST['submit'])) { $helper->log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log( - "\$mask = Wizard\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\Number::" . + "\$mask = Wizard\\Currency('{$_POST['currency']}', {$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . - (((bool) $_POST['position']) ? ', Wizard\Currency::LEADING_SYMBOL' : ', Wizard\Currency::TRAILING_SYMBOL') . - (((bool) $_POST['spacing']) ? ', Wizard\Currency::SYMBOL_WITH_SPACING' : ', Wizard\Currency::SYMBOL_WITHOUT_SPACING') . + ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL') . + ', Wizard\Currency::' . (((bool) $_POST['spacing']) ? 'SYMBOL_WITH_SPACING' : 'SYMBOL_WITHOUT_SPACING') . ')
' ); $helper->log('
Mask:
'); diff --git a/samples/Wizards/NumberFormat/Number.php b/samples/Wizards/NumberFormat/Number.php index 3b3850e69..3e2e1a517 100644 --- a/samples/Wizards/NumberFormat/Number.php +++ b/samples/Wizards/NumberFormat/Number.php @@ -59,7 +59,7 @@ if (isset($_POST['submit'])) { $helper->log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); $helper->log( - "\$mask = Wizard\Number({$_POST['decimals']}, Wizard\Number::" . + "\$mask = Wizard\\Number({$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . ')
' ); diff --git a/samples/Wizards/NumberFormat/Percentage.php b/samples/Wizards/NumberFormat/Percentage.php index daa77908a..d06dafb69 100644 --- a/samples/Wizards/NumberFormat/Percentage.php +++ b/samples/Wizards/NumberFormat/Percentage.php @@ -52,7 +52,7 @@ if (isset($_POST['submit'])) { $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); - $helper->log("\$mask = Wizard\Percentage({$_POST['decimals']})
"); + $helper->log("\$mask = Wizard\\Percentage({$_POST['decimals']})
"); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); diff --git a/samples/Wizards/NumberFormat/Scientific.php b/samples/Wizards/NumberFormat/Scientific.php index 5ff99dec8..3e68033b7 100644 --- a/samples/Wizards/NumberFormat/Scientific.php +++ b/samples/Wizards/NumberFormat/Scientific.php @@ -52,7 +52,7 @@ if (isset($_POST['submit'])) { $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask); $helper->log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); - $helper->log("\$mask = Wizard\Scientific({$_POST['decimals']})
"); + $helper->log("\$mask = Wizard\\Scientific({$_POST['decimals']})
"); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); From 32b4dfb52508a4796f59e699e545402a75f0172b Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 28 Mar 2023 14:43:40 +0200 Subject: [PATCH 4/5] Tweaks --- samples/Wizards/NumberFormat/Accounting.php | 7 ++++--- samples/Wizards/NumberFormat/Currency.php | 7 ++++--- samples/Wizards/NumberFormat/Number.php | 7 ++++--- samples/Wizards/NumberFormat/Percentage.php | 7 ++++--- samples/Wizards/NumberFormat/Scientific.php | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/samples/Wizards/NumberFormat/Accounting.php b/samples/Wizards/NumberFormat/Accounting.php index 1d342de82..bdc156d5d 100644 --- a/samples/Wizards/NumberFormat/Accounting.php +++ b/samples/Wizards/NumberFormat/Accounting.php @@ -1,6 +1,6 @@ ' + ');
' ); + $helper->log('echo (string) $mask;'); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); $helper->log($example); - } catch (Exception $e) { + } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } diff --git a/samples/Wizards/NumberFormat/Currency.php b/samples/Wizards/NumberFormat/Currency.php index 11b0bfc89..c6ab4d2c9 100644 --- a/samples/Wizards/NumberFormat/Currency.php +++ b/samples/Wizards/NumberFormat/Currency.php @@ -1,6 +1,6 @@ ' + ');
' ); + $helper->log('echo (string) $mask;'); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); $helper->log($example); - } catch (Exception $e) { + } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } diff --git a/samples/Wizards/NumberFormat/Number.php b/samples/Wizards/NumberFormat/Number.php index 3e2e1a517..7869838ab 100644 --- a/samples/Wizards/NumberFormat/Number.php +++ b/samples/Wizards/NumberFormat/Number.php @@ -1,6 +1,6 @@ log( "\$mask = Wizard\\Number({$_POST['decimals']}, Wizard\\Number::" . (isset($_POST['thousands']) ? 'WITH_THOUSANDS_SEPARATOR' : 'WITHOUT_THOUSANDS_SEPARATOR') . - ')
' + ');
' ); + $helper->log('echo (string) $mask;'); $helper->log('
Mask:'); $helper->log($mask); $helper->log('Example:'); $helper->log($example); - } catch (Exception $e) { + } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } diff --git a/samples/Wizards/NumberFormat/Percentage.php b/samples/Wizards/NumberFormat/Percentage.php index d06dafb69..a1bde45c9 100644 --- a/samples/Wizards/NumberFormat/Percentage.php +++ b/samples/Wizards/NumberFormat/Percentage.php @@ -1,6 +1,6 @@ log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); - $helper->log("\$mask = Wizard\\Percentage({$_POST['decimals']})
"); + $helper->log("\$mask = Wizard\\Percentage({$_POST['decimals']});
"); + $helper->log('echo (string) $mask;'); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); $helper->log($example); - } catch (Exception $e) { + } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } diff --git a/samples/Wizards/NumberFormat/Scientific.php b/samples/Wizards/NumberFormat/Scientific.php index 3e68033b7..d35f43903 100644 --- a/samples/Wizards/NumberFormat/Scientific.php +++ b/samples/Wizards/NumberFormat/Scientific.php @@ -1,6 +1,6 @@ log('
Code:
'); $helper->log('use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;'); - $helper->log("\$mask = Wizard\\Scientific({$_POST['decimals']})
"); + $helper->log("\$mask = Wizard\\Scientific({$_POST['decimals']});
"); + $helper->log('echo (string) $mask;'); $helper->log('
Mask:
'); $helper->log($mask . '
'); $helper->log('
Example:
'); $helper->log($example); - } catch (Exception $e) { + } catch (SpreadsheetException $e) { $helper->log("Exception: {$e->getMessage()}"); } } From a69ab80f7dbca9b1a84b8af6a1427a54b5e759ee Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 28 Mar 2023 20:37:10 +0200 Subject: [PATCH 5/5] Build currencies list for Currency and Accounting Wizards --- samples/Wizards/NumberFormat/Accounting.php | 19 +++++++++++++------ samples/Wizards/NumberFormat/Currency.php | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/samples/Wizards/NumberFormat/Accounting.php b/samples/Wizards/NumberFormat/Accounting.php index bdc156d5d..6e6296b23 100644 --- a/samples/Wizards/NumberFormat/Accounting.php +++ b/samples/Wizards/NumberFormat/Accounting.php @@ -14,6 +14,16 @@ if ($helper->isCli()) { return; } + +$currencies = [ + '$' => 'US Dollars ($)', + '€' => 'Euro (€)', + '¥' => 'Japanese Yen (¥)', + '£' => 'Pound Sterling (£)', + '₹' => 'Rupee (₹)', + '₽' => 'Rouble (₽)', +]; + ?>
@@ -29,12 +39,9 @@ if ($helper->isCli()) {
diff --git a/samples/Wizards/NumberFormat/Currency.php b/samples/Wizards/NumberFormat/Currency.php index c6ab4d2c9..b4373d541 100644 --- a/samples/Wizards/NumberFormat/Currency.php +++ b/samples/Wizards/NumberFormat/Currency.php @@ -14,6 +14,16 @@ if ($helper->isCli()) { return; } + +$currencies = [ + '$' => 'US Dollars ($)', + '€' => 'Euro (€)', + '¥' => 'Japanese Yen (¥)', + '£' => 'Pound Sterling (£)', + '₹' => 'Rupee (₹)', + '₽' => 'Rouble (₽)', +]; + ?>
@@ -29,12 +39,9 @@ if ($helper->isCli()) {