From 50a0ec58afd2279f291e868084d55b8198fd814e Mon Sep 17 00:00:00 2001
From: Adrien Crivelli
Date: Sun, 1 Oct 2017 17:48:59 +0900
Subject: [PATCH] Merge all examples together
Closes #17
---
composer.json | 2 +-
.../Calculations/Database/DAVERAGE.php | 78 --------
.../Examples/Calculations/Database/DCOUNT.php | 78 --------
docs/Examples/Calculations/Database/DGET.php | 74 --------
docs/Examples/Calculations/Database/DMAX.php | 77 --------
docs/Examples/Calculations/Database/DMIN.php | 77 --------
.../Calculations/Database/DPRODUCT.php | 74 --------
.../Examples/Calculations/Database/DSTDEV.php | 78 --------
.../Calculations/Database/DSTDEVP.php | 78 --------
docs/Examples/Calculations/Database/DVAR.php | 78 --------
docs/Examples/Calculations/Database/DVARP.php | 78 --------
docs/Examples/Calculations/DateTime/DATE.php | 77 --------
.../Calculations/DateTime/DATEVALUE.php | 70 -------
docs/Examples/Calculations/DateTime/TIME.php | 75 --------
.../Calculations/DateTime/TIMEVALUE.php | 66 -------
docs/Examples/Calculations/index.php | 45 -----
docs/Examples/Reader/exampleReader01.php | 34 ----
docs/Examples/Reader/exampleReader02.php | 36 ----
docs/Examples/Reader/exampleReader03.php | 37 ----
docs/Examples/Reader/exampleReader04.php | 39 ----
docs/Examples/Reader/exampleReader05.php | 39 ----
docs/Examples/Reader/exampleReader06.php | 42 -----
docs/Examples/Reader/exampleReader07.php | 43 -----
docs/Examples/Reader/exampleReader08.php | 43 -----
docs/Examples/Reader/exampleReader09.php | 61 ------
docs/Examples/Reader/exampleReader10.php | 72 -------
docs/Examples/Reader/exampleReader11.php | 86 ---------
docs/Examples/Reader/exampleReader12.php | 89 ---------
docs/Examples/Reader/exampleReader13.php | 52 -----
docs/Examples/Reader/exampleReader14.php | 110 -----------
docs/Examples/Reader/exampleReader15.php | 69 -------
docs/Examples/Reader/exampleReader16.php | 39 ----
docs/Examples/Reader/exampleReader17.php | 40 ----
docs/Examples/Reader/exampleReader18.php | 40 ----
docs/Examples/Reader/exampleReader19.php | 43 -----
.../exampleWorkBookReader01.php | 85 ---------
.../exampleWorkBookReader02.php | 43 -----
.../exampleWorkBookReader03.php | 71 -------
.../exampleWorkBookReader04.php | 47 -----
docs/Examples/index.php | 44 -----
docs/topics/autofilters.md | 2 +-
docs/topics/reading-files.md | 80 ++++----
samples/05_Feature_demo.php | 7 -
samples/06_Largescale.php | 8 -
samples/13_Calculation.php | 178 ------------------
samples/{ => Autofilter}/10_Autofilter.php | 2 +-
.../10_Autofilter_selection_1.php | 2 +-
.../10_Autofilter_selection_2.php | 2 +-
.../10_Autofilter_selection_display.php | 9 +-
samples/{ => Basic}/01_Simple.php | 2 +-
.../{ => Basic}/01_Simple_download_ods.php | 4 +-
.../{ => Basic}/01_Simple_download_pdf.php | 4 +-
.../{ => Basic}/01_Simple_download_xls.php | 4 +-
.../{ => Basic}/01_Simple_download_xlsx.php | 4 +-
samples/{ => Basic}/02_Types.php | 2 +-
samples/{ => Basic}/03_Formulas.php | 12 +-
samples/{ => Basic}/04_Printing.php | 4 +-
samples/Basic/05_Feature_demo.php | 7 +
samples/Basic/06_Largescale.php | 8 +
samples/{ => Basic}/07_Reader.php | 4 +-
.../{ => Basic}/08_Conditional_formatting.php | 2 +-
.../08_Conditional_formatting_2.php | 2 +-
samples/{ => Basic}/09_Pagebreaks.php | 2 +-
samples/{ => Basic}/11_Documentsecurity.php | 2 +-
samples/{ => Basic}/12_CellProtection.php | 2 +-
samples/Basic/13_Calculation.php | 176 +++++++++++++++++
.../13_CalculationCyclicFormulae.php | 5 +-
samples/{ => Basic}/14_Xls.php | 4 +-
samples/{ => Basic}/15_Datavalidation.php | 2 +-
samples/{ => Basic}/16_Csv.php | 4 +-
samples/{ => Basic}/17_Html.php | 4 +-
.../{ => Basic}/18_Extendedcalculation.php | 4 +-
samples/{ => Basic}/19_Namedrange.php | 2 +-
samples/{ => Basic}/20_Read_Excel2003XML.php | 4 +-
samples/{ => Basic}/20_Read_Gnumeric.php | 4 +-
samples/{ => Basic}/20_Read_Ods.php | 4 +-
samples/{ => Basic}/20_Read_Sylk.php | 4 +-
samples/{ => Basic}/20_Read_Xls.php | 4 +-
samples/{ => Basic}/22_Heavily_formatted.php | 2 +-
samples/{ => Basic}/23_Sharedstyles.php | 2 +-
samples/{ => Basic}/24_Readfilter.php | 4 +-
samples/{ => Basic}/25_In_memory_image.php | 2 +-
samples/{ => Basic}/26_Utf8.php | 4 +-
samples/{ => Basic}/27_Images_Xls.php | 4 +-
samples/{ => Basic}/28_Iterator.php | 4 +-
.../{ => Basic}/29_Advanced_value_binder.php | 2 +-
samples/{ => Basic}/30_Template.php | 4 +-
.../31_Document_properties_write.php | 10 +-
.../31_Document_properties_write_xls.php | 10 +-
samples/{ => Basic}/37_Page_layout_view.php | 2 +-
samples/{ => Basic}/38_Clone_worksheet.php | 2 +-
samples/{ => Basic}/39_Dropdown.php | 6 +-
samples/{ => Basic}/40_Duplicate_style.php | 4 +-
samples/{ => Basic}/41_Password.php | 4 +-
samples/{ => Basic}/42_RichText.php | 2 +-
samples/{ => Basic}/43_Merge_workbooks.php | 6 +-
samples/{ => Basic}/44_Worksheet_info.php | 4 +-
.../45_Quadratic_equation_solver.php | 10 +-
samples/{ => Basic}/46_ReadHtml.php | 4 +-
.../{ => Basic}/data/continents/Africa.txt | 0
samples/{ => Basic}/data/continents/Asia.txt | 0
.../{ => Basic}/data/continents/Europe.txt | 0
.../data/continents/North America.txt | 0
.../{ => Basic}/data/continents/Oceania.txt | 0
.../data/continents/South America.txt | 0
samples/Calculations/Database/DAVERAGE.php | 56 ++++++
samples/Calculations/Database/DCOUNT.php | 55 ++++++
samples/Calculations/Database/DGET.php | 52 +++++
samples/Calculations/Database/DMAX.php | 55 ++++++
samples/Calculations/Database/DMIN.php | 55 ++++++
samples/Calculations/Database/DPRODUCT.php | 52 +++++
samples/Calculations/Database/DSTDEV.php | 56 ++++++
samples/Calculations/Database/DSTDEVP.php | 55 ++++++
samples/Calculations/Database/DVAR.php | 55 ++++++
samples/Calculations/Database/DVARP.php | 56 ++++++
samples/Calculations/DateTime/DATE.php | 41 ++++
samples/Calculations/DateTime/DATEVALUE.php | 39 ++++
samples/Calculations/DateTime/TIME.php | 39 ++++
samples/Calculations/DateTime/TIMEVALUE.php | 35 ++++
samples/{ => Chart}/32_Chart_read_write.php | 10 +-
.../{ => Chart}/32_Chart_read_write_HTML.php | 22 +--
.../{ => Chart}/32_Chart_read_write_PDF.php | 22 +--
samples/{ => Chart}/33_Chart_create_area.php | 2 +-
samples/{ => Chart}/33_Chart_create_bar.php | 4 +-
.../33_Chart_create_bar_stacked.php | 2 +-
.../{ => Chart}/33_Chart_create_column.php | 2 +-
.../{ => Chart}/33_Chart_create_column_2.php | 2 +-
.../{ => Chart}/33_Chart_create_composite.php | 2 +-
samples/{ => Chart}/33_Chart_create_line.php | 2 +-
.../33_Chart_create_multiple_charts.php | 2 +-
samples/{ => Chart}/33_Chart_create_pie.php | 2 +-
samples/{ => Chart}/33_Chart_create_radar.php | 2 +-
.../{ => Chart}/33_Chart_create_scatter.php | 2 +-
samples/{ => Chart}/33_Chart_create_stock.php | 2 +-
samples/{ => Chart}/34_Chart_update.php | 4 +-
samples/{ => Chart}/35_Chart_render.php | 17 +-
samples/Header.php | 33 ++--
samples/{ => Pdf}/21_Pdf_Domdf.php | 4 +-
samples/{ => Pdf}/21_Pdf_TCPDF.php | 4 +-
samples/{ => Pdf}/21_Pdf_mPDF.php | 4 +-
.../01_Simple_file_reader_using_IOFactory.php | 11 ++
...e_file_reader_using_a_specified_reader.php | 13 ++
...using_the_IOFactory_to_return_a_reader.php | 15 ++
..._IOFactory_to_identify_a_reader_to_use.php | 17 ++
...reader_using_the_read_data_only_option.php | 17 ++
...ple_file_reader_loading_all_worksheets.php | 20 ++
...eader_loading_a_single_named_worksheet.php | 21 +++
...eader_loading_several_named_worksheets.php | 21 +++
...Simple_file_reader_using_a_read_filter.php | 40 ++++
...eader_using_a_configurable_read_filter.php | 50 +++++
...a_configurable_read_filter_(version_1).php | 63 +++++++
...a_configurable_read_filter_(version_2).php | 66 +++++++
...ple_file_reader_for_multiple_CSV_files.php | 29 +++
...ks_to_split_across_multiple_worksheets.php | 85 +++++++++
...e_file_using_the_Advanced_Value_Binder.php | 40 ++++
...dling_loader_exceptions_using_TryCatch.php | 13 ++
...eader_loading_several_named_worksheets.php | 20 ++
...worksheets_without_loading_entire_file.php | 20 ++
...nformation_without_loading_entire_file.php | 23 +++
.../Reader/sampleData/example1.csv | 0
.../Reader/sampleData/example1.tsv | 0
.../Reader/sampleData/example1.xls | Bin
.../Reader/sampleData/example2.csv | 0
.../Reader/sampleData/example2.xls | Bin
.../Custom_properties.php | 48 +++++
.../Custom_property_names.php | 20 ++
samples/Reading_workbook_data/Properties.php | 64 +++++++
.../Worksheet_count_and_names.php | 24 +++
.../sampleData/example1.xls | Bin
.../sampleData/example1.xlsx | Bin
.../sampleData/example2.xls | Bin
samples/index.php | 2 +-
src/PhpSpreadsheet/Helper/Sample.php | 29 ++-
tests/PhpSpreadsheetTests/SampleTest.php | 13 +-
174 files changed, 1878 insertions(+), 2830 deletions(-)
delete mode 100644 docs/Examples/Calculations/Database/DAVERAGE.php
delete mode 100644 docs/Examples/Calculations/Database/DCOUNT.php
delete mode 100644 docs/Examples/Calculations/Database/DGET.php
delete mode 100644 docs/Examples/Calculations/Database/DMAX.php
delete mode 100644 docs/Examples/Calculations/Database/DMIN.php
delete mode 100644 docs/Examples/Calculations/Database/DPRODUCT.php
delete mode 100644 docs/Examples/Calculations/Database/DSTDEV.php
delete mode 100644 docs/Examples/Calculations/Database/DSTDEVP.php
delete mode 100644 docs/Examples/Calculations/Database/DVAR.php
delete mode 100644 docs/Examples/Calculations/Database/DVARP.php
delete mode 100644 docs/Examples/Calculations/DateTime/DATE.php
delete mode 100644 docs/Examples/Calculations/DateTime/DATEVALUE.php
delete mode 100644 docs/Examples/Calculations/DateTime/TIME.php
delete mode 100644 docs/Examples/Calculations/DateTime/TIMEVALUE.php
delete mode 100644 docs/Examples/Calculations/index.php
delete mode 100644 docs/Examples/Reader/exampleReader01.php
delete mode 100644 docs/Examples/Reader/exampleReader02.php
delete mode 100644 docs/Examples/Reader/exampleReader03.php
delete mode 100644 docs/Examples/Reader/exampleReader04.php
delete mode 100644 docs/Examples/Reader/exampleReader05.php
delete mode 100644 docs/Examples/Reader/exampleReader06.php
delete mode 100644 docs/Examples/Reader/exampleReader07.php
delete mode 100644 docs/Examples/Reader/exampleReader08.php
delete mode 100644 docs/Examples/Reader/exampleReader09.php
delete mode 100644 docs/Examples/Reader/exampleReader10.php
delete mode 100644 docs/Examples/Reader/exampleReader11.php
delete mode 100644 docs/Examples/Reader/exampleReader12.php
delete mode 100644 docs/Examples/Reader/exampleReader13.php
delete mode 100644 docs/Examples/Reader/exampleReader14.php
delete mode 100644 docs/Examples/Reader/exampleReader15.php
delete mode 100644 docs/Examples/Reader/exampleReader16.php
delete mode 100644 docs/Examples/Reader/exampleReader17.php
delete mode 100644 docs/Examples/Reader/exampleReader18.php
delete mode 100644 docs/Examples/Reader/exampleReader19.php
delete mode 100644 docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php
delete mode 100644 docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php
delete mode 100644 docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php
delete mode 100644 docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php
delete mode 100644 docs/Examples/index.php
delete mode 100644 samples/05_Feature_demo.php
delete mode 100644 samples/06_Largescale.php
delete mode 100644 samples/13_Calculation.php
rename samples/{ => Autofilter}/10_Autofilter.php (98%)
rename samples/{ => Autofilter}/10_Autofilter_selection_1.php (99%)
rename samples/{ => Autofilter}/10_Autofilter_selection_2.php (99%)
rename samples/{ => Autofilter}/10_Autofilter_selection_display.php (95%)
rename samples/{ => Basic}/01_Simple.php (98%)
rename samples/{ => Basic}/01_Simple_download_ods.php (93%)
rename samples/{ => Basic}/01_Simple_download_pdf.php (93%)
rename samples/{ => Basic}/01_Simple_download_xls.php (93%)
rename samples/{ => Basic}/01_Simple_download_xlsx.php (93%)
rename samples/{ => Basic}/02_Types.php (99%)
rename samples/{ => Basic}/03_Formulas.php (82%)
rename samples/{ => Basic}/04_Printing.php (95%)
create mode 100644 samples/Basic/05_Feature_demo.php
create mode 100644 samples/Basic/06_Largescale.php
rename samples/{ => Basic}/07_Reader.php (78%)
rename samples/{ => Basic}/08_Conditional_formatting.php (99%)
rename samples/{ => Basic}/08_Conditional_formatting_2.php (98%)
rename samples/{ => Basic}/09_Pagebreaks.php (98%)
rename samples/{ => Basic}/11_Documentsecurity.php (98%)
rename samples/{ => Basic}/12_CellProtection.php (97%)
create mode 100644 samples/Basic/13_Calculation.php
rename samples/{ => Basic}/13_CalculationCyclicFormulae.php (82%)
rename samples/{ => Basic}/14_Xls.php (71%)
rename samples/{ => Basic}/15_Datavalidation.php (98%)
rename samples/{ => Basic}/16_Csv.php (90%)
rename samples/{ => Basic}/17_Html.php (71%)
rename samples/{ => Basic}/18_Extendedcalculation.php (94%)
rename samples/{ => Basic}/19_Namedrange.php (98%)
rename samples/{ => Basic}/20_Read_Excel2003XML.php (70%)
rename samples/{ => Basic}/20_Read_Gnumeric.php (70%)
rename samples/{ => Basic}/20_Read_Ods.php (71%)
rename samples/{ => Basic}/20_Read_Sylk.php (72%)
rename samples/{ => Basic}/20_Read_Xls.php (81%)
rename samples/{ => Basic}/22_Heavily_formatted.php (97%)
rename samples/{ => Basic}/23_Sharedstyles.php (98%)
rename samples/{ => Basic}/24_Readfilter.php (90%)
rename samples/{ => Basic}/25_In_memory_image.php (97%)
rename samples/{ => Basic}/26_Utf8.php (93%)
rename samples/{ => Basic}/27_Images_Xls.php (66%)
rename samples/{ => Basic}/28_Iterator.php (90%)
rename samples/{ => Basic}/29_Advanced_value_binder.php (99%)
rename samples/{ => Basic}/30_Template.php (91%)
rename samples/{ => Basic}/31_Document_properties_write.php (84%)
rename samples/{ => Basic}/31_Document_properties_write_xls.php (84%)
rename samples/{ => Basic}/37_Page_layout_view.php (96%)
rename samples/{ => Basic}/38_Clone_worksheet.php (98%)
rename samples/{ => Basic}/39_Dropdown.php (96%)
rename samples/{ => Basic}/40_Duplicate_style.php (89%)
rename samples/{ => Basic}/41_Password.php (71%)
rename samples/{ => Basic}/42_RichText.php (98%)
rename samples/{ => Basic}/43_Merge_workbooks.php (81%)
rename samples/{ => Basic}/44_Worksheet_info.php (84%)
rename samples/{ => Basic}/45_Quadratic_equation_solver.php (84%)
rename samples/{ => Basic}/46_ReadHtml.php (78%)
rename samples/{ => Basic}/data/continents/Africa.txt (100%)
rename samples/{ => Basic}/data/continents/Asia.txt (100%)
rename samples/{ => Basic}/data/continents/Europe.txt (100%)
rename samples/{ => Basic}/data/continents/North America.txt (100%)
rename samples/{ => Basic}/data/continents/Oceania.txt (100%)
rename samples/{ => Basic}/data/continents/South America.txt (100%)
create mode 100644 samples/Calculations/Database/DAVERAGE.php
create mode 100644 samples/Calculations/Database/DCOUNT.php
create mode 100644 samples/Calculations/Database/DGET.php
create mode 100644 samples/Calculations/Database/DMAX.php
create mode 100644 samples/Calculations/Database/DMIN.php
create mode 100644 samples/Calculations/Database/DPRODUCT.php
create mode 100644 samples/Calculations/Database/DSTDEV.php
create mode 100644 samples/Calculations/Database/DSTDEVP.php
create mode 100644 samples/Calculations/Database/DVAR.php
create mode 100644 samples/Calculations/Database/DVARP.php
create mode 100644 samples/Calculations/DateTime/DATE.php
create mode 100644 samples/Calculations/DateTime/DATEVALUE.php
create mode 100644 samples/Calculations/DateTime/TIME.php
create mode 100644 samples/Calculations/DateTime/TIMEVALUE.php
rename samples/{ => Chart}/32_Chart_read_write.php (91%)
rename samples/{ => Chart}/32_Chart_read_write_HTML.php (82%)
rename samples/{ => Chart}/32_Chart_read_write_PDF.php (83%)
rename samples/{ => Chart}/33_Chart_create_area.php (98%)
rename samples/{ => Chart}/33_Chart_create_bar.php (75%)
rename samples/{ => Chart}/33_Chart_create_bar_stacked.php (98%)
rename samples/{ => Chart}/33_Chart_create_column.php (98%)
rename samples/{ => Chart}/33_Chart_create_column_2.php (99%)
rename samples/{ => Chart}/33_Chart_create_composite.php (99%)
rename samples/{ => Chart}/33_Chart_create_line.php (98%)
rename samples/{ => Chart}/33_Chart_create_multiple_charts.php (99%)
rename samples/{ => Chart}/33_Chart_create_pie.php (99%)
rename samples/{ => Chart}/33_Chart_create_radar.php (99%)
rename samples/{ => Chart}/33_Chart_create_scatter.php (98%)
rename samples/{ => Chart}/33_Chart_create_stock.php (99%)
rename samples/{ => Chart}/34_Chart_update.php (89%)
rename samples/{ => Chart}/35_Chart_render.php (81%)
rename samples/{ => Pdf}/21_Pdf_Domdf.php (83%)
rename samples/{ => Pdf}/21_Pdf_TCPDF.php (83%)
rename samples/{ => Pdf}/21_Pdf_mPDF.php (83%)
create mode 100644 samples/Reader/01_Simple_file_reader_using_IOFactory.php
create mode 100644 samples/Reader/02_Simple_file_reader_using_a_specified_reader.php
create mode 100644 samples/Reader/03_Simple_file_reader_using_the_IOFactory_to_return_a_reader.php
create mode 100644 samples/Reader/04_Simple_file_reader_using_the_IOFactory_to_identify_a_reader_to_use.php
create mode 100644 samples/Reader/05_Simple_file_reader_using_the_read_data_only_option.php
create mode 100644 samples/Reader/06_Simple_file_reader_loading_all_worksheets.php
create mode 100644 samples/Reader/07_Simple_file_reader_loading_a_single_named_worksheet.php
create mode 100644 samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php
create mode 100644 samples/Reader/09_Simple_file_reader_using_a_read_filter.php
create mode 100644 samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php
create mode 100644 samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php
create mode 100644 samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php
create mode 100644 samples/Reader/13_Simple_file_reader_for_multiple_CSV_files.php
create mode 100644 samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php
create mode 100644 samples/Reader/15_Simple_file_reader_for_tab_separated_value_file_using_the_Advanced_Value_Binder.php
create mode 100644 samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php
create mode 100644 samples/Reader/17_Simple_file_reader_loading_several_named_worksheets.php
create mode 100644 samples/Reader/18_Reading_list_of_worksheets_without_loading_entire_file.php
create mode 100644 samples/Reader/19_Reading_worksheet_information_without_loading_entire_file.php
rename {docs/Examples => samples}/Reader/sampleData/example1.csv (100%)
rename {docs/Examples => samples}/Reader/sampleData/example1.tsv (100%)
rename {docs/Examples => samples}/Reader/sampleData/example1.xls (100%)
rename {docs/Examples => samples}/Reader/sampleData/example2.csv (100%)
rename {docs/Examples => samples}/Reader/sampleData/example2.xls (100%)
create mode 100644 samples/Reading_workbook_data/Custom_properties.php
create mode 100644 samples/Reading_workbook_data/Custom_property_names.php
create mode 100644 samples/Reading_workbook_data/Properties.php
create mode 100644 samples/Reading_workbook_data/Worksheet_count_and_names.php
rename {docs/Examples/Reading WorkBook Data => samples/Reading_workbook_data}/sampleData/example1.xls (100%)
rename {docs/Examples/Reading WorkBook Data => samples/Reading_workbook_data}/sampleData/example1.xlsx (100%)
rename {docs/Examples/Reading WorkBook Data => samples/Reading_workbook_data}/sampleData/example2.xls (100%)
diff --git a/composer.json b/composer.json
index 04a922c8..cd8de208 100644
--- a/composer.json
+++ b/composer.json
@@ -25,7 +25,7 @@
"scripts": {
"check": [
"php-cs-fixer fix --ansi --dry-run --diff",
- "phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --standard=PSR2 -n",
+ "phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n",
"phpunit --color=always"
]
},
diff --git a/docs/Examples/Calculations/Database/DAVERAGE.php b/docs/Examples/Calculations/Database/DAVERAGE.php
deleted file mode 100644
index be87d3ef..00000000
--- a/docs/Examples/Calculations/Database/DAVERAGE.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DAVERAGE
- Returns the average of selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The Average yield of Apple trees over 10\' in height');
- $worksheet->setCellValue('B12', '=DAVERAGE(A4:E10,"Yield",A1:B2)');
-
- $worksheet->setCellValue('A13', 'The Average age of all Apple and Pear trees in the orchard');
- $worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DCOUNT.php b/docs/Examples/Calculations/Database/DCOUNT.php
deleted file mode 100644
index 4387d8fa..00000000
--- a/docs/Examples/Calculations/Database/DCOUNT.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DCOUNT
- Counts the cells that contain numbers in a database.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The Number of Apple trees over 10\' in height');
- $worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Yield",A1:B2)');
-
- $worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
- $worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DGET.php b/docs/Examples/Calculations/Database/DGET.php
deleted file mode 100644
index 59dd9529..00000000
--- a/docs/Examples/Calculations/Database/DGET.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DGET
- Extracts a single value from a column of a list or database that matches conditions that you specify.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
- $worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- echo 'ALL' . '
';
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DMAX.php b/docs/Examples/Calculations/Database/DMAX.php
deleted file mode 100644
index bc0af306..00000000
--- a/docs/Examples/Calculations/Database/DMAX.php
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DMAX
- Returns the maximum value from selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The tallest tree in the orchard');
- $worksheet->setCellValue('B12', '=DMAX(A4:E10,"Height",A4:E10)');
-
- $worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard');
- $worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- echo 'ALL' . '
';
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DMIN.php b/docs/Examples/Calculations/Database/DMIN.php
deleted file mode 100644
index 9f36786a..00000000
--- a/docs/Examples/Calculations/Database/DMIN.php
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DMIN
- Returns the minimum value from selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The shortest tree in the orchard');
- $worksheet->setCellValue('B12', '=DMIN(A4:E10,"Height",A4:E10)');
-
- $worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard');
- $worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- echo 'ALL' . '
';
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DPRODUCT.php b/docs/Examples/Calculations/Database/DPRODUCT.php
deleted file mode 100644
index 92efcf08..00000000
--- a/docs/Examples/Calculations/Database/DPRODUCT.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DPRODUCT
- Multiplies the values in a column of a list or database that match conditions that you specify.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
- $worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- echo 'ALL' . '
';
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DSTDEV.php b/docs/Examples/Calculations/Database/DSTDEV.php
deleted file mode 100644
index 8eaf133e..00000000
--- a/docs/Examples/Calculations/Database/DSTDEV.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DSTDEV
- Estimates the standard deviation based on a sample of selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The estimated standard deviation in the yield of Apple and Pear trees');
- $worksheet->setCellValue('B12', '=DSTDEV(A4:E10,"Yield",A1:A3)');
-
- $worksheet->setCellValue('A13', 'The estimated standard deviation in height of Apple and Pear trees');
- $worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DSTDEVP.php b/docs/Examples/Calculations/Database/DSTDEVP.php
deleted file mode 100644
index ea9a5345..00000000
--- a/docs/Examples/Calculations/Database/DSTDEVP.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DSTDEVP
- Calculates the standard deviation based on the entire population of selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The standard deviation in the yield of Apple and Pear trees');
- $worksheet->setCellValue('B12', '=DSTDEVP(A4:E10,"Yield",A1:A3)');
-
- $worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees');
- $worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DVAR.php b/docs/Examples/Calculations/Database/DVAR.php
deleted file mode 100644
index 2349845e..00000000
--- a/docs/Examples/Calculations/Database/DVAR.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DVAR
- Estimates variance based on a sample from selected database entries.
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The estimated variance in the yield of Apple and Pear trees');
- $worksheet->setCellValue('B12', '=DVAR(A4:E10,"Yield",A1:A3)');
-
- $worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees');
- $worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/Database/DVARP.php b/docs/Examples/Calculations/Database/DVARP.php
deleted file mode 100644
index a9b053a5..00000000
--- a/docs/Examples/Calculations/Database/DVARP.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DVARP
- Calculates variance based on the entire population of selected database entries,
- getActiveSheet();
-
- // Add some data
- $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
- ['Apple', 18, 20, 14, 105.00],
- ['Pear', 12, 12, 10, 96.00],
- ['Cherry', 13, 14, 9, 105.00],
- ['Apple', 14, 15, 10, 75.00],
- ['Pear', 9, 8, 8, 76.80],
- ['Apple', 8, 9, 6, 45.00],
- ];
- $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
- ['="=Apple"', '>10', null, null, null, '<16'],
- ['="=Pear"', null, null, null, null, null],
- ];
-
- $worksheet->fromArray($criteria, null, 'A1');
- $worksheet->fromArray($database, null, 'A4');
-
- $worksheet->setCellValue('A12', 'The variance in the yield of Apple and Pear trees');
- $worksheet->setCellValue('B12', '=DVARP(A4:E10,"Yield",A1:A3)');
-
- $worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees');
- $worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
-
- echo '
';
-
- echo 'Database
';
-
- $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
- var_dump($databaseData);
-
- echo '
';
-
- // Test the formulae
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A12')->getValue() . '
';
- echo 'DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '
';
-
- echo 'Criteria
';
-
- $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
- var_dump($criteriaData);
-
- echo $worksheet->getCell('A13')->getValue() . '
';
- echo 'DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/DateTime/DATE.php b/docs/Examples/Calculations/DateTime/DATE.php
deleted file mode 100644
index 33330c97..00000000
--- a/docs/Examples/Calculations/DateTime/DATE.php
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DATE
- Returns the serial number of a particular date.
- getActiveSheet();
-
- // Add some data
- $testDates = [[2012, 3, 26], [2012, 2, 29], [2012, 4, 1], [2012, 12, 25],
- [2012, 10, 31], [2012, 11, 5], [2012, 1, 1], [2012, 3, 17],
- [2011, 2, 29], [7, 5, 3], [2012, 13, 1], [2012, 11, 45],
- [2012, 0, 0], [2012, 1, 0], [2012, 0, 1],
- [2012, -2, 2], [2012, 2, -2], [2012, -2, -2],
- ];
- $testDateCount = count($testDates);
-
- $worksheet->fromArray($testDates, null, 'A1', true);
-
- for ($row = 1; $row <= $testDateCount; ++$row) {
- $worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
- $worksheet->setCellValue('E' . $row, '=D' . $row);
- }
- $worksheet->getStyle('E1:E' . $testDateCount)
- ->getNumberFormat()
- ->setFormatCode('yyyy-mmm-dd');
-
- echo '
';
-
- // Test the formulae
- ?>
-
-
- Date Value |
- Formula |
- Excel DateStamp |
- Formatted DateStamp |
-
-
- Year |
- Month |
- Day |
-
- ';
- echo '', $worksheet->getCell('A' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('C' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('D' . $row)->getValue(), ' | ';
- echo '', $worksheet->getCell('D' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('E' . $row)->getFormattedValue(), ' | ';
- echo '
';
- }
- ?>
-
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/DateTime/DATEVALUE.php b/docs/Examples/Calculations/DateTime/DATEVALUE.php
deleted file mode 100644
index 535fdcce..00000000
--- a/docs/Examples/Calculations/DateTime/DATEVALUE.php
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- DATEVALUE
- Converts a date in the form of text to a serial number.
- getActiveSheet();
-
- // Add some data
- $testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
- '2012-Oct-31', '5th November', 'January 1st', 'April 2012',
- '17-03', '03-2012', '29 Feb 2011', '03-05-07',
- '03-MAY-07', '03-13-07',
- ];
- $testDateCount = count($testDates);
-
- for ($row = 1; $row <= $testDateCount; ++$row) {
- $worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
- $worksheet->setCellValue('B' . $row, '=DATEVALUE(A' . $row . ')');
- $worksheet->setCellValue('C' . $row, '=B' . $row);
- }
-
- $worksheet->getStyle('C1:C' . $testDateCount)
- ->getNumberFormat()
- ->setFormatCode('yyyy-mmm-dd');
-
- echo '
';
-
- // Test the formulae
- ?>
- Warning: The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.
-
-
- Date String |
- Formula |
- Excel DateStamp |
- Formatted DateStamp |
-
- ';
- echo '', $worksheet->getCell('A' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('C' . $row)->getFormattedValue(), ' | ';
- echo '';
- }
- ?>
-
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/DateTime/TIME.php b/docs/Examples/Calculations/DateTime/TIME.php
deleted file mode 100644
index 09641074..00000000
--- a/docs/Examples/Calculations/DateTime/TIME.php
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- TIME
- Returns the serial number of a particular time.
- getActiveSheet();
-
- // Add some data
- $testDates = [[3, 15], [13, 15], [15, 15, 15], [3, 15, 30],
- [15, 15, 15], [5], [9, 15, 0], [9, 15, -1],
- [13, -14, -15], [0, 0, -1],
- ];
- $testDateCount = count($testDates);
-
- $worksheet->fromArray($testDates, null, 'A1', true);
-
- for ($row = 1; $row <= $testDateCount; ++$row) {
- $worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
- $worksheet->setCellValue('E' . $row, '=D' . $row);
- }
- $worksheet->getStyle('E1:E' . $testDateCount)
- ->getNumberFormat()
- ->setFormatCode('hh:mm:ss');
-
- echo '
';
-
- // Test the formulae
- ?>
-
-
- Date Value |
- Formula |
- Excel TimeStamp |
- Formatted TimeStamp |
-
-
- Hour |
- Minute |
- Second |
-
- ';
- echo '', $worksheet->getCell('A' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('C' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('D' . $row)->getValue(), ' | ';
- echo '', $worksheet->getCell('D' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('E' . $row)->getFormattedValue(), ' | ';
- echo '
';
- }
- ?>
-
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/DateTime/TIMEVALUE.php b/docs/Examples/Calculations/DateTime/TIMEVALUE.php
deleted file mode 100644
index 4cf27c81..00000000
--- a/docs/Examples/Calculations/DateTime/TIMEVALUE.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Examples
-
-
-
-
- TIMEVALUE
- Converts a time in the form of text to a serial number.
- getActiveSheet();
-
- // Add some data
- $testDates = ['3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM',
- ];
- $testDateCount = count($testDates);
-
- for ($row = 1; $row <= $testDateCount; ++$row) {
- $worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
- $worksheet->setCellValue('B' . $row, '=TIMEVALUE(A' . $row . ')');
- $worksheet->setCellValue('C' . $row, '=B' . $row);
- }
-
- $worksheet->getStyle('C1:C' . $testDateCount)
- ->getNumberFormat()
- ->setFormatCode('hh:mm:ss');
-
- echo '
';
-
- // Test the formulae
- ?>
-
-
- Time String |
- Formula |
- Excel TimeStamp |
- Formatted TimeStamp |
-
- ';
- echo '', $worksheet->getCell('A' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getValue(), ' | ';
- echo '', $worksheet->getCell('B' . $row)->getFormattedValue(), ' | ';
- echo '', $worksheet->getCell('C' . $row)->getFormattedValue(), ' | ';
- echo '';
- }
- ?>
-
-
-
\ No newline at end of file
diff --git a/docs/Examples/Calculations/index.php b/docs/Examples/Calculations/index.php
deleted file mode 100644
index ad03fe8e..00000000
--- a/docs/Examples/Calculations/index.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Calculation Function Examples
-
-
-
-
- PhpSpreadsheet Calculation Function Examples';
-
- $exampleTypeList = glob('./*', GLOB_ONLYDIR);
-
- foreach ($exampleTypeList as $exampleType) {
- echo '' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Function Examples
';
-
- $exampleList = glob('./' . $exampleType . '/*.php');
-
- foreach ($exampleList as $exampleFile) {
- $fileData = file_get_contents($exampleFile);
-
- $h1Pattern = '#(.*?)
#';
- $h2Pattern = '#(.*?)
#';
-
- if (preg_match($h1Pattern, $fileData, $out)) {
- $h1Text = $out[1];
- $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
-
- echo '', $h1Text, '
';
- if ($h2Text > '') {
- echo $h2Text, '
';
- }
- }
- }
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader01.php b/docs/Examples/Reader/exampleReader01.php
deleted file mode 100644
index 1e343e5d..00000000
--- a/docs/Examples/Reader/exampleReader01.php
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #01
-
-
-
-
- PhpSpreadsheet Reader Example #01
- Simple File Reader using IOFactory::load()
- ';
- $spreadsheet = IOFactory::load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader02.php b/docs/Examples/Reader/exampleReader02.php
deleted file mode 100644
index c29e7993..00000000
--- a/docs/Examples/Reader/exampleReader02.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #02
-
-
-
-
- PhpSpreadsheet Reader Example #02
- Simple File Reader using a Specified Reader
- ';
- $reader = new Xls();
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader03.php b/docs/Examples/Reader/exampleReader03.php
deleted file mode 100644
index 750d52c2..00000000
--- a/docs/Examples/Reader/exampleReader03.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #03
-
-
-
-
- PhpSpreadsheet Reader Example #03
- Simple File Reader using the IOFactory to Return a Reader
- ';
- $reader = IOFactory::createReader($inputFileType);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader04.php b/docs/Examples/Reader/exampleReader04.php
deleted file mode 100644
index 7b8065d5..00000000
--- a/docs/Examples/Reader/exampleReader04.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #04
-
-
-
-
- PhpSpreadsheet Reader Example #04
- Simple File Reader using the IOFactory to Identify a Reader to Use
- ';
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with the identified reader type
';
- $reader = IOFactory::createReader($inputFileType);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader05.php b/docs/Examples/Reader/exampleReader05.php
deleted file mode 100644
index 2b06e8ac..00000000
--- a/docs/Examples/Reader/exampleReader05.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #05
-
-
-
-
- PhpSpreadsheet Reader Example #05
- Simple File Reader using the "Read Data Only" Option
- ';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Turning Formatting off for Load
';
- $reader->setReadDataOnly(true);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader06.php b/docs/Examples/Reader/exampleReader06.php
deleted file mode 100644
index 04e6b94e..00000000
--- a/docs/Examples/Reader/exampleReader06.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #06
-
-
-
-
- PhpSpreadsheet Reader Example #06
- Simple File Reader Loading All WorkSheets
- ';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Loading all WorkSheets
';
- $reader->setLoadAllSheets();
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo $sheetIndex, ' -> ', $loadedSheetName, '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader07.php b/docs/Examples/Reader/exampleReader07.php
deleted file mode 100644
index 7beabc82..00000000
--- a/docs/Examples/Reader/exampleReader07.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #07
-
-
-
-
- PhpSpreadsheet Reader Example #07
- Simple File Reader Loading a Single Named WorkSheet
- ';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Loading Sheet "', $sheetname, '" only
';
- $reader->setLoadSheetsOnly($sheetname);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo $sheetIndex, ' -> ', $loadedSheetName, '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader08.php b/docs/Examples/Reader/exampleReader08.php
deleted file mode 100644
index c9e574b9..00000000
--- a/docs/Examples/Reader/exampleReader08.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #08
-
-
-
-
- PhpSpreadsheet Reader Example #08
- Simple File Reader Loading Several Named WorkSheets
- ';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Loading Sheet', ((count($sheetnames) == 1) ? '' : 's'), ' "', implode('" and "', $sheetnames), '" only
';
- $reader->setLoadSheetsOnly($sheetnames);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo $sheetIndex, ' -> ', $loadedSheetName, '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader09.php b/docs/Examples/Reader/exampleReader09.php
deleted file mode 100644
index 1c5c4147..00000000
--- a/docs/Examples/Reader/exampleReader09.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #09
-
-
-
-
- PhpSpreadsheet Reader Example #09
- Simple File Reader Using a Read Filter
- = 1 && $row <= 7) {
- if (in_array($column, range('A', 'E'))) {
- return true;
- }
- }
-
- return false;
- }
-
- }
-
- $filterSubset = new MyReadFilter();
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Loading Sheet "', $sheetname, '" only
';
- $reader->setLoadSheetsOnly($sheetname);
- echo 'Loading Sheet using filter
';
- $reader->setReadFilter($filterSubset);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader10.php b/docs/Examples/Reader/exampleReader10.php
deleted file mode 100644
index 6d4517eb..00000000
--- a/docs/Examples/Reader/exampleReader10.php
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #10
-
-
-
-
- PhpSpreadsheet Reader Example #10
- Simple File Reader Using a Configurable Read Filter
- _startRow = $startRow;
- $this->_endRow = $endRow;
- $this->_columns = $columns;
- }
-
- public function readCell($column, $row, $worksheetName = '')
- {
- if ($row >= $this->_startRow && $row <= $this->_endRow) {
- if (in_array($column, $this->_columns)) {
- return true;
- }
- }
-
- return false;
- }
-
- }
-
- $filterSubset = new MyReadFilter(9, 15, range('G', 'K'));
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- $reader = IOFactory::createReader($inputFileType);
- echo 'Loading Sheet "', $sheetname, '" only
';
- $reader->setLoadSheetsOnly($sheetname);
- echo 'Loading Sheet using configurable filter
';
- $reader->setReadFilter($filterSubset);
- $spreadsheet = $reader->load($inputFileName);
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader11.php b/docs/Examples/Reader/exampleReader11.php
deleted file mode 100644
index 67c9ec4d..00000000
--- a/docs/Examples/Reader/exampleReader11.php
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #11
-
-
-
-
- PhpSpreadsheet Reader Example #11
- Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)
- _startRow = $startRow;
- $this->_endRow = $startRow + $chunkSize;
- }
-
- public function readCell($column, $row, $worksheetName = '')
- {
- // Only read the heading row, and the rows that were configured in the constructor
- if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
- return true;
- }
-
- return false;
- }
-
- }
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- /* Create a new Reader of the type defined in $inputFileType * */
- $reader = IOFactory::createReader($inputFileType);
-
- echo '
';
-
- /* Define how many rows we want for each "chunk" * */
- $chunkSize = 20;
-
- /* Loop to read our worksheet in "chunk size" blocks * */
- for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
- echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '
';
- /* Create a new Instance of our Read Filter, passing in the limits on which rows we want to read * */
- $chunkFilter = new chunkReadFilter($startRow, $chunkSize);
- /* Tell the Reader that we want to use the new Read Filter that we've just Instantiated * */
- $reader->setReadFilter($chunkFilter);
- /* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
- $spreadsheet = $reader->load($inputFileName);
-
- // Do some processing here
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- echo '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader12.php b/docs/Examples/Reader/exampleReader12.php
deleted file mode 100644
index f9055ae1..00000000
--- a/docs/Examples/Reader/exampleReader12.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #12
-
-
-
-
- PhpSpreadsheet Reader Example #12
- Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)
- _startRow = $startRow;
- $this->_endRow = $startRow + $chunkSize;
- }
-
- public function readCell($column, $row, $worksheetName = '')
- {
- // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
- if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
- return true;
- }
-
- return false;
- }
-
- }
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- /* Create a new Reader of the type defined in $inputFileType * */
- $reader = IOFactory::createReader($inputFileType);
-
- echo '
';
-
- /* Define how many rows we want to read for each "chunk" * */
- $chunkSize = 20;
- /* Create a new Instance of our Read Filter * */
- $chunkFilter = new chunkReadFilter();
-
- /* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
- $reader->setReadFilter($chunkFilter);
-
- /* Loop to read our worksheet in "chunk size" blocks * */
- for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
- echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '
';
- /* Tell the Read Filter, the limits on which rows we want to read this iteration * */
- $chunkFilter->setRows($startRow, $chunkSize);
- /* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
- $spreadsheet = $reader->load($inputFileName);
-
- // Do some processing here
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- echo '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader13.php b/docs/Examples/Reader/exampleReader13.php
deleted file mode 100644
index e13f1801..00000000
--- a/docs/Examples/Reader/exampleReader13.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #13
-
-
-
-
- PhpSpreadsheet Reader Example #13
- Simple File Reader for Multiple CSV Files
- ';
- $spreadsheet = $reader->load($inputFileName);
- $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
- foreach ($inputFileNames as $sheet => $inputFileName) {
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #', ($sheet + 2), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- $reader->setSheetIndex($sheet + 1);
- $reader->loadIntoExisting($inputFileName, $spreadsheet);
- $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
- }
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo 'Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '
';
- $spreadsheet->setActiveSheetIndexByName($loadedSheetName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- echo '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader14.php b/docs/Examples/Reader/exampleReader14.php
deleted file mode 100644
index 98ab0b65..00000000
--- a/docs/Examples/Reader/exampleReader14.php
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #14
-
-
-
-
- PhpSpreadsheet Reader Example #14
- Reading a Large CSV file in "Chunks" to split across multiple Worksheets
- _startRow = $startRow;
- $this->_endRow = $startRow + $chunkSize;
- }
-
- public function readCell($column, $row, $worksheetName = '')
- {
- // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
- if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
- return true;
- }
-
- return false;
- }
-
- }
-
- echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '
';
- /* Create a new Reader of the type defined in $inputFileType * */
- $reader = IOFactory::createReader($inputFileType);
-
- echo '
';
-
- /* Define how many rows we want to read for each "chunk" * */
- $chunkSize = 100;
- /* Create a new Instance of our Read Filter * */
- $chunkFilter = new chunkReadFilter();
-
- /* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
- /* and that we want to store it in contiguous rows/columns * */
- $reader->setReadFilter($chunkFilter)
- ->setContiguous(true);
-
- /* Instantiate a new PhpSpreadsheet object manually * */
- $spreadsheet = new Spreadsheet();
-
- /* Set a sheet index * */
- $sheet = 0;
- /* Loop to read our worksheet in "chunk size" blocks * */
- /** $startRow is set to 2 initially because we always read the headings in row #1 * */
- for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
- echo 'Loading WorkSheet #', ($sheet + 1), ' using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '
';
- /* Tell the Read Filter, the limits on which rows we want to read this iteration * */
- $chunkFilter->setRows($startRow, $chunkSize);
-
- /* Increment the worksheet index pointer for the Reader * */
- $reader->setSheetIndex($sheet);
- /* Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object * */
- $reader->loadIntoExisting($inputFileName, $spreadsheet);
- /* Set the worksheet title (to reference the "sheet" of data that we've loaded) * */
- /* and increment the sheet index as well * */
- $spreadsheet->getActiveSheet()->setTitle('Country Data #' . ( ++$sheet));
- }
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo 'Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '
';
- $spreadsheet->setActiveSheetIndexByName($loadedSheetName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
- var_dump($sheetData);
- echo '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader15.php b/docs/Examples/Reader/exampleReader15.php
deleted file mode 100644
index be913444..00000000
--- a/docs/Examples/Reader/exampleReader15.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #15
-
-
-
-
- PhpSpreadsheet Reader Example #15
- Simple File Reader for Tab-Separated Value File using the Advanced Value Binder
- ';
- $reader->setDelimiter("\t");
- $spreadsheet = $reader->load($inputFileName);
- $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
-
- echo '
';
-
- echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded
';
- $loadedSheetNames = $spreadsheet->getSheetNames();
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo 'Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Formatted)
';
- $spreadsheet->setActiveSheetIndexByName($loadedSheetName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- echo '
';
- }
-
- echo '
';
-
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo 'Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Unformatted)
';
- $spreadsheet->setActiveSheetIndexByName($loadedSheetName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, false, true);
- var_dump($sheetData);
- echo '
';
- }
-
- echo '
';
-
- foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
- echo 'Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Raw)
';
- $spreadsheet->setActiveSheetIndexByName($loadedSheetName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
- var_dump($sheetData);
- echo '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader16.php b/docs/Examples/Reader/exampleReader16.php
deleted file mode 100644
index aa4bc469..00000000
--- a/docs/Examples/Reader/exampleReader16.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #16
-
-
-
-
- PhpSpreadsheet Reader Example #16
- Handling Loader Exceptions using Try/Catch
- ';
- try {
- $spreadsheet = IOFactory::load($inputFileName);
- } catch (InvalidArgumentException $e) {
- die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
- }
-
- echo '
';
-
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- var_dump($sheetData);
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader17.php b/docs/Examples/Reader/exampleReader17.php
deleted file mode 100644
index 3c6ebf30..00000000
--- a/docs/Examples/Reader/exampleReader17.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #17
-
-
-
-
- PhpSpreadsheet Reader Example #17
- Simple File Reader Loading Several Named WorkSheets
- ';
- $reader = IOFactory::createReader($inputFileType);
-
- /* Read the list of Worksheet Names from the Workbook file * */
- echo 'Read the list of Worksheets in the WorkBook
';
- $worksheetNames = $reader->listWorksheetNames($inputFileName);
-
- echo 'There are ', count($worksheetNames), ' worksheet', ((count($worksheetNames) == 1) ? '' : 's'), ' in the workbook
';
- foreach ($worksheetNames as $worksheetName) {
- echo $worksheetName, '
';
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader18.php b/docs/Examples/Reader/exampleReader18.php
deleted file mode 100644
index 68a478bb..00000000
--- a/docs/Examples/Reader/exampleReader18.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #18
-
-
-
-
- PhpSpreadsheet Reader Example #18
- Reading list of WorkSheets without loading entire file
- ';
-
- $reader = IOFactory::createReader($inputFileType);
- $worksheetNames = $reader->listWorksheetNames($inputFileName);
-
- echo 'Worksheet Names
';
- echo '';
- foreach ($worksheetNames as $worksheetName) {
- echo '- ', $worksheetName, '
';
- }
- echo '
';
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reader/exampleReader19.php b/docs/Examples/Reader/exampleReader19.php
deleted file mode 100644
index dea2dd06..00000000
--- a/docs/Examples/Reader/exampleReader19.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reader Example #19
-
-
-
-
- PhpSpreadsheet Reader Example #19
- Reading WorkSheet information without loading entire file
- ';
-
- $reader = IOFactory::createReader($inputFileType);
- $worksheetData = $reader->listWorksheetInfo($inputFileName);
-
- echo 'Worksheet Information
';
- echo '';
- foreach ($worksheetData as $worksheet) {
- echo '- ', $worksheet['worksheetName'], '
';
- echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '
';
- echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows'];
- echo ' ';
- }
- echo '
';
- ?>
-
-
\ No newline at end of file
diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php
deleted file mode 100644
index 9085b394..00000000
--- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #01
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #01
- Read the WorkBook Properties
- load($inputFileName);
-
- echo '
';
-
- /* Read the document's creator property * */
- $creator = $spreadsheet->getProperties()->getCreator();
- echo 'Document Creator: ', $creator, '
';
-
- /* Read the Date when the workbook was created (as a PHP timestamp value) * */
- $creationDatestamp = $spreadsheet->getProperties()->getCreated();
- /* Format the date and time using the standard PHP date() function * */
- $creationDate = date('l, d<\s\up>S\s\up> F Y', $creationDatestamp);
- $creationTime = date('g:i A', $creationDatestamp);
- echo 'Created On: ', $creationDate, ' at ', $creationTime, '
';
-
- /* Read the name of the last person to modify this workbook * */
- $modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy();
- echo 'Last Modified By: ', $modifiedBy, '
';
-
- /* Read the Date when the workbook was last modified (as a PHP timestamp value) * */
- $modifiedDatestamp = $spreadsheet->getProperties()->getModified();
- /* Format the date and time using the standard PHP date() function * */
- $modifiedDate = date('l, d<\s\up>S\s\up> F Y', $modifiedDatestamp);
- $modifiedTime = date('g:i A', $modifiedDatestamp);
- echo 'Last Modified On: ', $modifiedDate, ' at ', $modifiedTime, '
';
-
- /* Read the workbook title property * */
- $workbookTitle = $spreadsheet->getProperties()->getTitle();
- echo 'Title: ', $workbookTitle, '
';
-
- /* Read the workbook description property * */
- $description = $spreadsheet->getProperties()->getDescription();
- echo 'Description: ', $description, '
';
-
- /* Read the workbook subject property * */
- $subject = $spreadsheet->getProperties()->getSubject();
- echo 'Subject: ', $subject, '
';
-
- /* Read the workbook keywords property * */
- $keywords = $spreadsheet->getProperties()->getKeywords();
- echo 'Keywords: ', $keywords, '
';
-
- /* Read the workbook category property * */
- $category = $spreadsheet->getProperties()->getCategory();
- echo 'Category: ', $category, '
';
-
- /* Read the workbook company property * */
- $company = $spreadsheet->getProperties()->getCompany();
- echo 'Company: ', $company, '
';
-
- /* Read the workbook manager property * */
- $manager = $spreadsheet->getProperties()->getManager();
- echo 'Manager: ', $manager, '
';
- ?>
-
-
diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php
deleted file mode 100644
index b643f74b..00000000
--- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #02
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #02
- Read a list of Custom Properties for a WorkBook
- load($inputFileName);
-
- echo '
';
-
- /* Read an array list of any custom properties for this document * */
- $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
-
- echo 'Custom Property names:
';
- foreach ($customPropertyList as $customPropertyName) {
- echo $customPropertyName, '
';
- }
- ?>
-
-
diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php
deleted file mode 100644
index 432099aa..00000000
--- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #03
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #03
- Read Custom Property Values for a WorkBook
- load($inputFileName);
-
- echo '
';
-
- /* Read an array list of any custom properties for this document * */
- $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
-
- echo 'Custom Properties:
';
- /* Loop through the list of custom properties * */
- foreach ($customPropertyList as $customPropertyName) {
- echo '', $customPropertyName, ': ';
- /* Retrieve the property value * */
- $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName);
- /* Retrieve the property type * */
- $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName);
-
- /* Manipulate properties as appropriate for display purposes * */
- switch ($propertyType) {
- case 'i': // integer
- $propertyType = 'integer number';
- break;
- case 'f': // float
- $propertyType = 'floating point number';
- break;
- case 's': // string
- $propertyType = 'string';
- break;
- case 'd': // date
- $propertyValue = date('l, d<\s\up>S\s\up> F Y g:i A', $propertyValue);
- $propertyType = 'date';
- break;
- case 'b': // boolean
- $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
- $propertyType = 'boolean';
- break;
- }
-
- echo $propertyValue, ' (', $propertyType, ')
';
- }
- ?>
-
-
diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php
deleted file mode 100644
index 7299e783..00000000
--- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #04
-
-
-
-
- PhpSpreadsheet Reading WorkBook Data Example #04
- Get a List of the Worksheets in a WorkBook
- load($inputFileName);
-
- echo '
';
-
- echo 'Reading the number of Worksheets in the WorkBook
';
- /* Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
- $sheetCount = $spreadsheet->getSheetCount();
- echo 'There ', (($sheetCount == 1) ? 'is' : 'are'), ' ', $sheetCount, ' WorkSheet', (($sheetCount == 1) ? '' : 's'), ' in the WorkBook
';
-
- echo 'Reading the names of Worksheets in the WorkBook
';
- /* Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
- $sheetNames = $spreadsheet->getSheetNames();
- foreach ($sheetNames as $sheetIndex => $sheetName) {
- echo 'WorkSheet #', $sheetIndex, ' is named "', $sheetName, '"
';
- }
- ?>
-
-
diff --git a/docs/Examples/index.php b/docs/Examples/index.php
deleted file mode 100644
index 9ff0929d..00000000
--- a/docs/Examples/index.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
- PhpSpreadsheet Examples
-
-
-
-
- PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples';
-
- $exampleList = glob('./' . $exampleType . '/*.php');
-
- foreach ($exampleList as $exampleFile) {
- $fileData = file_get_contents($exampleFile);
-
- $h1Pattern = '#(.*?)
#';
- $h2Pattern = '#(.*?)
#';
-
- if (preg_match($h1Pattern, $fileData, $out)) {
- $h1Text = $out[1];
- $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
-
- echo '', $h1Text, '
';
- if (($h2Text > '') &&
- (pathinfo($exampleType, PATHINFO_BASENAME) != 'Calculations')) {
- echo $h2Text, '
';
- }
- }
- }
- }
- ?>
-
-
\ No newline at end of file
diff --git a/docs/topics/autofilters.md b/docs/topics/autofilters.md
index f6b0c572..15be56f8 100644
--- a/docs/topics/autofilters.md
+++ b/docs/topics/autofilters.md
@@ -519,7 +519,7 @@ foreach ($spreadsheet->getActiveSheet()->getRowIterator() as $row) {
->getCell(
'D'.$row->getRowIndex()
)->getFormattedValue(), ' ';
- echo EOL;
+ echo PHP_EOL;
}
}
```
diff --git a/docs/topics/reading-files.md b/docs/topics/reading-files.md
index afd3db35..35ae7ed7 100644
--- a/docs/topics/reading-files.md
+++ b/docs/topics/reading-files.md
@@ -27,8 +27,8 @@ $inputFileName = './sampleData/example1.xls';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
```
-> See Examples/Reader/exampleReader01.php for a working example of this
-> code.
+See `samples/Reader/01_Simple_file_reader_using_IOFactory.php` for a working
+example of this code.
The `load()` method will attempt to identify the file type, and
instantiate a loader for that file type; using it to load the file and
@@ -72,8 +72,8 @@ $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader02.php for a working example of this
-> code.
+See `samples/Reader/02_Simple_file_reader_using_a_specified_reader.php`
+for a working example of this code.
Alternatively, you can use the IO Factory's `createReader()` method to
instantiate the reader object for you, simply telling it the file type
@@ -95,8 +95,8 @@ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader03.php for a working example of this
-> code.
+See `samples/Reader/03_Simple_file_reader_using_the_IOFactory_to_return_a_reader.php`
+for a working example of this code.
If you're uncertain of the filetype, you can use the IO Factory's
identify() method to identify the reader that you need, before using the
@@ -113,8 +113,8 @@ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader04.php for a working example of this
-> code.
+See `samples/Reader/04_Simple_file_reader_using_the_IOFactory_to_identify_a_reader_to_use.php`
+for a working example of this code.
## Spreadsheet Reader Options
@@ -141,8 +141,8 @@ $reader->setReadDataOnly(true);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader05.php for a working example of this
-> code.
+See `samples/Reader/05_Simple_file_reader_using_the_read_data_only_option.php`
+for a working example of this code.
It is important to note that Workbooks (and PhpSpreadsheet) store dates
and times as simple numeric values: they can only be distinguished from
@@ -187,8 +187,8 @@ $reader->setLoadSheetsOnly($sheetname);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader07.php for a working example of this
-> code.
+See `samples/Reader/07_Simple_file_reader_loading_a_single_named_worksheet.php`
+for a working example of this code.
If you want to read more than just a single sheet, you can pass a list
of sheet names as an array parameter to the `setLoadSheetsOnly()` method.
@@ -206,8 +206,8 @@ $reader->setLoadSheetsOnly($sheetnames);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader08.php for a working example of this
-> code.
+See `samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php`
+for a working example of this code.
To reset this option to the default, you can call the `setLoadAllSheets()`
method.
@@ -224,8 +224,8 @@ $reader->setLoadAllSheets();
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader06.php for a working example of this
-> code.
+See `samples/Reader/06_Simple_file_reader_loading_all_worksheets.php` for a
+working example of this code.
Reading Only Named WorkSheets from a File applies to Readers:
@@ -277,8 +277,8 @@ $reader->setReadFilter($filterSubset);
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader09.php for a working example of this
-> code.
+See `samples/Reader/09_Simple_file_reader_using_a_read_filter.php` for a
+working example of this code.
This example is not particularly useful, because it can only be used in
a very specific circumstance (when you only want cells in the range
@@ -315,8 +315,8 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
$filterSubset = new MyReadFilter(9,15,range('G','K'));
```
-> See Examples/Reader/exampleReader10.php for a working example of this
-> code.
+See `samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php`
+for a working example of this code.
This can be particularly useful for conserving memory, by allowing you
to read and process a large workbook in "chunks": an example of this
@@ -329,7 +329,7 @@ $inputFileName = './sampleData/example2.xls';
/** Define a Read Filter class implementing \PhpOffice\PhpSpreadsheet\Reader\IReadFilter */
-class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
+class ChunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
{
private $_startRow = 0;
private $_endRow = 0;
@@ -357,7 +357,7 @@ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Define how many rows we want to read for each "chunk" **/
$chunkSize = 2048;
/** Create a new Instance of our Read Filter **/
-$chunkFilter = new chunkReadFilter();
+$chunkFilter = new ChunkReadFilter();
/** Tell the Reader that we want to use the Read Filter **/
$reader->setReadFilter($chunkFilter);
@@ -372,8 +372,8 @@ for ($startRow = 2; $startRow <= 65536; $startRow += $chunkSize) {
}
```
-> See Examples/Reader/exampleReader12.php for a working example of this
-> code.
+See `samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_`
+for a working example of this code.
Using Read Filters applies to:
@@ -427,8 +427,8 @@ foreach($inputFileNames as $sheet => $inputFileName) {
}
```
-> See Examples/Reader/exampleReader13.php for a working example of this
-> code.
+See `samples/Reader/13_Simple_file_reader_for_multiple_CSV_files.php` for a
+working example of this code.
Note that using the same sheet index for multiple sheets won't append
files into the same sheet, but overwrite the results of the previous
@@ -450,7 +450,7 @@ Xlsx Microsoft Office Open XML SpreadsheetML .xlsx file is limited to
by available disk space. This means that we wouldn’t ordinarily be able
to read all the rows from a very large CSV file that exceeded those
limits, and save it as an Xls or Xlsx file. However, by using Read
-Filters to read the CSV file in "chunks" (using the chunkReadFilter
+Filters to read the CSV file in "chunks" (using the ChunkReadFilter
Class that we defined in [the above section](#reading-only-specific-columns-and-rows-from-a-file-read-filters),
and the `setSheetIndex()` method of the `$reader`, we can split the CSV
file across several individual worksheets.
@@ -468,7 +468,7 @@ $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Define how many rows we want to read for each "chunk" **/
$chunkSize = 65530;
/** Create a new Instance of our Read Filter **/
-$chunkFilter = new chunkReadFilter();
+$chunkFilter = new ChunkReadFilter();
/** Tell the Reader that we want to use the Read Filter **/
/** and that we want to store it in contiguous rows/columns **/
@@ -497,8 +497,8 @@ for ($startRow = 2; $startRow <= 1000000; $startRow += $chunkSize) {
}
```
-> See Examples/Reader/exampleReader14.php for a working example of this
-> code.
+See `samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php`
+for a working example of this code.
This code will read 65,530 rows at a time from the CSV file that we’re
loading, and store each "chunk" in a new worksheet.
@@ -542,8 +542,8 @@ $reader->setDelimiter("\t");
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader15.php for a working example of this
-> code.
+See `samples/Reader/15_Simple_file_reader_for_tab_separated_value_file_using_the_Advanced_Value_Binder.php`
+for a working example of this code.
In addition to the delimiter, you can also use the following methods to
set other attributes for the data load:
@@ -603,8 +603,8 @@ $reader->setDelimiter("\t");
$spreadsheet = $reader->load($inputFileName);
```
-> See Examples/Reader/exampleReader15.php for a working example of this
-> code.
+See `samples/Reader/15_Simple_file_reader_for_tab_separated_value_file_using_the_Advanced_Value_Binder.php`
+for a working example of this code.
Loading using a Value Binder applies to:
@@ -636,8 +636,8 @@ try {
}
```
-> See Examples/Reader/exampleReader16.php for a working example of this
-> code.
+See `samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php` for a
+working example of this code.
## Helper Methods
@@ -665,8 +665,8 @@ foreach ($worksheetNames as $worksheetName) {
echo '';
```
-> See Examples/Reader/exampleReader18.php for a working example of this
-> code.
+See `samples/Reader/18_Reading_list_of_worksheets_without_loading_entire_file.php`
+for a working example of this code.
### listWorksheetInfo
@@ -691,5 +691,5 @@ foreach ($worksheetData as $worksheet) {
echo '';
```
-> See Examples/Reader/exampleReader19.php for a working example of this
-> code.
+See `samples/Reader/19_Reading_worksheet_information_without_loading_entire_file.php`
+for a working example of this code.
diff --git a/samples/05_Feature_demo.php b/samples/05_Feature_demo.php
deleted file mode 100644
index 0fbb86a6..00000000
--- a/samples/05_Feature_demo.php
+++ /dev/null
@@ -1,7 +0,0 @@
-write($spreadsheet, __FILE__);
diff --git a/samples/06_Largescale.php b/samples/06_Largescale.php
deleted file mode 100644
index a5054c34..00000000
--- a/samples/06_Largescale.php
+++ /dev/null
@@ -1,8 +0,0 @@
-write($spreadsheet, __FILE__);
diff --git a/samples/13_Calculation.php b/samples/13_Calculation.php
deleted file mode 100644
index e143e9ab..00000000
--- a/samples/13_Calculation.php
+++ /dev/null
@@ -1,178 +0,0 @@
-log('List implemented functions');
-$calc = Calculation::getInstance();
-print_r($calc->getImplementedFunctionNames());
-
-// Create new Spreadsheet object
-$helper->log('Create new Spreadsheet object');
-$spreadsheet = new Spreadsheet();
-
-// Add some data, we will use some formulas here
-$helper->log('Add some data and formulas');
-$spreadsheet->getActiveSheet()->setCellValue('A14', 'Count:')
- ->setCellValue('A15', 'Sum:')
- ->setCellValue('A16', 'Max:')
- ->setCellValue('A17', 'Min:')
- ->setCellValue('A18', 'Average:')
- ->setCellValue('A19', 'Median:')
- ->setCellValue('A20', 'Mode:');
-
-$spreadsheet->getActiveSheet()->setCellValue('A22', 'CountA:')
- ->setCellValue('A23', 'MaxA:')
- ->setCellValue('A24', 'MinA:');
-
-$spreadsheet->getActiveSheet()->setCellValue('A26', 'StDev:')
- ->setCellValue('A27', 'StDevA:')
- ->setCellValue('A28', 'StDevP:')
- ->setCellValue('A29', 'StDevPA:');
-
-$spreadsheet->getActiveSheet()->setCellValue('A31', 'DevSq:')
- ->setCellValue('A32', 'Var:')
- ->setCellValue('A33', 'VarA:')
- ->setCellValue('A34', 'VarP:')
- ->setCellValue('A35', 'VarPA:');
-
-$spreadsheet->getActiveSheet()->setCellValue('A37', 'Date:');
-
-$spreadsheet->getActiveSheet()->setCellValue('B1', 'Range 1')
- ->setCellValue('B2', 2)
- ->setCellValue('B3', 8)
- ->setCellValue('B4', 10)
- ->setCellValue('B5', true)
- ->setCellValue('B6', false)
- ->setCellValue('B7', 'Text String')
- ->setCellValue('B9', '22')
- ->setCellValue('B10', 4)
- ->setCellValue('B11', 6)
- ->setCellValue('B12', 12);
-
-$spreadsheet->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)')
- ->setCellValue('B15', '=SUM(B2:B12)')
- ->setCellValue('B16', '=MAX(B2:B12)')
- ->setCellValue('B17', '=MIN(B2:B12)')
- ->setCellValue('B18', '=AVERAGE(B2:B12)')
- ->setCellValue('B19', '=MEDIAN(B2:B12)')
- ->setCellValue('B20', '=MODE(B2:B12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)')
- ->setCellValue('B23', '=MAXA(B2:B12)')
- ->setCellValue('B24', '=MINA(B2:B12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)')
- ->setCellValue('B27', '=STDEVA(B2:B12)')
- ->setCellValue('B28', '=STDEVP(B2:B12)')
- ->setCellValue('B29', '=STDEVPA(B2:B12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)')
- ->setCellValue('B32', '=VAR(B2:B12)')
- ->setCellValue('B33', '=VARA(B2:B12)')
- ->setCellValue('B34', '=VARP(B2:B12)')
- ->setCellValue('B35', '=VARPA(B2:B12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)')
- ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )')
- ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")')
- ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )')
- ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
-
-$spreadsheet->getActiveSheet()->setCellValue('C1', 'Range 2')
- ->setCellValue('C2', 1)
- ->setCellValue('C3', 2)
- ->setCellValue('C4', 2)
- ->setCellValue('C5', 3)
- ->setCellValue('C6', 3)
- ->setCellValue('C7', 3)
- ->setCellValue('C8', '0')
- ->setCellValue('C9', 4)
- ->setCellValue('C10', 4)
- ->setCellValue('C11', 4)
- ->setCellValue('C12', 4);
-
-$spreadsheet->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)')
- ->setCellValue('C15', '=SUM(C2:C12)')
- ->setCellValue('C16', '=MAX(C2:C12)')
- ->setCellValue('C17', '=MIN(C2:C12)')
- ->setCellValue('C18', '=AVERAGE(C2:C12)')
- ->setCellValue('C19', '=MEDIAN(C2:C12)')
- ->setCellValue('C20', '=MODE(C2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)')
- ->setCellValue('C23', '=MAXA(C2:C12)')
- ->setCellValue('C24', '=MINA(C2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)')
- ->setCellValue('C27', '=STDEVA(C2:C12)')
- ->setCellValue('C28', '=STDEVP(C2:C12)')
- ->setCellValue('C29', '=STDEVPA(C2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)')
- ->setCellValue('C32', '=VAR(C2:C12)')
- ->setCellValue('C33', '=VARA(C2:C12)')
- ->setCellValue('C34', '=VARP(C2:C12)')
- ->setCellValue('C35', '=VARPA(C2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('D1', 'Range 3')
- ->setCellValue('D2', 2)
- ->setCellValue('D3', 3)
- ->setCellValue('D4', 4);
-
-$spreadsheet->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
-
-$spreadsheet->getActiveSheet()->setCellValue('E12', 'Other functions')
- ->setCellValue('E14', '=PI()')
- ->setCellValue('E15', '=RAND()')
- ->setCellValue('E16', '=RANDBETWEEN(5, 10)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E17', 'Count of both ranges:')
- ->setCellValue('F17', '=COUNT(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E18', 'Total of both ranges:')
- ->setCellValue('F18', '=SUM(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:')
- ->setCellValue('F19', '=MAX(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:')
- ->setCellValue('F20', '=MIN(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E21', 'Average of both ranges:')
- ->setCellValue('F21', '=AVERAGE(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E22', 'Median of both ranges:')
- ->setCellValue('F22', '=MEDIAN(B2:C12)');
-
-$spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
- ->setCellValue('F23', '=MODE(B2:C12)');
-
-// Calculated data
-$helper->log('Calculated data');
-for ($col = 'B'; $col != 'G'; ++$col) {
- for ($row = 14; $row <= 41; ++$row) {
- if ((!is_null($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue())) &&
- ($formula[0] == '=')) {
- echo 'Value of ', $col, $row, ' [', $formula, ']: ',
- $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue() . EOL;
- }
- }
-}
-
-//
-// If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the
-// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
-// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
-// If the value is false (the default) for the Xlsx Writer, then MS Excel (or the application used to
-// open the file) will need to recalculate values itself to guarantee that the correct results are available.
-//
-//$writer->setPreCalculateFormulas(true);
-
-// Save
-$helper->write($spreadsheet, __FILE__);
diff --git a/samples/10_Autofilter.php b/samples/Autofilter/10_Autofilter.php
similarity index 98%
rename from samples/10_Autofilter.php
rename to samples/Autofilter/10_Autofilter.php
index 7058e6a5..04d176ce 100644
--- a/samples/10_Autofilter.php
+++ b/samples/Autofilter/10_Autofilter.php
@@ -2,7 +2,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/10_Autofilter_selection_1.php b/samples/Autofilter/10_Autofilter_selection_1.php
similarity index 99%
rename from samples/10_Autofilter_selection_1.php
rename to samples/Autofilter/10_Autofilter_selection_1.php
index 1b34b019..9bc47f8b 100644
--- a/samples/10_Autofilter_selection_1.php
+++ b/samples/Autofilter/10_Autofilter_selection_1.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/10_Autofilter_selection_2.php b/samples/Autofilter/10_Autofilter_selection_2.php
similarity index 99%
rename from samples/10_Autofilter_selection_2.php
rename to samples/Autofilter/10_Autofilter_selection_2.php
index 9bfb254a..9d0afa0f 100644
--- a/samples/10_Autofilter_selection_2.php
+++ b/samples/Autofilter/10_Autofilter_selection_2.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/10_Autofilter_selection_display.php b/samples/Autofilter/10_Autofilter_selection_display.php
similarity index 95%
rename from samples/10_Autofilter_selection_display.php
rename to samples/Autofilter/10_Autofilter_selection_display.php
index 2be654d3..9a6e8c88 100644
--- a/samples/10_Autofilter_selection_display.php
+++ b/samples/Autofilter/10_Autofilter_selection_display.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
@@ -163,9 +163,8 @@ $spreadsheet->setActiveSheetIndex(0);
$helper->log('Display filtered rows');
foreach ($spreadsheet->getActiveSheet()->getRowIterator() as $row) {
if ($spreadsheet->getActiveSheet()->getRowDimension($row->getRowIndex())->getVisible()) {
- echo ' Row number - ', $row->getRowIndex(), ' ';
- echo $spreadsheet->getActiveSheet()->getCell('C' . $row->getRowIndex())->getValue(), ' ';
- echo $spreadsheet->getActiveSheet()->getCell('D' . $row->getRowIndex())->getFormattedValue(), ' ';
- echo EOL;
+ $helper->log(' Row number - ' . $row->getRowIndex());
+ $helper->log($spreadsheet->getActiveSheet()->getCell('C' . $row->getRowIndex())->getValue());
+ $helper->log($spreadsheet->getActiveSheet()->getCell('D' . $row->getRowIndex())->getFormattedValue());
}
}
diff --git a/samples/01_Simple.php b/samples/Basic/01_Simple.php
similarity index 98%
rename from samples/01_Simple.php
rename to samples/Basic/01_Simple.php
index 3ba6ba05..02e39de0 100644
--- a/samples/01_Simple.php
+++ b/samples/Basic/01_Simple.php
@@ -2,7 +2,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$spreadsheet = new Spreadsheet();
$helper->log('Create new Spreadsheet object');
diff --git a/samples/01_Simple_download_ods.php b/samples/Basic/01_Simple_download_ods.php
similarity index 93%
rename from samples/01_Simple_download_ods.php
rename to samples/Basic/01_Simple_download_ods.php
index 4031eec6..50a35768 100644
--- a/samples/01_Simple_download_ods.php
+++ b/samples/Basic/01_Simple_download_ods.php
@@ -4,11 +4,11 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require_once __DIR__ . '/../src/Bootstrap.php';
+require_once __DIR__ . '/../../src/Bootstrap.php';
$helper = new Sample();
if ($helper->isCli()) {
- echo 'This example should only be run from a Web Browser' . PHP_EOL;
+ $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
return;
}
diff --git a/samples/01_Simple_download_pdf.php b/samples/Basic/01_Simple_download_pdf.php
similarity index 93%
rename from samples/01_Simple_download_pdf.php
rename to samples/Basic/01_Simple_download_pdf.php
index 04c91a18..7f013194 100644
--- a/samples/01_Simple_download_pdf.php
+++ b/samples/Basic/01_Simple_download_pdf.php
@@ -5,11 +5,11 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Settings;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require_once __DIR__ . '/../src/Bootstrap.php';
+require_once __DIR__ . '/../../src/Bootstrap.php';
$helper = new Sample();
if ($helper->isCli()) {
- echo 'This example should only be run from a Web Browser' . PHP_EOL;
+ $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
return;
}
diff --git a/samples/01_Simple_download_xls.php b/samples/Basic/01_Simple_download_xls.php
similarity index 93%
rename from samples/01_Simple_download_xls.php
rename to samples/Basic/01_Simple_download_xls.php
index 71fcbc7e..94fb789e 100644
--- a/samples/01_Simple_download_xls.php
+++ b/samples/Basic/01_Simple_download_xls.php
@@ -4,11 +4,11 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require_once __DIR__ . '/../src/Bootstrap.php';
+require_once __DIR__ . '/../../src/Bootstrap.php';
$helper = new Sample();
if ($helper->isCli()) {
- echo 'This example should only be run from a Web Browser' . PHP_EOL;
+ $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
return;
}
diff --git a/samples/01_Simple_download_xlsx.php b/samples/Basic/01_Simple_download_xlsx.php
similarity index 93%
rename from samples/01_Simple_download_xlsx.php
rename to samples/Basic/01_Simple_download_xlsx.php
index 45ba9bc3..4262b9cd 100644
--- a/samples/01_Simple_download_xlsx.php
+++ b/samples/Basic/01_Simple_download_xlsx.php
@@ -4,11 +4,11 @@ use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require_once __DIR__ . '/../src/Bootstrap.php';
+require_once __DIR__ . '/../../src/Bootstrap.php';
$helper = new Sample();
if ($helper->isCli()) {
- echo 'This example should only be run from a Web Browser' . PHP_EOL;
+ $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
return;
}
diff --git a/samples/02_Types.php b/samples/Basic/02_Types.php
similarity index 99%
rename from samples/02_Types.php
rename to samples/Basic/02_Types.php
index 84bc5002..a61a9d6a 100644
--- a/samples/02_Types.php
+++ b/samples/Basic/02_Types.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/03_Formulas.php b/samples/Basic/03_Formulas.php
similarity index 82%
rename from samples/03_Formulas.php
rename to samples/Basic/03_Formulas.php
index 752b99c8..0d810738 100644
--- a/samples/03_Formulas.php
+++ b/samples/Basic/03_Formulas.php
@@ -2,7 +2,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
@@ -35,31 +35,31 @@ $spreadsheet->getActiveSheet()->setCellValue('C1', 'Range #2')
->setCellValue('C3', 11)
->setCellValue('C4', 17)
->setCellValue('C5', '=SUM(C2:C4)');
-$helper->log('Sum of Range #2 is ', $spreadsheet->getActiveSheet()->getCell('C5')->getCalculatedValue());
+$helper->log('Sum of Range #2 is ' . $spreadsheet->getActiveSheet()->getCell('C5')->getCalculatedValue());
$spreadsheet->getActiveSheet()
->setCellValue('A7', 'Total of both ranges:');
$spreadsheet->getActiveSheet()
->setCellValue('B7', '=SUM(B5:C5)');
-$helper->log('Sum of both Ranges is ', $spreadsheet->getActiveSheet()->getCell('B7')->getCalculatedValue());
+$helper->log('Sum of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B7')->getCalculatedValue());
$spreadsheet->getActiveSheet()
->setCellValue('A8', 'Minimum of both ranges:');
$spreadsheet->getActiveSheet()
->setCellValue('B8', '=MIN(B2:C4)');
-$helper->log('Minimum value in either Range is ', $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue());
+$helper->log('Minimum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B8')->getCalculatedValue());
$spreadsheet->getActiveSheet()
->setCellValue('A9', 'Maximum of both ranges:');
$spreadsheet->getActiveSheet()
->setCellValue('B9', '=MAX(B2:C4)');
-$helper->log('Maximum value in either Range is ', $spreadsheet->getActiveSheet()->getCell('B9')->getCalculatedValue());
+$helper->log('Maximum value in either Range is ' . $spreadsheet->getActiveSheet()->getCell('B9')->getCalculatedValue());
$spreadsheet->getActiveSheet()
->setCellValue('A10', 'Average of both ranges:');
$spreadsheet->getActiveSheet()
->setCellValue('B10', '=AVERAGE(B2:C4)');
-$helper->log('Average value of both Ranges is ', $spreadsheet->getActiveSheet()->getCell('B10')->getCalculatedValue());
+$helper->log('Average value of both Ranges is ' . $spreadsheet->getActiveSheet()->getCell('B10')->getCalculatedValue());
$spreadsheet->getActiveSheet()
->getColumnDimension('A')
->setAutoSize(true);
diff --git a/samples/04_Printing.php b/samples/Basic/04_Printing.php
similarity index 95%
rename from samples/04_Printing.php
rename to samples/Basic/04_Printing.php
index e8854821..fc340a6c 100644
--- a/samples/04_Printing.php
+++ b/samples/Basic/04_Printing.php
@@ -5,7 +5,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter;
use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
@@ -41,7 +41,7 @@ $spreadsheet->getActiveSheet()
$helper->log('Add a drawing to the header');
$drawing = new HeaderFooterDrawing();
$drawing->setName('PhpSpreadsheet logo');
-$drawing->setPath(__DIR__ . '/images/PhpSpreadsheet_logo.png');
+$drawing->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
$drawing->setHeight(36);
$spreadsheet->getActiveSheet()
->getHeaderFooter()
diff --git a/samples/Basic/05_Feature_demo.php b/samples/Basic/05_Feature_demo.php
new file mode 100644
index 00000000..a85ebbc2
--- /dev/null
+++ b/samples/Basic/05_Feature_demo.php
@@ -0,0 +1,7 @@
+write($spreadsheet, __FILE__);
diff --git a/samples/Basic/06_Largescale.php b/samples/Basic/06_Largescale.php
new file mode 100644
index 00000000..2e8a3e67
--- /dev/null
+++ b/samples/Basic/06_Largescale.php
@@ -0,0 +1,8 @@
+write($spreadsheet, __FILE__);
diff --git a/samples/07_Reader.php b/samples/Basic/07_Reader.php
similarity index 78%
rename from samples/07_Reader.php
rename to samples/Basic/07_Reader.php
index 05186521..4d9bd79e 100644
--- a/samples/07_Reader.php
+++ b/samples/Basic/07_Reader.php
@@ -3,10 +3,10 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create temporary file that will be read
-$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$filename = $helper->getTemporaryFilename();
$writer = new Xlsx($sampleSpreadsheet);
$writer->save($filename);
diff --git a/samples/08_Conditional_formatting.php b/samples/Basic/08_Conditional_formatting.php
similarity index 99%
rename from samples/08_Conditional_formatting.php
rename to samples/Basic/08_Conditional_formatting.php
index 36c3aaee..e73fa3f6 100644
--- a/samples/08_Conditional_formatting.php
+++ b/samples/Basic/08_Conditional_formatting.php
@@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/08_Conditional_formatting_2.php b/samples/Basic/08_Conditional_formatting_2.php
similarity index 98%
rename from samples/08_Conditional_formatting_2.php
rename to samples/Basic/08_Conditional_formatting_2.php
index 07d2361d..0bf4a30c 100644
--- a/samples/08_Conditional_formatting_2.php
+++ b/samples/Basic/08_Conditional_formatting_2.php
@@ -5,7 +5,7 @@ use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/09_Pagebreaks.php b/samples/Basic/09_Pagebreaks.php
similarity index 98%
rename from samples/09_Pagebreaks.php
rename to samples/Basic/09_Pagebreaks.php
index c4cf33af..31bc17a1 100644
--- a/samples/09_Pagebreaks.php
+++ b/samples/Basic/09_Pagebreaks.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/11_Documentsecurity.php b/samples/Basic/11_Documentsecurity.php
similarity index 98%
rename from samples/11_Documentsecurity.php
rename to samples/Basic/11_Documentsecurity.php
index 0298e7ee..d92c7d4e 100644
--- a/samples/11_Documentsecurity.php
+++ b/samples/Basic/11_Documentsecurity.php
@@ -2,7 +2,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/12_CellProtection.php b/samples/Basic/12_CellProtection.php
similarity index 97%
rename from samples/12_CellProtection.php
rename to samples/Basic/12_CellProtection.php
index a84bb8a5..e29aa5e4 100644
--- a/samples/12_CellProtection.php
+++ b/samples/Basic/12_CellProtection.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Protection;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/Basic/13_Calculation.php b/samples/Basic/13_Calculation.php
new file mode 100644
index 00000000..4bbc296d
--- /dev/null
+++ b/samples/Basic/13_Calculation.php
@@ -0,0 +1,176 @@
+log('List implemented functions');
+$calc = Calculation::getInstance();
+print_r($calc->getImplementedFunctionNames());
+
+// Create new Spreadsheet object
+$helper->log('Create new Spreadsheet object');
+$spreadsheet = new Spreadsheet();
+
+// Add some data, we will use some formulas here
+$helper->log('Add some data and formulas');
+$spreadsheet->getActiveSheet()->setCellValue('A14', 'Count:')
+ ->setCellValue('A15', 'Sum:')
+ ->setCellValue('A16', 'Max:')
+ ->setCellValue('A17', 'Min:')
+ ->setCellValue('A18', 'Average:')
+ ->setCellValue('A19', 'Median:')
+ ->setCellValue('A20', 'Mode:');
+
+$spreadsheet->getActiveSheet()->setCellValue('A22', 'CountA:')
+ ->setCellValue('A23', 'MaxA:')
+ ->setCellValue('A24', 'MinA:');
+
+$spreadsheet->getActiveSheet()->setCellValue('A26', 'StDev:')
+ ->setCellValue('A27', 'StDevA:')
+ ->setCellValue('A28', 'StDevP:')
+ ->setCellValue('A29', 'StDevPA:');
+
+$spreadsheet->getActiveSheet()->setCellValue('A31', 'DevSq:')
+ ->setCellValue('A32', 'Var:')
+ ->setCellValue('A33', 'VarA:')
+ ->setCellValue('A34', 'VarP:')
+ ->setCellValue('A35', 'VarPA:');
+
+$spreadsheet->getActiveSheet()->setCellValue('A37', 'Date:');
+
+$spreadsheet->getActiveSheet()->setCellValue('B1', 'Range 1')
+ ->setCellValue('B2', 2)
+ ->setCellValue('B3', 8)
+ ->setCellValue('B4', 10)
+ ->setCellValue('B5', true)
+ ->setCellValue('B6', false)
+ ->setCellValue('B7', 'Text String')
+ ->setCellValue('B9', '22')
+ ->setCellValue('B10', 4)
+ ->setCellValue('B11', 6)
+ ->setCellValue('B12', 12);
+
+$spreadsheet->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)')
+ ->setCellValue('B15', '=SUM(B2:B12)')
+ ->setCellValue('B16', '=MAX(B2:B12)')
+ ->setCellValue('B17', '=MIN(B2:B12)')
+ ->setCellValue('B18', '=AVERAGE(B2:B12)')
+ ->setCellValue('B19', '=MEDIAN(B2:B12)')
+ ->setCellValue('B20', '=MODE(B2:B12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)')
+ ->setCellValue('B23', '=MAXA(B2:B12)')
+ ->setCellValue('B24', '=MINA(B2:B12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)')
+ ->setCellValue('B27', '=STDEVA(B2:B12)')
+ ->setCellValue('B28', '=STDEVP(B2:B12)')
+ ->setCellValue('B29', '=STDEVPA(B2:B12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)')
+ ->setCellValue('B32', '=VAR(B2:B12)')
+ ->setCellValue('B33', '=VARA(B2:B12)')
+ ->setCellValue('B34', '=VARP(B2:B12)')
+ ->setCellValue('B35', '=VARPA(B2:B12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)')
+ ->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )')
+ ->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")')
+ ->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )')
+ ->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
+
+$spreadsheet->getActiveSheet()->setCellValue('C1', 'Range 2')
+ ->setCellValue('C2', 1)
+ ->setCellValue('C3', 2)
+ ->setCellValue('C4', 2)
+ ->setCellValue('C5', 3)
+ ->setCellValue('C6', 3)
+ ->setCellValue('C7', 3)
+ ->setCellValue('C8', '0')
+ ->setCellValue('C9', 4)
+ ->setCellValue('C10', 4)
+ ->setCellValue('C11', 4)
+ ->setCellValue('C12', 4);
+
+$spreadsheet->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)')
+ ->setCellValue('C15', '=SUM(C2:C12)')
+ ->setCellValue('C16', '=MAX(C2:C12)')
+ ->setCellValue('C17', '=MIN(C2:C12)')
+ ->setCellValue('C18', '=AVERAGE(C2:C12)')
+ ->setCellValue('C19', '=MEDIAN(C2:C12)')
+ ->setCellValue('C20', '=MODE(C2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)')
+ ->setCellValue('C23', '=MAXA(C2:C12)')
+ ->setCellValue('C24', '=MINA(C2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)')
+ ->setCellValue('C27', '=STDEVA(C2:C12)')
+ ->setCellValue('C28', '=STDEVP(C2:C12)')
+ ->setCellValue('C29', '=STDEVPA(C2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)')
+ ->setCellValue('C32', '=VAR(C2:C12)')
+ ->setCellValue('C33', '=VARA(C2:C12)')
+ ->setCellValue('C34', '=VARP(C2:C12)')
+ ->setCellValue('C35', '=VARPA(C2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('D1', 'Range 3')
+ ->setCellValue('D2', 2)
+ ->setCellValue('D3', 3)
+ ->setCellValue('D4', 4);
+
+$spreadsheet->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
+
+$spreadsheet->getActiveSheet()->setCellValue('E12', 'Other functions')
+ ->setCellValue('E14', '=PI()')
+ ->setCellValue('E15', '=RAND()')
+ ->setCellValue('E16', '=RANDBETWEEN(5, 10)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E17', 'Count of both ranges:')
+ ->setCellValue('F17', '=COUNT(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E18', 'Total of both ranges:')
+ ->setCellValue('F18', '=SUM(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:')
+ ->setCellValue('F19', '=MAX(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:')
+ ->setCellValue('F20', '=MIN(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E21', 'Average of both ranges:')
+ ->setCellValue('F21', '=AVERAGE(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E22', 'Median of both ranges:')
+ ->setCellValue('F22', '=MEDIAN(B2:C12)');
+
+$spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
+ ->setCellValue('F23', '=MODE(B2:C12)');
+
+// Calculated data
+$helper->log('Calculated data');
+for ($col = 'B'; $col != 'G'; ++$col) {
+ for ($row = 14; $row <= 41; ++$row) {
+ if ((!is_null($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue())) &&
+ ($formula[0] == '=')) {
+ $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
+ }
+ }
+}
+
+//
+// If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the
+// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
+// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
+// If the value is false (the default) for the Xlsx Writer, then MS Excel (or the application used to
+// open the file) will need to recalculate values itself to guarantee that the correct results are available.
+//
+//$writer->setPreCalculateFormulas(true);
+// Save
+$helper->write($spreadsheet, __FILE__);
diff --git a/samples/13_CalculationCyclicFormulae.php b/samples/Basic/13_CalculationCyclicFormulae.php
similarity index 82%
rename from samples/13_CalculationCyclicFormulae.php
rename to samples/Basic/13_CalculationCyclicFormulae.php
index 968c467c..006151bb 100644
--- a/samples/13_CalculationCyclicFormulae.php
+++ b/samples/Basic/13_CalculationCyclicFormulae.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Calculation;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
@@ -24,8 +24,7 @@ for ($row = 1; $row <= 2; ++$row) {
for ($col = 'A'; $col != 'C'; ++$col) {
if ((!is_null($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue())) &&
($formula[0] == '=')) {
- echo 'Value of ', $col, $row, ' [', $formula, ']: ',
- $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue() . EOL;
+ $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
}
}
}
diff --git a/samples/14_Xls.php b/samples/Basic/14_Xls.php
similarity index 71%
rename from samples/14_Xls.php
rename to samples/Basic/14_Xls.php
index 03a38d28..ce27eb8c 100644
--- a/samples/14_Xls.php
+++ b/samples/Basic/14_Xls.php
@@ -2,8 +2,8 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
-$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+require __DIR__ . '/../Header.php';
+$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$filename = $helper->getFilename(__FILE__, 'xls');
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
diff --git a/samples/15_Datavalidation.php b/samples/Basic/15_Datavalidation.php
similarity index 98%
rename from samples/15_Datavalidation.php
rename to samples/Basic/15_Datavalidation.php
index 416a102a..45496ffb 100644
--- a/samples/15_Datavalidation.php
+++ b/samples/Basic/15_Datavalidation.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/16_Csv.php b/samples/Basic/16_Csv.php
similarity index 90%
rename from samples/16_Csv.php
rename to samples/Basic/16_Csv.php
index 0c1db51d..23c91d19 100644
--- a/samples/16_Csv.php
+++ b/samples/Basic/16_Csv.php
@@ -2,8 +2,8 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
-$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+require __DIR__ . '/../Header.php';
+$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$helper->log('Write to CSV format');
$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
diff --git a/samples/17_Html.php b/samples/Basic/17_Html.php
similarity index 71%
rename from samples/17_Html.php
rename to samples/Basic/17_Html.php
index 9ea9f0bd..b90b7212 100644
--- a/samples/17_Html.php
+++ b/samples/Basic/17_Html.php
@@ -2,8 +2,8 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
-$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+require __DIR__ . '/../Header.php';
+$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$filename = $helper->getFilename(__FILE__, 'html');
$writer = IOFactory::createWriter($spreadsheet, 'Html');
diff --git a/samples/18_Extendedcalculation.php b/samples/Basic/18_Extendedcalculation.php
similarity index 94%
rename from samples/18_Extendedcalculation.php
rename to samples/Basic/18_Extendedcalculation.php
index e459e9d3..ad8aaaf4 100644
--- a/samples/18_Extendedcalculation.php
+++ b/samples/Basic/18_Extendedcalculation.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Calculation;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// List functions
$helper->log('List implemented functions');
@@ -64,6 +64,6 @@ $spreadsheet->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
// Calculated data
$helper->log('Calculated data');
-echo 'Value of B14 [=COUNT(B2:B12)]: ' . $spreadsheet->getActiveSheet()->getCell('B14')->getCalculatedValue() . "\r\n";
+$helper->log('Value of B14 [=COUNT(B2:B12)]: ' . $spreadsheet->getActiveSheet()->getCell('B14')->getCalculatedValue());
$helper->logEndingNotes();
diff --git a/samples/19_Namedrange.php b/samples/Basic/19_Namedrange.php
similarity index 98%
rename from samples/19_Namedrange.php
rename to samples/Basic/19_Namedrange.php
index 53c25660..ad9abc45 100644
--- a/samples/19_Namedrange.php
+++ b/samples/Basic/19_Namedrange.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\NamedRange;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/20_Read_Excel2003XML.php b/samples/Basic/20_Read_Excel2003XML.php
similarity index 70%
rename from samples/20_Read_Excel2003XML.php
rename to samples/Basic/20_Read_Excel2003XML.php
index 6e2f464d..44425e20 100644
--- a/samples/20_Read_Excel2003XML.php
+++ b/samples/Basic/20_Read_Excel2003XML.php
@@ -2,9 +2,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$filename = __DIR__ . '/templates/Excel2003XMLTest.xml';
+$filename = __DIR__ . '/../templates/Excel2003XMLTest.xml';
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
$helper->logRead('Xml', $filename, $callStartTime);
diff --git a/samples/20_Read_Gnumeric.php b/samples/Basic/20_Read_Gnumeric.php
similarity index 70%
rename from samples/20_Read_Gnumeric.php
rename to samples/Basic/20_Read_Gnumeric.php
index d2c598c4..2d6ce221 100644
--- a/samples/20_Read_Gnumeric.php
+++ b/samples/Basic/20_Read_Gnumeric.php
@@ -2,9 +2,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$filename = __DIR__ . '/templates/GnumericTest.gnumeric';
+$filename = __DIR__ . '/../templates/GnumericTest.gnumeric';
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
$helper->logRead('Gnumeric', $filename, $callStartTime);
diff --git a/samples/20_Read_Ods.php b/samples/Basic/20_Read_Ods.php
similarity index 71%
rename from samples/20_Read_Ods.php
rename to samples/Basic/20_Read_Ods.php
index 10a8275c..64f54827 100644
--- a/samples/20_Read_Ods.php
+++ b/samples/Basic/20_Read_Ods.php
@@ -2,9 +2,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$filename = __DIR__ . '/templates/OOCalcTest.ods';
+$filename = __DIR__ . '/../templates/OOCalcTest.ods';
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
$helper->logRead('Ods', $filename, $callStartTime);
diff --git a/samples/20_Read_Sylk.php b/samples/Basic/20_Read_Sylk.php
similarity index 72%
rename from samples/20_Read_Sylk.php
rename to samples/Basic/20_Read_Sylk.php
index c07c9647..1a064593 100644
--- a/samples/20_Read_Sylk.php
+++ b/samples/Basic/20_Read_Sylk.php
@@ -2,9 +2,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$filename = __DIR__ . '/templates/SylkTest.slk';
+$filename = __DIR__ . '/../templates/SylkTest.slk';
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
$helper->logRead('Slk', $filename, $callStartTime);
diff --git a/samples/20_Read_Xls.php b/samples/Basic/20_Read_Xls.php
similarity index 81%
rename from samples/20_Read_Xls.php
rename to samples/Basic/20_Read_Xls.php
index 542f96a2..9e5fa014 100644
--- a/samples/20_Read_Xls.php
+++ b/samples/Basic/20_Read_Xls.php
@@ -2,9 +2,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
// Write temporary file
$filename = $helper->getTemporaryFilename('xls');
diff --git a/samples/22_Heavily_formatted.php b/samples/Basic/22_Heavily_formatted.php
similarity index 97%
rename from samples/22_Heavily_formatted.php
rename to samples/Basic/22_Heavily_formatted.php
index feb2d957..d8259990 100644
--- a/samples/22_Heavily_formatted.php
+++ b/samples/Basic/22_Heavily_formatted.php
@@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/23_Sharedstyles.php b/samples/Basic/23_Sharedstyles.php
similarity index 98%
rename from samples/23_Sharedstyles.php
rename to samples/Basic/23_Sharedstyles.php
index 1405431c..0499e9ba 100644
--- a/samples/23_Sharedstyles.php
+++ b/samples/Basic/23_Sharedstyles.php
@@ -5,7 +5,7 @@ use PhpOffice\PhpSpreadsheet\Style;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/24_Readfilter.php b/samples/Basic/24_Readfilter.php
similarity index 90%
rename from samples/24_Readfilter.php
rename to samples/Basic/24_Readfilter.php
index f5258604..844996f2 100644
--- a/samples/24_Readfilter.php
+++ b/samples/Basic/24_Readfilter.php
@@ -5,10 +5,10 @@ namespace PhpOffice\PhpSpreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Write temporary file
-$largeSpreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php';
+$largeSpreadsheet = require __DIR__ . '/../templates/largeSpreadsheet.php';
$writer = new Xlsx($largeSpreadsheet);
$filename = $helper->getTemporaryFilename();
$callStartTime = microtime(true);
diff --git a/samples/25_In_memory_image.php b/samples/Basic/25_In_memory_image.php
similarity index 97%
rename from samples/25_In_memory_image.php
rename to samples/Basic/25_In_memory_image.php
index 5756bd3e..09b25c64 100644
--- a/samples/25_In_memory_image.php
+++ b/samples/Basic/25_In_memory_image.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/26_Utf8.php b/samples/Basic/26_Utf8.php
similarity index 93%
rename from samples/26_Utf8.php
rename to samples/Basic/26_Utf8.php
index 790640a0..02b60801 100644
--- a/samples/26_Utf8.php
+++ b/samples/Basic/26_Utf8.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Settings;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Change these values to select the PDF Rendering library that you wish to use
// and its directory location on your server
@@ -14,7 +14,7 @@ $rendererName = Settings::PDF_RENDERER_DOMPDF;
// Read from Xlsx (.xlsx) template
$helper->log('Load Xlsx template file');
$reader = IOFactory::createReader('Xlsx');
-$spreadsheet = $reader->load(__DIR__ . '/templates/26template.xlsx');
+$spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
/* at this point, we could do some manipulations with the template, but we skip this step */
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
diff --git a/samples/27_Images_Xls.php b/samples/Basic/27_Images_Xls.php
similarity index 66%
rename from samples/27_Images_Xls.php
rename to samples/Basic/27_Images_Xls.php
index 4923efe2..4c20a9ac 100644
--- a/samples/27_Images_Xls.php
+++ b/samples/Basic/27_Images_Xls.php
@@ -2,12 +2,12 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Read from Xls (.xls) template
$helper->log('Load Xlsx template file');
$reader = IOFactory::createReader('Xls');
-$spreadsheet = $reader->load(__DIR__ . '/templates/27template.xls');
+$spreadsheet = $reader->load(__DIR__ . '/../templates/27template.xls');
// Save
$helper->write($spreadsheet, __FILE__);
diff --git a/samples/28_Iterator.php b/samples/Basic/28_Iterator.php
similarity index 90%
rename from samples/28_Iterator.php
rename to samples/Basic/28_Iterator.php
index 5dbb49e4..64981c5c 100644
--- a/samples/28_Iterator.php
+++ b/samples/Basic/28_Iterator.php
@@ -3,9 +3,9 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
-$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$filename = $helper->getTemporaryFilename();
$writer = new Xlsx($sampleSpreadsheet);
$callStartTime = microtime(true);
diff --git a/samples/29_Advanced_value_binder.php b/samples/Basic/29_Advanced_value_binder.php
similarity index 99%
rename from samples/29_Advanced_value_binder.php
rename to samples/Basic/29_Advanced_value_binder.php
index 7f22c8f0..c0131cef 100644
--- a/samples/29_Advanced_value_binder.php
+++ b/samples/Basic/29_Advanced_value_binder.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Cell;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Set timezone
$helper->log('Set timezone');
diff --git a/samples/30_Template.php b/samples/Basic/30_Template.php
similarity index 91%
rename from samples/30_Template.php
rename to samples/Basic/30_Template.php
index 4c6d867b..1f8a9629 100644
--- a/samples/30_Template.php
+++ b/samples/Basic/30_Template.php
@@ -3,11 +3,11 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Shared\Date;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$helper->log('Load from Xls template');
$reader = IOFactory::createReader('Xls');
-$spreadsheet = $reader->load(__DIR__ . '/templates/30template.xls');
+$spreadsheet = $reader->load(__DIR__ . '/../templates/30template.xls');
$helper->log('Add new data to the template');
$data = [['title' => 'Excel for dummies',
diff --git a/samples/31_Document_properties_write.php b/samples/Basic/31_Document_properties_write.php
similarity index 84%
rename from samples/31_Document_properties_write.php
rename to samples/Basic/31_Document_properties_write.php
index 15936ffa..0611389f 100644
--- a/samples/31_Document_properties_write.php
+++ b/samples/Basic/31_Document_properties_write.php
@@ -3,10 +3,10 @@
use PhpOffice\PhpSpreadsheet\Document\Properties;
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$inputFileType = 'Xlsx';
-$inputFileName = __DIR__ . '/templates/31docproperties.xlsx';
+$inputFileName = __DIR__ . '/../templates/31docproperties.xlsx';
$spreadsheetReader = IOFactory::createReader($inputFileType);
$callStartTime = microtime(true);
@@ -26,7 +26,6 @@ $callStartTime = microtime(true);
$writer->save($filename);
$helper->logWrite($writer, $filename, $callStartTime);
-// Echo memory peak usage
$helper->logEndingNotes();
// Reread File
@@ -38,9 +37,9 @@ $helper->log('Get properties');
$helper->log('Core Properties:');
$helper->log(' Created by - ' . $spreadsheet->getProperties()->getCreator());
-$helper->log(' Created on - ' . date('d-M-Y', $spreadsheet->getProperties()->getCreated()) . ' at ' . date('H:i:s', $spreadsheet->getProperties()->getCreated()));
+$helper->log(' Created on - ' . date('d-M-Y' . $spreadsheet->getProperties()->getCreated()) . ' at ' . date('H:i:s' . $spreadsheet->getProperties()->getCreated()));
$helper->log(' Last Modified by - ' . $spreadsheet->getProperties()->getLastModifiedBy());
-$helper->log(' Last Modified on - ' . date('d-M-Y', $spreadsheet->getProperties()->getModified()) . ' at ' . date('H:i:s', $spreadsheet->getProperties()->getModified()));
+$helper->log(' Last Modified on - ' . date('d-M-Y' . $spreadsheet->getProperties()->getModified()) . ' at ' . date('H:i:s' . $spreadsheet->getProperties()->getModified()));
$helper->log(' Title - ' . $spreadsheet->getProperties()->getTitle());
$helper->log(' Subject - ' . $spreadsheet->getProperties()->getSubject());
$helper->log(' Description - ' . $spreadsheet->getProperties()->getDescription());
@@ -66,5 +65,4 @@ foreach ($customProperties as $customProperty) {
$helper->log(' ' . $customProperty . ' - (' . $propertyType . ') - ' . $formattedValue);
}
-// Echo memory peak usage
$helper->logEndingNotes();
diff --git a/samples/31_Document_properties_write_xls.php b/samples/Basic/31_Document_properties_write_xls.php
similarity index 84%
rename from samples/31_Document_properties_write_xls.php
rename to samples/Basic/31_Document_properties_write_xls.php
index a427be18..4f63e443 100644
--- a/samples/31_Document_properties_write_xls.php
+++ b/samples/Basic/31_Document_properties_write_xls.php
@@ -3,10 +3,10 @@
use PhpOffice\PhpSpreadsheet\Document\Properties;
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$inputFileType = 'Xls';
-$inputFileName = __DIR__ . '/templates/31docproperties.xls';
+$inputFileName = __DIR__ . '/../templates/31docproperties.xls';
$spreadsheetReader = IOFactory::createReader($inputFileType);
$callStartTime = microtime(true);
@@ -26,7 +26,6 @@ $callStartTime = microtime(true);
$writer->save($filename);
$helper->logWrite($writer, $filename, $callStartTime);
-// Echo memory peak usage
$helper->logEndingNotes();
// Reread File
@@ -38,9 +37,9 @@ $helper->log('Get properties');
$helper->log('Core Properties:');
$helper->log(' Created by - ' . $spreadsheet->getProperties()->getCreator());
-$helper->log(' Created on - ' . date('d-M-Y', $spreadsheet->getProperties()->getCreated()) . ' at ' . date('H:i:s', $spreadsheet->getProperties()->getCreated()));
+$helper->log(' Created on - ' . date('d-M-Y' . $spreadsheet->getProperties()->getCreated()) . ' at ' . date('H:i:s' . $spreadsheet->getProperties()->getCreated()));
$helper->log(' Last Modified by - ' . $spreadsheet->getProperties()->getLastModifiedBy());
-$helper->log(' Last Modified on - ' . date('d-M-Y', $spreadsheet->getProperties()->getModified()) . ' at ' . date('H:i:s', $spreadsheet->getProperties()->getModified()));
+$helper->log(' Last Modified on - ' . date('d-M-Y' . $spreadsheet->getProperties()->getModified()) . ' at ' . date('H:i:s' . $spreadsheet->getProperties()->getModified()));
$helper->log(' Title - ' . $spreadsheet->getProperties()->getTitle());
$helper->log(' Subject - ' . $spreadsheet->getProperties()->getSubject());
$helper->log(' Description - ' . $spreadsheet->getProperties()->getDescription());
@@ -66,5 +65,4 @@ foreach ($customProperties as $customProperty) {
$helper->log(' ' . $customProperty . ' - (' . $propertyType . ') - ' . $formattedValue);
}
-// Echo memory peak usage
$helper->logEndingNotes();
diff --git a/samples/37_Page_layout_view.php b/samples/Basic/37_Page_layout_view.php
similarity index 96%
rename from samples/37_Page_layout_view.php
rename to samples/Basic/37_Page_layout_view.php
index 2cdb3e12..725f004c 100644
--- a/samples/37_Page_layout_view.php
+++ b/samples/Basic/37_Page_layout_view.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\SheetView;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/38_Clone_worksheet.php b/samples/Basic/38_Clone_worksheet.php
similarity index 98%
rename from samples/38_Clone_worksheet.php
rename to samples/Basic/38_Clone_worksheet.php
index b55b9025..dde310cb 100644
--- a/samples/38_Clone_worksheet.php
+++ b/samples/Basic/38_Clone_worksheet.php
@@ -2,7 +2,7 @@
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/39_Dropdown.php b/samples/Basic/39_Dropdown.php
similarity index 96%
rename from samples/39_Dropdown.php
rename to samples/Basic/39_Dropdown.php
index bb68c3e9..79b6bbfb 100644
--- a/samples/39_Dropdown.php
+++ b/samples/Basic/39_Dropdown.php
@@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PhpOffice\PhpSpreadsheet\NamedRange;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
@@ -30,10 +30,10 @@ $continentColumn = 'D';
$column = 'F';
// Set data for dropdowns
-$continents = glob('./data/continents/*');
+$continents = glob(__DIR__ . '/data/continents/*');
foreach ($continents as $key => $filename) {
$continent = pathinfo($filename, PATHINFO_FILENAME);
- echo "Loading $continent", EOL;
+ $helper->log("Loading $continent");
$continent = str_replace(' ', '_', $continent);
$countries = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$countryCount = count($countries);
diff --git a/samples/40_Duplicate_style.php b/samples/Basic/40_Duplicate_style.php
similarity index 89%
rename from samples/40_Duplicate_style.php
rename to samples/Basic/40_Duplicate_style.php
index 4a006f90..9d167641 100644
--- a/samples/40_Duplicate_style.php
+++ b/samples/Basic/40_Duplicate_style.php
@@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\Cell;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$helper->log('Create new Spreadsheet object');
$spreadsheet = new Spreadsheet();
@@ -30,7 +30,7 @@ for ($col = 0; $col < 50; ++$col) {
}
}
$d = microtime(true) - $t;
-$helper->log('Add data (end), time: ' . round($d, 2) . ' s');
+$helper->log('Add data (end) . time: ' . round($d . 2) . ' s');
// Save
$helper->write($spreadsheet, __FILE__);
diff --git a/samples/41_Password.php b/samples/Basic/41_Password.php
similarity index 71%
rename from samples/41_Password.php
rename to samples/Basic/41_Password.php
index 6844b8e4..9aa8e6db 100644
--- a/samples/41_Password.php
+++ b/samples/Basic/41_Password.php
@@ -1,7 +1,7 @@
getSecurity()->setLockWindows(true);
diff --git a/samples/42_RichText.php b/samples/Basic/42_RichText.php
similarity index 98%
rename from samples/42_RichText.php
rename to samples/Basic/42_RichText.php
index 88db805c..722b0326 100644
--- a/samples/42_RichText.php
+++ b/samples/Basic/42_RichText.php
@@ -3,7 +3,7 @@
use PhpOffice\PhpSpreadsheet\Helper\Html as HtmlHelper;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create new Spreadsheet object
$helper->log('Create new Spreadsheet object');
diff --git a/samples/43_Merge_workbooks.php b/samples/Basic/43_Merge_workbooks.php
similarity index 81%
rename from samples/43_Merge_workbooks.php
rename to samples/Basic/43_Merge_workbooks.php
index 57721a4a..86314b3b 100644
--- a/samples/43_Merge_workbooks.php
+++ b/samples/Basic/43_Merge_workbooks.php
@@ -2,16 +2,16 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
$helper->log('Load MergeBook1 from Xlsx file');
-$filename1 = __DIR__ . '/templates/43mergeBook1.xlsx';
+$filename1 = __DIR__ . '/../templates/43mergeBook1.xlsx';
$callStartTime = microtime(true);
$spreadsheet1 = IOFactory::load($filename1);
$helper->logRead('Xlsx', $filename1, $callStartTime);
$helper->log('Load MergeBook2 from Xlsx file');
-$filename2 = __DIR__ . '/templates/43mergeBook2.xlsx';
+$filename2 = __DIR__ . '/../templates/43mergeBook2.xlsx';
$callStartTime = microtime(true);
$spreadsheet2 = IOFactory::load($filename2);
$helper->logRead('Xlsx', $filename2, $callStartTime);
diff --git a/samples/44_Worksheet_info.php b/samples/Basic/44_Worksheet_info.php
similarity index 84%
rename from samples/44_Worksheet_info.php
rename to samples/Basic/44_Worksheet_info.php
index cacb9ae6..33c0cd05 100644
--- a/samples/44_Worksheet_info.php
+++ b/samples/Basic/44_Worksheet_info.php
@@ -3,10 +3,10 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
-require __DIR__ . '/Header.php';
+require __DIR__ . '/../Header.php';
// Create temporary file that will be read
-$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
+$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
$filename = $helper->getTemporaryFilename();
$writer = new Xlsx($sampleSpreadsheet);
$writer->save($filename);
diff --git a/samples/45_Quadratic_equation_solver.php b/samples/Basic/45_Quadratic_equation_solver.php
similarity index 84%
rename from samples/45_Quadratic_equation_solver.php
rename to samples/Basic/45_Quadratic_equation_solver.php
index 39f6685d..11edb856 100644
--- a/samples/45_Quadratic_equation_solver.php
+++ b/samples/Basic/45_Quadratic_equation_solver.php
@@ -1,7 +1,7 @@
Requirement check:';
+ echo 'Requirement check
';
echo '';
foreach ($requirements as $label => $result) {
$status = $result ? 'passed' : 'failed';
diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php
index c538fe95..1200db76 100644
--- a/src/PhpSpreadsheet/Helper/Sample.php
+++ b/src/PhpSpreadsheet/Helper/Sample.php
@@ -5,7 +5,11 @@ namespace PhpOffice\PhpSpreadsheet\Helper;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+use RecursiveRegexIterator;
use ReflectionClass;
+use RegexIterator;
/**
* Helper class to be used in sample code.
@@ -70,15 +74,31 @@ class Sample
public function getSamples()
{
// Populate samples
+ $baseDir = realpath(__DIR__ . '/../../../samples');
+ $directory = new RecursiveDirectoryIterator($baseDir);
+ $iterator = new RecursiveIteratorIterator($directory);
+ $regex = new RegexIterator($iterator, '/^.+\.php$/', RecursiveRegexIterator::GET_MATCH);
+
$files = [];
- foreach (glob(realpath(__DIR__ . '/../../../samples') . '/*.php') as $file) {
+ foreach ($regex as $file) {
+ $file = str_replace($baseDir . '/', '', $file[0]);
$info = pathinfo($file);
+ $category = str_replace('_', ' ', $info['dirname']);
$name = str_replace('_', ' ', preg_replace('/(|\.php)/', '', $info['filename']));
- if (preg_match('/^\d+/', $name)) {
- $files[$name] = $file;
+ if (!in_array($category, ['.', 'boostrap', 'templates'])) {
+ if (!isset($files[$category])) {
+ $files[$category] = [];
+ }
+ $files[$category][$name] = $file;
}
}
+ // Sort everything
+ ksort($files);
+ foreach ($files as &$f) {
+ asort($f);
+ }
+
return $files;
}
@@ -151,7 +171,8 @@ class Sample
public function log($message)
{
- echo date('H:i:s '), $message, EOL;
+ $eol = $this->isCli() ? PHP_EOL : '
';
+ echo date('H:i:s ') . $message . $eol;
}
/**
diff --git a/tests/PhpSpreadsheetTests/SampleTest.php b/tests/PhpSpreadsheetTests/SampleTest.php
index ecbedfbd..92d4ead9 100644
--- a/tests/PhpSpreadsheetTests/SampleTest.php
+++ b/tests/PhpSpreadsheetTests/SampleTest.php
@@ -39,13 +39,16 @@ class SampleTest extends PHPUnit_Framework_TestCase
}
$helper = new Sample();
- $samples = [];
- foreach ($helper->getSamples() as $name => $sample) {
- if (!in_array($name, $skipped)) {
- $samples[$name] = [$sample];
+ $result = [];
+ foreach ($helper->getSamples() as $samples) {
+ foreach ($samples as $name => $sample) {
+ if (!in_array($name, $skipped) && preg_match('~21_Pdf_mPDF~', $sample)) {
+ $file = '../samples/' . $sample;
+ $result[] = [$file];
+ }
}
}
- return $samples;
+ return $result;
}
}