From 5df66809bcfbea35fcda1513c577470da1b4dbc9 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Fri, 5 May 2017 11:56:18 +0200 Subject: [PATCH 01/31] Workaround for RTD search For details, see https://github.com/rtfd/readthedocs.org/issues/1487 FIX #153 --- docs/extra/extra.css | 8 +++ docs/extra/extra.js | 57 +++++++++++++++++++++ docs/references/features-cross-reference.md | 2 +- mkdocs.yml | 11 ++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 docs/extra/extra.css create mode 100644 docs/extra/extra.js create mode 100644 mkdocs.yml diff --git a/docs/extra/extra.css b/docs/extra/extra.css new file mode 100644 index 00000000..2addeb79 --- /dev/null +++ b/docs/extra/extra.css @@ -0,0 +1,8 @@ +/* Make the huge table always visible */ +table.features-cross-reference { + overflow: visible !important; +} +.rst-content table.features-cross-reference.docutils th, +.rst-content table.features-cross-reference.docutils td { + background-color: white; +} diff --git a/docs/extra/extra.js b/docs/extra/extra.js new file mode 100644 index 00000000..fdef958f --- /dev/null +++ b/docs/extra/extra.js @@ -0,0 +1,57 @@ +var nodemcu = nodemcu || {}; +(function () { + 'use strict'; + + $(document).ready(function () { + fixSearch(); + }); + + /* + * RTD messes up MkDocs' search feature by tinkering with the search box defined in the theme, see + * https://github.com/rtfd/readthedocs.org/issues/1088. This function sets up a DOM4 MutationObserver + * to react to changes to the search form (triggered by RTD on doc ready). It then reverts everything + * the RTD JS code modified. + */ + function fixSearch() { + var target = document.getElementById('rtd-search-form'); + var config = {attributes: true, childList: true}; + + var observer = new MutationObserver(function (mutations) { + // if it isn't disconnected it'll loop infinitely because the observed element is modified + observer.disconnect(); + var form = $('#rtd-search-form'); + form.empty(); + form.attr('action', 'https://' + window.location.hostname + '/en/' + determineSelectedBranch() + '/search.html'); + $('').attr({ + type: "text", + name: "q", + placeholder: "Search docs" + }).appendTo(form); + }); + + if (window.location.origin.indexOf('readthedocs') > -1) { + observer.observe(target, config); + } + } + + /** + * Analyzes the URL of the current page to find out what the selected GitHub branch is. It's usually + * part of the location path. The code needs to distinguish between running MkDocs standalone + * and docs served from RTD. If no valid branch could be determined 'dev' returned. + * + * @returns GitHub branch name + */ + function determineSelectedBranch() { + var branch = 'dev', path = window.location.pathname; + if (window.location.origin.indexOf('readthedocs') > -1) { + // path is like /en///build/ -> extract 'lang' + // split[0] is an '' because the path starts with the separator + var thirdPathSegment = path.split('/')[2]; + // 'latest' is an alias on RTD for the 'dev' branch - which is the default for 'branch' here + if (thirdPathSegment !== 'latest') { + branch = thirdPathSegment; + } + } + return branch; + } +}()); \ No newline at end of file diff --git a/docs/references/features-cross-reference.md b/docs/references/features-cross-reference.md index cdca7001..a1b1e012 100644 --- a/docs/references/features-cross-reference.md +++ b/docs/references/features-cross-reference.md @@ -5,7 +5,7 @@ - Not supported - N/A Cannot be supported - +
diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..00620004 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,11 @@ +site_name: PhpSpreadsheet Documentation +repo_url: https://github.com/PHPOffice/phpspreadsheet +edit_uri: edit/develop/docs/ + +theme: readthedocs +extra_css: + - extra/extra.css + +extra_javascript: + - extra/extra.js + \ No newline at end of file From 4c42afe7b80e34b33acea381af3f3263410d586b Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 7 May 2017 16:54:41 +0200 Subject: [PATCH 02/31] Add issue and PR template To reduce issue volume on GitHub all support question should be redirected to StackOverflow or Gitter. --- .github/ISSUE_TEMPLATE.md | 29 +++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 14 ++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..2557290f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,29 @@ +This is: + +- [ ] a bug report +- [ ] a feature request +- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet) + +### What is the expected behavior? + + +### What is the current behavior? + + +### What are the steps to reproduce? + +Please provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) of code that exhibits the issue without relying on an external Excel file or a web server: + +```php + Date: Thu, 20 Apr 2017 22:42:04 +0200 Subject: [PATCH 03/31] Ods writer repects PreCalculateFormulas flag The OpenDocument Writer did not respect the "preCalculateFormulas" flag that can be set to speed up saving process, now it does. Closes #142 --- src/PhpSpreadsheet/Writer/Ods/Content.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index b8597028..bd5db3e3 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -224,10 +224,13 @@ class Content extends WriterPart throw new Exception('Writing of error not implemented yet.'); break; case DataType::TYPE_FORMULA: - try { - $formulaValue = $cell->getCalculatedValue(); - } catch (\Exception $e) { - $formulaValue = $cell->getValue(); + $formulaValue = $cell->getValue(); + if ($this->getParentWriter()->getPreCalculateFormulas()) { + try { + $formulaValue = $cell->getCalculatedValue(); + } catch (Exception $e) { + // don't do anything + } } $objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue()); if (is_numeric($formulaValue)) { From 07455d24f644ea1ebd8efafbc8bcc711d0cbf6b3 Mon Sep 17 00:00:00 2001 From: Zharikov Viktor Date: Thu, 18 May 2017 00:02:17 +0200 Subject: [PATCH 04/31] Make global usage of `use` instead of FQCN Closes #78 Closes #147 --- bin/migrate-from-phpexcel | 4 +- .../Calculations/Database/DAVERAGE.php | 4 +- .../Examples/Calculations/Database/DCOUNT.php | 4 +- docs/Examples/Calculations/Database/DGET.php | 4 +- docs/Examples/Calculations/Database/DMAX.php | 4 +- docs/Examples/Calculations/Database/DMIN.php | 4 +- .../Calculations/Database/DPRODUCT.php | 4 +- .../Examples/Calculations/Database/DSTDEV.php | 4 +- .../Calculations/Database/DSTDEVP.php | 4 +- docs/Examples/Calculations/Database/DVAR.php | 4 +- docs/Examples/Calculations/Database/DVARP.php | 4 +- docs/Examples/Calculations/DateTime/DATE.php | 4 +- .../Calculations/DateTime/DATEVALUE.php | 4 +- docs/Examples/Calculations/DateTime/TIME.php | 4 +- .../Calculations/DateTime/TIMEVALUE.php | 4 +- docs/Examples/Reader/exampleReader01.php | 6 +- docs/Examples/Reader/exampleReader02.php | 4 +- docs/Examples/Reader/exampleReader03.php | 6 +- docs/Examples/Reader/exampleReader04.php | 8 +- docs/Examples/Reader/exampleReader05.php | 4 +- docs/Examples/Reader/exampleReader06.php | 4 +- docs/Examples/Reader/exampleReader07.php | 4 +- docs/Examples/Reader/exampleReader08.php | 4 +- docs/Examples/Reader/exampleReader09.php | 7 +- docs/Examples/Reader/exampleReader10.php | 7 +- docs/Examples/Reader/exampleReader11.php | 9 +- docs/Examples/Reader/exampleReader12.php | 9 +- docs/Examples/Reader/exampleReader13.php | 4 +- docs/Examples/Reader/exampleReader14.php | 12 +- docs/Examples/Reader/exampleReader15.php | 7 +- docs/Examples/Reader/exampleReader16.php | 7 +- docs/Examples/Reader/exampleReader17.php | 4 +- docs/Examples/Reader/exampleReader18.php | 4 +- docs/Examples/Reader/exampleReader19.php | 4 +- .../exampleWorkBookReader01.php | 4 +- .../exampleWorkBookReader02.php | 4 +- .../exampleWorkBookReader03.php | 4 +- .../exampleWorkBookReader04.php | 4 +- samples/01_Simple.php | 6 +- samples/01_Simple_download_ods.php | 10 +- samples/01_Simple_download_pdf.php | 15 +- samples/01_Simple_download_xls.php | 10 +- samples/01_Simple_download_xlsx.php | 10 +- samples/02_Types.php | 28 +- samples/03_Formulas.php | 4 +- samples/04_Printing.php | 15 +- samples/07_Reader.php | 7 +- samples/08_Conditional_formatting.php | 42 +- samples/08_Conditional_formatting_2.php | 25 +- samples/09_Pagebreaks.php | 7 +- samples/10_Autofilter.php | 4 +- samples/10_Autofilter_selection_1.php | 34 +- samples/10_Autofilter_selection_2.php | 38 +- samples/10_Autofilter_selection_display.php | 34 +- samples/11_Documentsecurity.php | 4 +- samples/12_CellProtection.php | 7 +- samples/13_Calculation.php | 7 +- samples/13_CalculationCyclicFormulae.php | 7 +- samples/14_Xls.php | 4 +- samples/15_Datavalidation.php | 17 +- samples/16_Csv.php | 8 +- samples/17_Html.php | 4 +- samples/18_Extendedcalculation.php | 6 +- samples/19_Namedrange.php | 9 +- samples/20_Read_Excel2003XML.php | 4 +- samples/20_Read_Gnumeric.php | 4 +- samples/20_Read_Ods.php | 4 +- samples/20_Read_Sylk.php | 4 +- samples/20_Read_Xls.php | 6 +- samples/21_Pdf_Domdf.php | 9 +- samples/21_Pdf_TCPDF.php | 9 +- samples/21_Pdf_mPDF.php | 9 +- samples/22_Heavily_formatted.php | 14 +- samples/23_Sharedstyles.php | 23 +- samples/24_Readfilter.php | 9 +- samples/25_In_memory_image.php | 11 +- samples/26_Utf8.php | 11 +- samples/27_Images_Xls.php | 4 +- samples/28_Iterator.php | 7 +- samples/29_Advanced_value_binder.php | 6 +- samples/30_Template.php | 7 +- samples/31_Document_properties_write.php | 13 +- samples/31_Document_properties_write_xls.php | 13 +- samples/32_Chart_read_write.php | 6 +- samples/32_Chart_read_write_HTML.php | 11 +- samples/32_Chart_read_write_PDF.php | 15 +- samples/33_Chart_create_area.php | 42 +- samples/33_Chart_create_bar.php | 3 +- samples/33_Chart_create_bar_stacked.php | 44 +- samples/33_Chart_create_column.php | 44 +- samples/33_Chart_create_column_2.php | 46 +- samples/33_Chart_create_composite.php | 54 +- samples/33_Chart_create_line.php | 42 +- samples/33_Chart_create_multiple_charts.php | 74 +-- samples/33_Chart_create_pie.php | 50 +- samples/33_Chart_create_radar.php | 40 +- samples/33_Chart_create_scatter.php | 42 +- samples/33_Chart_create_stock.php | 49 +- samples/34_Chart_update.php | 8 +- samples/35_Chart_render.php | 9 +- samples/37_Page_layout_view.php | 7 +- samples/38_Clone_worksheet.php | 4 +- samples/39_Dropdown.php | 18 +- samples/40_Duplicate_style.php | 10 +- samples/42_RichText.php | 7 +- samples/43_Merge_workbooks.php | 6 +- samples/44_Worksheet_info.php | 9 +- samples/45_Quadratic_equation_solver.php | 8 +- samples/Header.php | 4 +- samples/templates/chartSpreadsheet.php | 42 +- samples/templates/largeSpreadsheet.php | 4 +- samples/templates/sampleSpreadsheet.php | 87 ++-- src/Bootstrap.php | 1 + src/PhpSpreadsheet/Calculation.php | 4 +- src/PhpSpreadsheet/Calculation/Database.php | 6 +- src/PhpSpreadsheet/Calculation/DateTime.php | 87 ++-- src/PhpSpreadsheet/Calculation/Exception.php | 4 +- .../Calculation/ExceptionHandler.php | 4 +- src/PhpSpreadsheet/Calculation/Financial.php | 8 +- src/PhpSpreadsheet/Calculation/Functions.php | 6 +- src/PhpSpreadsheet/Calculation/Logical.php | 14 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 51 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 26 +- .../Calculation/Statistical.php | 41 +- src/PhpSpreadsheet/Calculation/TextData.php | 55 +- .../Calculation/Token/Stack.php | 4 +- .../Cell/AdvancedValueBinder.php | 41 +- src/PhpSpreadsheet/Cell/DataType.php | 7 +- .../Cell/DefaultValueBinder.php | 17 +- src/PhpSpreadsheet/Cell/IValueBinder.php | 6 +- src/PhpSpreadsheet/Chart/DataSeries.php | 4 +- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 23 +- src/PhpSpreadsheet/Chart/Exception.php | 4 +- src/PhpSpreadsheet/Chart/PlotArea.php | 4 +- src/PhpSpreadsheet/Chart/Renderer/JpGraph.php | 43 +- src/PhpSpreadsheet/Collection/Cells.php | 17 +- src/PhpSpreadsheet/Collection/Memory.php | 4 +- src/PhpSpreadsheet/Document/Security.php | 6 +- src/PhpSpreadsheet/Helper/Html.php | 9 +- src/PhpSpreadsheet/Helper/Sample.php | 10 +- src/PhpSpreadsheet/Reader/Csv.php | 10 +- src/PhpSpreadsheet/Reader/Exception.php | 4 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 160 +++--- src/PhpSpreadsheet/Reader/Html.php | 21 +- src/PhpSpreadsheet/Reader/IReader.php | 2 +- src/PhpSpreadsheet/Reader/Ods.php | 85 ++-- src/PhpSpreadsheet/Reader/Slk.php | 56 ++- src/PhpSpreadsheet/Reader/Xls.php | 324 ++++++------ src/PhpSpreadsheet/Reader/Xls/Color.php | 4 +- src/PhpSpreadsheet/Reader/Xls/Escher.php | 122 ++--- src/PhpSpreadsheet/Reader/Xlsx.php | 7 +- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 58 ++- src/PhpSpreadsheet/Reader/Xml.php | 104 ++-- src/PhpSpreadsheet/ReferenceHelper.php | 2 +- src/PhpSpreadsheet/RichText/Run.php | 15 +- src/PhpSpreadsheet/Shared/CodePage.php | 10 +- src/PhpSpreadsheet/Shared/Date.php | 97 ++-- src/PhpSpreadsheet/Shared/Drawing.php | 12 +- .../DgContainer/SpgrContainer/SpContainer.php | 10 +- src/PhpSpreadsheet/Shared/File.php | 7 +- src/PhpSpreadsheet/Shared/Font.php | 19 +- .../Shared/JAMA/CholeskyDecomposition.php | 6 +- .../Shared/JAMA/LUDecomposition.php | 14 +- src/PhpSpreadsheet/Shared/JAMA/Matrix.php | 154 +++--- .../Shared/JAMA/QRDecomposition.php | 8 +- src/PhpSpreadsheet/Shared/OLE.php | 13 +- src/PhpSpreadsheet/Shared/OLE/PPS.php | 5 +- src/PhpSpreadsheet/Shared/OLE/PPS/File.php | 6 +- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 45 +- src/PhpSpreadsheet/Shared/OLERead.php | 10 +- src/PhpSpreadsheet/Shared/StringHelper.php | 10 +- src/PhpSpreadsheet/Shared/TimeZone.php | 11 +- .../Shared/Trend/PolynomialBestFit.php | 2 + src/PhpSpreadsheet/Shared/Xls.php | 57 ++- src/PhpSpreadsheet/Style.php | 4 +- src/PhpSpreadsheet/Style/Alignment.php | 14 +- src/PhpSpreadsheet/Style/Border.php | 15 +- src/PhpSpreadsheet/Style/Borders.php | 36 +- src/PhpSpreadsheet/Style/Color.php | 10 +- src/PhpSpreadsheet/Style/Conditional.php | 14 +- src/PhpSpreadsheet/Style/Fill.php | 16 +- src/PhpSpreadsheet/Style/Font.php | 12 +- src/PhpSpreadsheet/Style/NumberFormat.php | 25 +- src/PhpSpreadsheet/Style/Protection.php | 10 +- src/PhpSpreadsheet/Style/Supervisor.php | 2 +- src/PhpSpreadsheet/Worksheet.php | 2 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 98 ++-- .../Worksheet/AutoFilter/Column.php | 29 +- .../Worksheet/AutoFilter/Column/Rule.php | 31 +- src/PhpSpreadsheet/Worksheet/BaseDrawing.php | 16 +- src/PhpSpreadsheet/Worksheet/CellIterator.php | 8 +- src/PhpSpreadsheet/Worksheet/Column.php | 6 +- .../Worksheet/ColumnCellIterator.php | 30 +- .../Worksheet/ColumnIterator.php | 36 +- src/PhpSpreadsheet/Worksheet/Dimension.php | 9 +- src/PhpSpreadsheet/Worksheet/Drawing.php | 9 +- .../Worksheet/Drawing/Shadow.php | 18 +- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 8 +- .../Worksheet/HeaderFooterDrawing.php | 9 +- src/PhpSpreadsheet/Worksheet/Iterator.php | 8 +- .../Worksheet/MemoryDrawing.php | 4 +- src/PhpSpreadsheet/Worksheet/PageSetup.php | 38 +- src/PhpSpreadsheet/Worksheet/Protection.php | 4 +- src/PhpSpreadsheet/Worksheet/Row.php | 6 +- .../Worksheet/RowCellIterator.php | 64 +-- src/PhpSpreadsheet/Worksheet/RowIterator.php | 21 +- src/PhpSpreadsheet/Worksheet/SheetView.php | 16 +- src/PhpSpreadsheet/Writer/Csv.php | 19 +- src/PhpSpreadsheet/Writer/Exception.php | 4 +- src/PhpSpreadsheet/Writer/Html.php | 238 ++++----- src/PhpSpreadsheet/Writer/Ods.php | 51 +- .../Writer/Ods/Cell/Comment.php | 6 +- src/PhpSpreadsheet/Writer/Ods/Meta.php | 11 +- src/PhpSpreadsheet/Writer/Ods/MetaInf.php | 11 +- src/PhpSpreadsheet/Writer/Ods/Mimetype.php | 6 +- src/PhpSpreadsheet/Writer/Ods/Settings.php | 11 +- src/PhpSpreadsheet/Writer/Ods/Styles.php | 11 +- src/PhpSpreadsheet/Writer/Ods/Thumbnails.php | 6 +- src/PhpSpreadsheet/Writer/Ods/WriterPart.php | 10 +- src/PhpSpreadsheet/Writer/Pdf.php | 5 +- src/PhpSpreadsheet/Writer/Pdf/Core.php | 167 ++++--- src/PhpSpreadsheet/Writer/Pdf/DomPDF.php | 13 +- src/PhpSpreadsheet/Writer/Pdf/MPDF.php | 16 +- src/PhpSpreadsheet/Writer/Pdf/TcPDF.php | 11 +- src/PhpSpreadsheet/Writer/Xls.php | 118 +++-- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Escher.php | 35 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 41 +- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 78 +-- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 470 +++++++++--------- src/PhpSpreadsheet/Writer/Xls/Xf.php | 123 ++--- src/PhpSpreadsheet/Writer/Xlsx.php | 136 ++--- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 81 +-- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 28 +- .../Writer/Xlsx/ContentTypes.php | 40 +- src/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 27 +- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 61 ++- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 53 +- src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 11 +- src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 11 +- .../Writer/Xlsx/StringTable.php | 58 ++- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 154 +++--- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 16 +- src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 138 ++--- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 306 ++++++------ src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 10 +- .../Calculation/DateTimeTest.php | 3 +- .../Calculation/EngineeringTest.php | 8 +- .../Calculation/FinancialTest.php | 3 +- .../Calculation/FunctionsTest.php | 3 +- .../Calculation/LogicalTest.php | 3 +- .../Calculation/LookupRefTest.php | 3 +- .../Calculation/MathTrigTest.php | 3 +- .../Calculation/TextDataTest.php | 3 +- tests/PhpSpreadsheetTests/CalculationTest.php | 3 +- .../Cell/AdvancedValueBinderTest.php | 3 +- .../PhpSpreadsheetTests/Cell/DataTypeTest.php | 3 +- .../Cell/DefaultValueBinderTest.php | 6 +- .../Cell/HyperlinkTest.php | 3 +- tests/PhpSpreadsheetTests/CellTest.php | 3 +- .../Chart/DataSeriesValuesTest.php | 3 +- .../PhpSpreadsheetTests/Chart/LayoutTest.php | 3 +- .../PhpSpreadsheetTests/Chart/LegendTest.php | 3 +- .../Collection/CellsTest.php | 3 +- .../Helper/MigratorTest.php | 3 +- tests/PhpSpreadsheetTests/IOFactoryTest.php | 3 +- tests/PhpSpreadsheetTests/Reader/CsvTest.php | 11 +- tests/PhpSpreadsheetTests/Reader/HTMLTest.php | 3 +- tests/PhpSpreadsheetTests/Reader/OdsTest.php | 16 +- .../Reader/XEEValidatorTest.php | 3 +- .../ReferenceHelperTest.php | 3 +- tests/PhpSpreadsheetTests/SampleTest.php | 7 +- tests/PhpSpreadsheetTests/SettingsTest.php | 11 +- .../Shared/CodePageTest.php | 3 +- tests/PhpSpreadsheetTests/Shared/DateTest.php | 3 +- tests/PhpSpreadsheetTests/Shared/FileTest.php | 3 +- tests/PhpSpreadsheetTests/Shared/FontTest.php | 3 +- .../Shared/PasswordHasherTest.php | 3 +- .../PhpSpreadsheetTests/Shared/StringTest.php | 3 +- .../Shared/TimeZoneTest.php | 3 +- tests/PhpSpreadsheetTests/Style/ColorTest.php | 3 +- .../Style/NumberFormatDateTest.php | 3 +- .../Style/NumberFormatTest.php | 3 +- .../Worksheet/AutoFilter/Column/RuleTest.php | 3 +- .../Worksheet/AutoFilter/ColumnTest.php | 3 +- .../Worksheet/AutoFilterTest.php | 3 +- .../Worksheet/ColumnCellIteratorTest.php | 3 +- .../Worksheet/ColumnIteratorTest.php | 3 +- .../Worksheet/RowCellIteratorTest.php | 3 +- .../Worksheet/RowIteratorTest.php | 3 +- .../Worksheet/WorksheetColumnTest.php | 3 +- .../Worksheet/WorksheetRowTest.php | 3 +- .../Writer/Ods/ContentTest.php | 3 +- 294 files changed, 3915 insertions(+), 2974 deletions(-) diff --git a/bin/migrate-from-phpexcel b/bin/migrate-from-phpexcel index 416c3a42..51c60d49 100755 --- a/bin/migrate-from-phpexcel +++ b/bin/migrate-from-phpexcel @@ -1,6 +1,8 @@ #!/usr/bin/env php migrate(); diff --git a/docs/Examples/Calculations/Database/DAVERAGE.php b/docs/Examples/Calculations/Database/DAVERAGE.php index b54a7d1d..c2d31a6a 100644 --- a/docs/Examples/Calculations/Database/DAVERAGE.php +++ b/docs/Examples/Calculations/Database/DAVERAGE.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DCOUNT.php b/docs/Examples/Calculations/Database/DCOUNT.php index 2cd0661d..d7bf2045 100644 --- a/docs/Examples/Calculations/Database/DCOUNT.php +++ b/docs/Examples/Calculations/Database/DCOUNT.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DGET.php b/docs/Examples/Calculations/Database/DGET.php index d64b1d6e..819120cb 100644 --- a/docs/Examples/Calculations/Database/DGET.php +++ b/docs/Examples/Calculations/Database/DGET.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DMAX.php b/docs/Examples/Calculations/Database/DMAX.php index 58d2f039..4fe13da6 100644 --- a/docs/Examples/Calculations/Database/DMAX.php +++ b/docs/Examples/Calculations/Database/DMAX.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DMIN.php b/docs/Examples/Calculations/Database/DMIN.php index e4fb7658..b765c061 100644 --- a/docs/Examples/Calculations/Database/DMIN.php +++ b/docs/Examples/Calculations/Database/DMIN.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DPRODUCT.php b/docs/Examples/Calculations/Database/DPRODUCT.php index 382227df..4cf234d3 100644 --- a/docs/Examples/Calculations/Database/DPRODUCT.php +++ b/docs/Examples/Calculations/Database/DPRODUCT.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DSTDEV.php b/docs/Examples/Calculations/Database/DSTDEV.php index e1273e5a..8aeaf2d8 100644 --- a/docs/Examples/Calculations/Database/DSTDEV.php +++ b/docs/Examples/Calculations/Database/DSTDEV.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DSTDEVP.php b/docs/Examples/Calculations/Database/DSTDEVP.php index 3af791bb..0a562c65 100644 --- a/docs/Examples/Calculations/Database/DSTDEVP.php +++ b/docs/Examples/Calculations/Database/DSTDEVP.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DVAR.php b/docs/Examples/Calculations/Database/DVAR.php index 44e63994..b49020bf 100644 --- a/docs/Examples/Calculations/Database/DVAR.php +++ b/docs/Examples/Calculations/Database/DVAR.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/Database/DVARP.php b/docs/Examples/Calculations/Database/DVARP.php index c630e731..83d06fba 100644 --- a/docs/Examples/Calculations/Database/DVARP.php +++ b/docs/Examples/Calculations/Database/DVARP.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/DateTime/DATE.php b/docs/Examples/Calculations/DateTime/DATE.php index 1af05e3e..5b0a8717 100644 --- a/docs/Examples/Calculations/DateTime/DATE.php +++ b/docs/Examples/Calculations/DateTime/DATE.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/DateTime/DATEVALUE.php b/docs/Examples/Calculations/DateTime/DATEVALUE.php index 42996a4e..437b6aa8 100644 --- a/docs/Examples/Calculations/DateTime/DATEVALUE.php +++ b/docs/Examples/Calculations/DateTime/DATEVALUE.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/DateTime/TIME.php b/docs/Examples/Calculations/DateTime/TIME.php index 9c206304..588eadf9 100644 --- a/docs/Examples/Calculations/DateTime/TIME.php +++ b/docs/Examples/Calculations/DateTime/TIME.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Calculations/DateTime/TIMEVALUE.php b/docs/Examples/Calculations/DateTime/TIMEVALUE.php index c5745cc2..26996b61 100644 --- a/docs/Examples/Calculations/DateTime/TIMEVALUE.php +++ b/docs/Examples/Calculations/DateTime/TIMEVALUE.php @@ -1,5 +1,7 @@ getActiveSheet(); // Add some data diff --git a/docs/Examples/Reader/exampleReader01.php b/docs/Examples/Reader/exampleReader01.php index 9ef1f565..d20207a2 100644 --- a/docs/Examples/Reader/exampleReader01.php +++ b/docs/Examples/Reader/exampleReader01.php @@ -1,5 +1,7 @@

PhpSpreadsheet Reader Example #01

-

Simple File Reader using \PhpOffice\PhpSpreadsheet\IOFactory::load()

+

Simple File Reader using IOFactory::load()

'; -$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); +$spreadsheet = IOFactory::load($inputFileName); echo '
'; diff --git a/docs/Examples/Reader/exampleReader02.php b/docs/Examples/Reader/exampleReader02.php index b98b860d..9d301f69 100644 --- a/docs/Examples/Reader/exampleReader02.php +++ b/docs/Examples/Reader/exampleReader02.php @@ -1,5 +1,7 @@ '; -$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls(); +$reader = new Xls(); // $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); // $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml(); // $reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods(); diff --git a/docs/Examples/Reader/exampleReader03.php b/docs/Examples/Reader/exampleReader03.php index dbd584b4..07dfa7ae 100644 --- a/docs/Examples/Reader/exampleReader03.php +++ b/docs/Examples/Reader/exampleReader03.php @@ -1,5 +1,7 @@

PhpSpreadsheet Reader Example #03

-

Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Return a Reader

+

Simple File Reader using the IOFactory to Return a Reader

'; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); $spreadsheet = $reader->load($inputFileName); echo '
'; diff --git a/docs/Examples/Reader/exampleReader04.php b/docs/Examples/Reader/exampleReader04.php index 2267a9df..d26d6525 100644 --- a/docs/Examples/Reader/exampleReader04.php +++ b/docs/Examples/Reader/exampleReader04.php @@ -1,5 +1,7 @@

PhpSpreadsheet Reader Example #04

-

Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Identify a Reader to Use

+

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 = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); $spreadsheet = $reader->load($inputFileName); echo '
'; diff --git a/docs/Examples/Reader/exampleReader05.php b/docs/Examples/Reader/exampleReader05.php index 807e910d..ff72be92 100644 --- a/docs/Examples/Reader/exampleReader05.php +++ b/docs/Examples/Reader/exampleReader05.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Turning Formatting off for Load
'; $reader->setReadDataOnly(true); $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader06.php b/docs/Examples/Reader/exampleReader06.php index 84675c17..ccc59373 100644 --- a/docs/Examples/Reader/exampleReader06.php +++ b/docs/Examples/Reader/exampleReader06.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Loading all WorkSheets
'; $reader->setLoadAllSheets(); $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader07.php b/docs/Examples/Reader/exampleReader07.php index 0463f37b..cde1c409 100644 --- a/docs/Examples/Reader/exampleReader07.php +++ b/docs/Examples/Reader/exampleReader07.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Loading Sheet "',$sheetname,'" only
'; $reader->setLoadSheetsOnly($sheetname); $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader08.php b/docs/Examples/Reader/exampleReader08.php index c5e9b39d..0a739f75 100644 --- a/docs/Examples/Reader/exampleReader08.php +++ b/docs/Examples/Reader/exampleReader08.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Loading Sheet',((count($sheetnames) == 1) ? '' : 's'),' "',implode('" and "', $sheetnames),'" only
'; $reader->setLoadSheetsOnly($sheetnames); $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader09.php b/docs/Examples/Reader/exampleReader09.php index e2464447..8dde497c 100644 --- a/docs/Examples/Reader/exampleReader09.php +++ b/docs/Examples/Reader/exampleReader09.php @@ -1,5 +1,8 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Loading Sheet "',$sheetname,'" only
'; $reader->setLoadSheetsOnly($sheetname); echo 'Loading Sheet using filter
'; diff --git a/docs/Examples/Reader/exampleReader10.php b/docs/Examples/Reader/exampleReader10.php index 965a1bb2..f62c98d93 100644 --- a/docs/Examples/Reader/exampleReader10.php +++ b/docs/Examples/Reader/exampleReader10.php @@ -1,5 +1,8 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo 'Loading Sheet "',$sheetname,'" only
'; $reader->setLoadSheetsOnly($sheetname); echo 'Loading Sheet using configurable filter
'; diff --git a/docs/Examples/Reader/exampleReader11.php b/docs/Examples/Reader/exampleReader11.php index 5435629a..2b7225a9 100644 --- a/docs/Examples/Reader/exampleReader11.php +++ b/docs/Examples/Reader/exampleReader11.php @@ -1,5 +1,8 @@ '; /* Create a new Reader of the type defined in $inputFileType **/ -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo '
'; diff --git a/docs/Examples/Reader/exampleReader12.php b/docs/Examples/Reader/exampleReader12.php index 673b2f14..50580f2a 100644 --- a/docs/Examples/Reader/exampleReader12.php +++ b/docs/Examples/Reader/exampleReader12.php @@ -1,5 +1,8 @@ '; /* Create a new Reader of the type defined in $inputFileType **/ -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo '
'; diff --git a/docs/Examples/Reader/exampleReader13.php b/docs/Examples/Reader/exampleReader13.php index 9977a83c..c5107c87 100644 --- a/docs/Examples/Reader/exampleReader13.php +++ b/docs/Examples/Reader/exampleReader13.php @@ -1,5 +1,7 @@ '; $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader14.php b/docs/Examples/Reader/exampleReader14.php index 933be4ac..aad066dc 100644 --- a/docs/Examples/Reader/exampleReader14.php +++ b/docs/Examples/Reader/exampleReader14.php @@ -1,5 +1,9 @@ '; /* Create a new Reader of the type defined in $inputFileType **/ -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); echo '
'; @@ -71,7 +75,7 @@ $reader->setReadFilter($chunkFilter) ->setContiguous(true); /* Instantiate a new PhpSpreadsheet object manually **/ -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); /* Set a sheet index **/ $sheet = 0; diff --git a/docs/Examples/Reader/exampleReader15.php b/docs/Examples/Reader/exampleReader15.php index a04a1adc..fdf38b05 100644 --- a/docs/Examples/Reader/exampleReader15.php +++ b/docs/Examples/Reader/exampleReader15.php @@ -1,5 +1,8 @@ '; $reader->setDelimiter("\t"); $spreadsheet = $reader->load($inputFileName); diff --git a/docs/Examples/Reader/exampleReader16.php b/docs/Examples/Reader/exampleReader16.php index 6e6a7583..9436bd2e 100644 --- a/docs/Examples/Reader/exampleReader16.php +++ b/docs/Examples/Reader/exampleReader16.php @@ -1,5 +1,8 @@ '; try { - $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); -} catch (\InvalidArgumentException $e) { + $spreadsheet = IOFactory::load($inputFileName); +} catch (InvalidArgumentException $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } diff --git a/docs/Examples/Reader/exampleReader17.php b/docs/Examples/Reader/exampleReader17.php index f76994e9..763805ac 100644 --- a/docs/Examples/Reader/exampleReader17.php +++ b/docs/Examples/Reader/exampleReader17.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); /* Read the list of Worksheet Names from the Workbook file **/ echo 'Read the list of Worksheets in the WorkBook
'; diff --git a/docs/Examples/Reader/exampleReader18.php b/docs/Examples/Reader/exampleReader18.php index 6688e481..9822b209 100644 --- a/docs/Examples/Reader/exampleReader18.php +++ b/docs/Examples/Reader/exampleReader18.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); $worksheetNames = $reader->listWorksheetNames($inputFileName); echo '

Worksheet Names

'; diff --git a/docs/Examples/Reader/exampleReader19.php b/docs/Examples/Reader/exampleReader19.php index 5ad3e5ba..5749d1b6 100644 --- a/docs/Examples/Reader/exampleReader19.php +++ b/docs/Examples/Reader/exampleReader19.php @@ -1,5 +1,7 @@ '; -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$reader = IOFactory::createReader($inputFileType); $worksheetData = $reader->listWorksheetInfo($inputFileName); echo '

Worksheet Information

'; diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php index aa9bddd7..8a6b4726 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php @@ -1,5 +1,7 @@ load($inputFileName); diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php index c021728c..b9cfc196 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php @@ -1,5 +1,7 @@ load($inputFileName); diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php index c02f51bd..81327481 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php @@ -1,5 +1,7 @@ load($inputFileName); diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php index 88c7f9e0..e3a71d34 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php @@ -1,5 +1,7 @@ load($inputFileName); diff --git a/samples/01_Simple.php b/samples/01_Simple.php index d21de72e..3ba6ba05 100644 --- a/samples/01_Simple.php +++ b/samples/01_Simple.php @@ -1,10 +1,12 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/01_Simple_download_ods.php b/samples/01_Simple_download_ods.php index 8e76e8cf..4031eec6 100644 --- a/samples/01_Simple_download_ods.php +++ b/samples/01_Simple_download_ods.php @@ -1,8 +1,12 @@ isCli()) { echo 'This example should only be run from a Web Browser' . PHP_EOL; @@ -10,7 +14,7 @@ if ($helper->isCli()) { } // Create new Spreadsheet object -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties()->setCreator('Maarten Balliauw') @@ -52,6 +56,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods'); +$writer = IOFactory::createWriter($spreadsheet, 'Ods'); $writer->save('php://output'); exit; diff --git a/samples/01_Simple_download_pdf.php b/samples/01_Simple_download_pdf.php index dc23daa0..04c91a18 100644 --- a/samples/01_Simple_download_pdf.php +++ b/samples/01_Simple_download_pdf.php @@ -1,8 +1,13 @@ isCli()) { echo 'This example should only be run from a Web Browser' . PHP_EOL; @@ -12,11 +17,11 @@ if ($helper->isCli()) { // Change these values to select the Rendering library that you wish to use // and its directory location on your server //$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF; -$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF; +$rendererName = Settings::PDF_RENDERER_MPDF; //$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF; // Create new Spreadsheet object -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties()->setCreator('Maarten Balliauw') @@ -46,13 +51,13 @@ $spreadsheet->getActiveSheet()->setShowGridLines(false); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); -\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName); +Settings::setPdfRendererName($rendererName); // Redirect output to a client’s web browser (PDF) header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="01simple.pdf"'); header('Cache-Control: max-age=0'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf'); +$writer = IOFactory::createWriter($spreadsheet, 'Pdf'); $writer->save('php://output'); exit; diff --git a/samples/01_Simple_download_xls.php b/samples/01_Simple_download_xls.php index 7bfd5cc6..71fcbc7e 100644 --- a/samples/01_Simple_download_xls.php +++ b/samples/01_Simple_download_xls.php @@ -1,8 +1,12 @@ isCli()) { echo 'This example should only be run from a Web Browser' . PHP_EOL; @@ -10,7 +14,7 @@ if ($helper->isCli()) { } // Create new Spreadsheet object -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties()->setCreator('Maarten Balliauw') @@ -52,6 +56,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); +$writer = IOFactory::createWriter($spreadsheet, 'Xls'); $writer->save('php://output'); exit; diff --git a/samples/01_Simple_download_xlsx.php b/samples/01_Simple_download_xlsx.php index 3881d4cc..45ba9bc3 100644 --- a/samples/01_Simple_download_xlsx.php +++ b/samples/01_Simple_download_xlsx.php @@ -1,15 +1,19 @@ isCli()) { echo 'This example should only be run from a Web Browser' . PHP_EOL; return; } // Create new Spreadsheet object -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $spreadsheet->getProperties()->setCreator('Maarten Balliauw') @@ -51,6 +55,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->save('php://output'); exit; diff --git a/samples/02_Types.php b/samples/02_Types.php index 5fef248d..84bc5002 100644 --- a/samples/02_Types.php +++ b/samples/02_Types.php @@ -1,10 +1,16 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -70,41 +76,41 @@ $dateTimeNow = time(); $spreadsheet->getActiveSheet() ->setCellValue('A9', 'Date/Time') ->setCellValue('B9', 'Date') - ->setCellValue('C9', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow)); + ->setCellValue('C9', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C9') ->getNumberFormat() - ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); + ->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2); $spreadsheet->getActiveSheet() ->setCellValue('A10', 'Date/Time') ->setCellValue('B10', 'Time') - ->setCellValue('C10', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow)); + ->setCellValue('C10', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C10') ->getNumberFormat() - ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4); + ->setFormatCode(NumberFormat::FORMAT_DATE_TIME4); $spreadsheet->getActiveSheet() ->setCellValue('A11', 'Date/Time') ->setCellValue('B11', 'Date and Time') - ->setCellValue('C11', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow)); + ->setCellValue('C11', Date::PHPToExcel($dateTimeNow)); $spreadsheet->getActiveSheet() ->getStyle('C11') ->getNumberFormat() - ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME); + ->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME); $spreadsheet->getActiveSheet() ->setCellValue('A12', 'NULL') ->setCellValue('C12', null); -$richText = new \PhpOffice\PhpSpreadsheet\RichText(); +$richText = new RichText(); $richText->createText('你好 '); $payable = $richText->createTextRun('你 好 吗?'); $payable->getFont()->setBold(true); $payable->getFont()->setItalic(true); -$payable->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN)); +$payable->getFont()->setColor(new Color(Color::COLOR_DARKGREEN)); $richText->createText(', unless specified otherwise on the invoice.'); @@ -112,11 +118,11 @@ $spreadsheet->getActiveSheet() ->setCellValue('A13', 'Rich Text') ->setCellValue('C13', $richText); -$richText2 = new \PhpOffice\PhpSpreadsheet\RichText(); +$richText2 = new RichText(); $richText2->createText("black text\n"); $red = $richText2->createTextRun('red text'); -$red->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED)); +$red->getFont()->setColor(new Color(Color::COLOR_RED)); $spreadsheet->getActiveSheet() ->getCell('C14') diff --git a/samples/03_Formulas.php b/samples/03_Formulas.php index 8896253c..752b99c8 100644 --- a/samples/03_Formulas.php +++ b/samples/03_Formulas.php @@ -1,10 +1,12 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/04_Printing.php b/samples/04_Printing.php index 4434b2f5..e8854821 100644 --- a/samples/04_Printing.php +++ b/samples/04_Printing.php @@ -1,10 +1,15 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -34,22 +39,22 @@ $spreadsheet->getActiveSheet() // Add a drawing to the header $helper->log('Add a drawing to the header'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing(); +$drawing = new HeaderFooterDrawing(); $drawing->setName('PhpSpreadsheet logo'); $drawing->setPath(__DIR__ . '/images/PhpSpreadsheet_logo.png'); $drawing->setHeight(36); $spreadsheet->getActiveSheet() ->getHeaderFooter() - ->addImage($drawing, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT); + ->addImage($drawing, HeaderFooter::IMAGE_HEADER_LEFT); // Set page orientation and size $helper->log('Set page orientation and size'); $spreadsheet->getActiveSheet() ->getPageSetup() - ->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); + ->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); $spreadsheet->getActiveSheet() ->getPageSetup() - ->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4); + ->setPaperSize(PageSetup::PAPERSIZE_A4); // Rename worksheet $helper->log('Rename worksheet'); diff --git a/samples/07_Reader.php b/samples/07_Reader.php index 2e7b9610..05186521 100644 --- a/samples/07_Reader.php +++ b/samples/07_Reader.php @@ -1,15 +1,18 @@ getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); +$writer = new Xlsx($sampleSpreadsheet); $writer->save($filename); $callStartTime = microtime(true); -$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); +$spreadsheet = IOFactory::load($filename); $helper->logRead('Xlsx', $filename, $callStartTime); // Save diff --git a/samples/08_Conditional_formatting.php b/samples/08_Conditional_formatting.php index 86019305..36c3aaee 100644 --- a/samples/08_Conditional_formatting.php +++ b/samples/08_Conditional_formatting.php @@ -1,10 +1,16 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -47,30 +53,30 @@ $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(12); // Add conditional formatting $helper->log('Add conditional formatting'); -$conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); -$conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) - ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_BETWEEN) +$conditional1 = new Conditional(); +$conditional1->setConditionType(Conditional::CONDITION_CELLIS) + ->setOperatorType(Conditional::OPERATOR_BETWEEN) ->addCondition('200') ->addCondition('400'); -$conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_YELLOW); +$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW); $conditional1->getStyle()->getFont()->setBold(true); -$conditional1->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$conditional1->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); -$conditional2 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); -$conditional2->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) - ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN) +$conditional2 = new Conditional(); +$conditional2->setConditionType(Conditional::CONDITION_CELLIS) + ->setOperatorType(Conditional::OPERATOR_LESSTHAN) ->addCondition('0'); -$conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED); +$conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED); $conditional2->getStyle()->getFont()->setItalic(true); -$conditional2->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$conditional2->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); -$conditional3 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); -$conditional3->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) - ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL) +$conditional3 = new Conditional(); +$conditional3->setConditionType(Conditional::CONDITION_CELLIS) + ->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL) ->addCondition('0'); -$conditional3->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN); +$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN); $conditional3->getStyle()->getFont()->setItalic(true); -$conditional3->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles(); array_push($conditionalStyles, $conditional1); @@ -98,8 +104,8 @@ $spreadsheet->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $spread // Set page orientation and size $helper->log('Set page orientation and size'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT); -$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT); +$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(PageSetup::PAPERSIZE_A4); // Rename worksheet $helper->log('Rename worksheet'); diff --git a/samples/08_Conditional_formatting_2.php b/samples/08_Conditional_formatting_2.php index 87bd2851..07d2361d 100644 --- a/samples/08_Conditional_formatting_2.php +++ b/samples/08_Conditional_formatting_2.php @@ -1,10 +1,15 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -32,22 +37,22 @@ $spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()->getStyle('A1:A8') ->getNumberFormat() ->setFormatCode( - \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00 + NumberFormat::FORMAT_PERCENTAGE_00 ); // Add conditional formatting $helper->log('Add conditional formatting'); -$conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); -$conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) - ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN) +$conditional1 = new Conditional(); +$conditional1->setConditionType(Conditional::CONDITION_CELLIS) + ->setOperatorType(Conditional::OPERATOR_LESSTHAN) ->addCondition('0'); -$conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED); +$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED); -$conditional3 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); -$conditional3->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) - ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL) +$conditional3 = new Conditional(); +$conditional3->setConditionType(Conditional::CONDITION_CELLIS) + ->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL) ->addCondition('1'); -$conditional3->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN); +$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN); $conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(); array_push($conditionalStyles, $conditional1); diff --git a/samples/09_Pagebreaks.php b/samples/09_Pagebreaks.php index 9b91d2f0..c4cf33af 100644 --- a/samples/09_Pagebreaks.php +++ b/samples/09_Pagebreaks.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -36,7 +39,7 @@ for ($i = 2; $i <= 50; ++$i) { // Add page breaks every 10 rows if ($i % 10 == 0) { // Add a page break - $spreadsheet->getActiveSheet()->setBreak('A' . $i, \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW); + $spreadsheet->getActiveSheet()->setBreak('A' . $i, Worksheet::BREAK_ROW); } } diff --git a/samples/10_Autofilter.php b/samples/10_Autofilter.php index 45955a8c..7058e6a5 100644 --- a/samples/10_Autofilter.php +++ b/samples/10_Autofilter.php @@ -1,10 +1,12 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/10_Autofilter_selection_1.php b/samples/10_Autofilter_selection_1.php index 6f74f483..1b34b019 100644 --- a/samples/10_Autofilter_selection_1.php +++ b/samples/10_Autofilter_selection_1.php @@ -1,10 +1,16 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -48,7 +54,7 @@ foreach ($years as $year) { foreach ($countries as $country) { $endDays = date('t', mktime(0, 0, 0, $period, 1, $year)); for ($i = 1; $i <= $endDays; ++$i) { - $eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + $eDate = Date::formattedPHPToExcel( $year, $period, $i @@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true); $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true); $spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5); $spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5); -$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); -$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); +$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2); +$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); $spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14); $spreadsheet->getActiveSheet()->freezePane('A2'); @@ -104,45 +110,45 @@ $helper->log('Set active filters'); // Filter the Country column on a filter value of countries beginning with the letter U (or Japan) // We use * as a wildcard, so specify as U* and using a wildcard requires customFilter $autoFilter->getColumn('C') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, 'u*' ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); $autoFilter->getColumn('C') ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, 'japan' ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); // Filter the Date column on a filter value of the first day of every period of the current year // We us a dateGroup ruletype for this, although it is still a standard filter foreach ($periods as $period) { $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $autoFilter->getColumn('D') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, [ 'year' => $currentYear, 'month' => $period, 'day' => $endDate, ] ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP); } // Display only sales values that are blank // Standard filter, operator equals, and value of NULL $autoFilter->getColumn('E') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, '' ); diff --git a/samples/10_Autofilter_selection_2.php b/samples/10_Autofilter_selection_2.php index 1802d0ea..9bfb254a 100644 --- a/samples/10_Autofilter_selection_2.php +++ b/samples/10_Autofilter_selection_2.php @@ -1,10 +1,16 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -48,7 +54,7 @@ foreach ($years as $year) { foreach ($countries as $country) { $endDays = date('t', mktime(0, 0, 0, $period, 1, $year)); for ($i = 1; $i <= $endDays; ++$i) { - $eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + $eDate = Date::formattedPHPToExcel( $year, $period, $i @@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true); $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true); $spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5); $spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5); -$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); -$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); +$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2); +$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); $spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14); $spreadsheet->getActiveSheet()->freezePane('A2'); @@ -104,39 +110,39 @@ $helper->log('Set active filters'); // Filter the Country column on a filter value of Germany // As it's just a simple value filter, we can use FILTERTYPE_FILTER $autoFilter->getColumn('C') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, 'Germany' ); // Filter the Date column on a filter value of the year to date $autoFilter->getColumn('D') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, null, - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE + Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); // Display only sales values that are between 400 and 600 $autoFilter->getColumn('E') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, + Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, 400 ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); $autoFilter->getColumn('E') - ->setJoin(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND) + ->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, + Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, 600 ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); // Save $helper->write($spreadsheet, __FILE__); diff --git a/samples/10_Autofilter_selection_display.php b/samples/10_Autofilter_selection_display.php index 0f431e66..2be654d3 100644 --- a/samples/10_Autofilter_selection_display.php +++ b/samples/10_Autofilter_selection_display.php @@ -1,10 +1,16 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -48,7 +54,7 @@ foreach ($years as $year) { foreach ($countries as $country) { $endDays = date('t', mktime(0, 0, 0, $period, 1, $year)); for ($i = 1; $i <= $endDays; ++$i) { - $eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + $eDate = Date::formattedPHPToExcel( $year, $period, $i @@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true); $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true); $spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5); $spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5); -$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2); -$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); +$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2); +$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); $spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14); $spreadsheet->getActiveSheet()->freezePane('A2'); @@ -104,45 +110,45 @@ $helper->log('Set active filters'); // Filter the Country column on a filter value of countries beginning with the letter U (or Japan) // We use * as a wildcard, so specify as U* and using a wildcard requires customFilter $autoFilter->getColumn('C') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, 'u*' ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); $autoFilter->getColumn('C') ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, 'japan' ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); // Filter the Date column on a filter value of the first day of every period of the current year // We us a dateGroup ruletype for this, although it is still a standard filter foreach ($periods as $period) { $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $autoFilter->getColumn('D') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, [ 'year' => $currentYear, 'month' => $period, 'day' => $endDate, ] ) - ->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); + ->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP); } // Display only sales values that are blank // Standard filter, operator equals, and value of NULL $autoFilter->getColumn('E') - ->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) + ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->createRule() ->setRule( - \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, '' ); diff --git a/samples/11_Documentsecurity.php b/samples/11_Documentsecurity.php index 2224808a..0298e7ee 100644 --- a/samples/11_Documentsecurity.php +++ b/samples/11_Documentsecurity.php @@ -1,10 +1,12 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/12_CellProtection.php b/samples/12_CellProtection.php index 4ef97b01..a84bb8a5 100644 --- a/samples/12_CellProtection.php +++ b/samples/12_CellProtection.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -37,7 +40,7 @@ $spreadsheet->getActiveSheet()->getProtection()->setSheet(true); $spreadsheet->getActiveSheet() ->getStyle('A2:B2') ->getProtection()->setLocked( - \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED + Protection::PROTECTION_UNPROTECTED ); // Save diff --git a/samples/13_Calculation.php b/samples/13_Calculation.php index d620a6f2..e143e9ab 100644 --- a/samples/13_Calculation.php +++ b/samples/13_Calculation.php @@ -1,17 +1,20 @@ log('List implemented functions'); -$calc = \PhpOffice\PhpSpreadsheet\Calculation::getInstance(); +$calc = Calculation::getInstance(); print_r($calc->getImplementedFunctionNames()); // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Add some data, we will use some formulas here $helper->log('Add some data and formulas'); diff --git a/samples/13_CalculationCyclicFormulae.php b/samples/13_CalculationCyclicFormulae.php index ea1be404..968c467c 100644 --- a/samples/13_CalculationCyclicFormulae.php +++ b/samples/13_CalculationCyclicFormulae.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Add some data, we will use some formulas here $helper->log('Add some data and formulas'); @@ -13,7 +16,7 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', '=B1') ->setCellValue('B1', '=A1+1') ->setCellValue('B2', '=A2'); -\PhpOffice\PhpSpreadsheet\Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100; +Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100; // Calculated data $helper->log('Calculated data'); diff --git a/samples/14_Xls.php b/samples/14_Xls.php index 86d125b9..03a38d28 100644 --- a/samples/14_Xls.php +++ b/samples/14_Xls.php @@ -1,10 +1,12 @@ getFilename(__FILE__, 'xls'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); +$writer = IOFactory::createWriter($spreadsheet, 'Xls'); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/15_Datavalidation.php b/samples/15_Datavalidation.php index bd7299d6..416a102a 100644 --- a/samples/15_Datavalidation.php +++ b/samples/15_Datavalidation.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -35,8 +38,8 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', 'Cell B3 and B5 contain data // Set data validation $helper->log('Set data validation'); $validation = $spreadsheet->getActiveSheet()->getCell('B3')->getDataValidation(); -$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE); -$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP); +$validation->setType(DataValidation::TYPE_WHOLE); +$validation->setErrorStyle(DataValidation::STYLE_STOP); $validation->setAllowBlank(true); $validation->setShowInputMessage(true); $validation->setShowErrorMessage(true); @@ -48,8 +51,8 @@ $validation->setFormula1(10); $validation->setFormula2(20); $validation = $spreadsheet->getActiveSheet()->getCell('B5')->getDataValidation(); -$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST); -$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION); +$validation->setType(DataValidation::TYPE_LIST); +$validation->setErrorStyle(DataValidation::STYLE_INFORMATION); $validation->setAllowBlank(false); $validation->setShowInputMessage(true); $validation->setShowErrorMessage(true); @@ -61,8 +64,8 @@ $validation->setPrompt('Please pick a value from the drop-down list.'); $validation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " if your list is simply a comma-separated list of values !!! $validation = $spreadsheet->getActiveSheet()->getCell('B7')->getDataValidation(); -$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST); -$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION); +$validation->setType(DataValidation::TYPE_LIST); +$validation->setErrorStyle(DataValidation::STYLE_INFORMATION); $validation->setAllowBlank(false); $validation->setShowInputMessage(true); $validation->setShowErrorMessage(true); diff --git a/samples/16_Csv.php b/samples/16_Csv.php index 63cbd53e..0c1db51d 100644 --- a/samples/16_Csv.php +++ b/samples/16_Csv.php @@ -1,10 +1,12 @@ log('Write to CSV format'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',') +$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',') ->setEnclosure('"') ->setSheetIndex(0); @@ -15,7 +17,7 @@ $helper->logWrite($writer, $filename, $callStartTime); $helper->log('Read from CSV format'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Csv')->setDelimiter(',') +$reader = IOFactory::createReader('Csv')->setDelimiter(',') ->setEnclosure('"') ->setSheetIndex(0); @@ -28,7 +30,7 @@ $helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx']); // Write CSV $filenameCSV = $helper->getFilename(__FILE__, 'csv'); -$writerCSV = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheetFromCSV, 'Csv'); +$writerCSV = IOFactory::createWriter($spreadsheetFromCSV, 'Csv'); $writerCSV->setExcelCompatibility(true); $callStartTime = microtime(true); diff --git a/samples/17_Html.php b/samples/17_Html.php index d3dfd5b0..9ea9f0bd 100644 --- a/samples/17_Html.php +++ b/samples/17_Html.php @@ -1,10 +1,12 @@ getFilename(__FILE__, 'html'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Html'); +$writer = IOFactory::createWriter($spreadsheet, 'Html'); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/18_Extendedcalculation.php b/samples/18_Extendedcalculation.php index b7d45b33..e459e9d3 100644 --- a/samples/18_Extendedcalculation.php +++ b/samples/18_Extendedcalculation.php @@ -1,16 +1,18 @@ log('List implemented functions'); -$calc = \PhpOffice\PhpSpreadsheet\Calculation::getInstance(); +$calc = Calculation::getInstance(); print_r($calc->getImplementedFunctionNames()); // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Add some data, we will use some formulas here $helper->log('Add some data'); diff --git a/samples/19_Namedrange.php b/samples/19_Namedrange.php index ea39a335..53c25660 100644 --- a/samples/19_Namedrange.php +++ b/samples/19_Namedrange.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -28,8 +31,8 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:') // Define named ranges $helper->log('Define named ranges'); -$spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('PersonName', $spreadsheet->getActiveSheet(), 'B1')); -$spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('PersonLN', $spreadsheet->getActiveSheet(), 'B2')); +$spreadsheet->addNamedRange(new NamedRange('PersonName', $spreadsheet->getActiveSheet(), 'B1')); +$spreadsheet->addNamedRange(new NamedRange('PersonLN', $spreadsheet->getActiveSheet(), 'B2')); // Rename named ranges $helper->log('Rename named ranges'); diff --git a/samples/20_Read_Excel2003XML.php b/samples/20_Read_Excel2003XML.php index e6c1a797..6e2f464d 100644 --- a/samples/20_Read_Excel2003XML.php +++ b/samples/20_Read_Excel2003XML.php @@ -1,10 +1,12 @@ logRead('Xml', $filename, $callStartTime); // Save diff --git a/samples/20_Read_Gnumeric.php b/samples/20_Read_Gnumeric.php index d390dc14..d2c598c4 100644 --- a/samples/20_Read_Gnumeric.php +++ b/samples/20_Read_Gnumeric.php @@ -1,10 +1,12 @@ logRead('Gnumeric', $filename, $callStartTime); // Save diff --git a/samples/20_Read_Ods.php b/samples/20_Read_Ods.php index 37f7d4f7..10a8275c 100644 --- a/samples/20_Read_Ods.php +++ b/samples/20_Read_Ods.php @@ -1,10 +1,12 @@ logRead('Ods', $filename, $callStartTime); // Save diff --git a/samples/20_Read_Sylk.php b/samples/20_Read_Sylk.php index b3baa5a5..c07c9647 100644 --- a/samples/20_Read_Sylk.php +++ b/samples/20_Read_Sylk.php @@ -1,10 +1,12 @@ logRead('Slk', $filename, $callStartTime); // Save diff --git a/samples/20_Read_Xls.php b/samples/20_Read_Xls.php index ef8b1eda..542f96a2 100644 --- a/samples/20_Read_Xls.php +++ b/samples/20_Read_Xls.php @@ -1,19 +1,21 @@ getTemporaryFilename('xls'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); +$writer = IOFactory::createWriter($spreadsheet, 'Xls'); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); // Read Xls file $callStartTime = microtime(true); -$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); +$spreadsheet = IOFactory::load($filename); $helper->logRead('Xls', $filename, $callStartTime); // Save diff --git a/samples/21_Pdf_Domdf.php b/samples/21_Pdf_Domdf.php index bc891d6f..f13ca72c 100644 --- a/samples/21_Pdf_Domdf.php +++ b/samples/21_Pdf_Domdf.php @@ -1,5 +1,8 @@ log('Hide grid lines'); $spreadsheet->getActiveSheet()->setShowGridLines(false); $helper->log('Set orientation to landscape'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); -$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF; +$rendererName = Settings::PDF_RENDERER_DOMPDF; $helper->log("Write to PDF format using {$rendererName}"); -\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName); +Settings::setPdfRendererName($rendererName); // Save $helper->write($spreadsheet, __FILE__, ['Pdf']); diff --git a/samples/21_Pdf_TCPDF.php b/samples/21_Pdf_TCPDF.php index 980069fc..1bf75c84 100644 --- a/samples/21_Pdf_TCPDF.php +++ b/samples/21_Pdf_TCPDF.php @@ -1,5 +1,8 @@ log('Hide grid lines'); $spreadsheet->getActiveSheet()->setShowGridLines(false); $helper->log('Set orientation to landscape'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); -$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF; +$rendererName = Settings::PDF_RENDERER_TCPDF; $helper->log("Write to PDF format using {$rendererName}"); -\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName); +Settings::setPdfRendererName($rendererName); // Save $helper->write($spreadsheet, __FILE__, ['Pdf']); diff --git a/samples/21_Pdf_mPDF.php b/samples/21_Pdf_mPDF.php index b5327a61..8e46f838 100644 --- a/samples/21_Pdf_mPDF.php +++ b/samples/21_Pdf_mPDF.php @@ -1,5 +1,8 @@ log('Hide grid lines'); $spreadsheet->getActiveSheet()->setShowGridLines(false); $helper->log('Set orientation to landscape'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); -$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF; +$rendererName = Settings::PDF_RENDERER_MPDF; $helper->log("Write to PDF format using {$rendererName}"); -\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName); +Settings::setPdfRendererName($rendererName); // Save $helper->write($spreadsheet, __FILE__, ['Pdf']); diff --git a/samples/22_Heavily_formatted.php b/samples/22_Heavily_formatted.php index 541f3149..ea4cd804 100644 --- a/samples/22_Heavily_formatted.php +++ b/samples/22_Heavily_formatted.php @@ -1,10 +1,14 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -22,19 +26,19 @@ $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->getStyle('A1:T100')->applyFromArray( ['fill' => [ - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'type' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFCCFFCC'], ], 'borders' => [ - 'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN], - 'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM], + 'bottom' => ['style' => Border::BORDER_THIN], + 'right' => ['style' => Border::BORDER_MEDIUM], ], ] ); $spreadsheet->getActiveSheet()->getStyle('C5:R95')->applyFromArray( ['fill' => [ - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'type' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFFFFF00'], ], ] diff --git a/samples/23_Sharedstyles.php b/samples/23_Sharedstyles.php index 48ffb1ad..74e3d8d6 100644 --- a/samples/23_Sharedstyles.php +++ b/samples/23_Sharedstyles.php @@ -1,10 +1,15 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -20,29 +25,29 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw') $helper->log('Add some data'); $spreadsheet->setActiveSheetIndex(0); -$sharedStyle1 = new \PhpOffice\PhpSpreadsheet\Style(); -$sharedStyle2 = new \PhpOffice\PhpSpreadsheet\Style(); +$sharedStyle1 = new Style(); +$sharedStyle2 = new Style(); $sharedStyle1->applyFromArray( ['fill' => [ - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'type' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFCCFFCC'], ], 'borders' => [ - 'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN], - 'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM], + 'bottom' => ['style' => Border::BORDER_THIN], + 'right' => ['style' => Border::BORDER_MEDIUM], ], ] ); $sharedStyle2->applyFromArray( ['fill' => [ - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'type' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFFFFF00'], ], 'borders' => [ - 'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN], - 'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM], + 'bottom' => ['style' => Border::BORDER_THIN], + 'right' => ['style' => Border::BORDER_MEDIUM], ], ] ); diff --git a/samples/24_Readfilter.php b/samples/24_Readfilter.php index 17912705..f5258604 100644 --- a/samples/24_Readfilter.php +++ b/samples/24_Readfilter.php @@ -2,17 +2,20 @@ namespace PhpOffice\PhpSpreadsheet; +use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; + require __DIR__ . '/Header.php'; // Write temporary file $largeSpreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php'; -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($largeSpreadsheet); +$writer = new Xlsx($largeSpreadsheet); $filename = $helper->getTemporaryFilename(); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); -class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter +class MyReadFilter implements IReadFilter { public function readCell($column, $row, $worksheetName = '') { @@ -26,7 +29,7 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter } $helper->log('Load from Xlsx file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); +$reader = IOFactory::createReader('Xlsx'); $reader->setReadFilter(new MyReadFilter()); $callStartTime = microtime(true); $spreadsheet = $reader->load($filename); diff --git a/samples/25_In_memory_image.php b/samples/25_In_memory_image.php index aef166f1..5756bd3e 100644 --- a/samples/25_In_memory_image.php +++ b/samples/25_In_memory_image.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -24,12 +27,12 @@ imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); // Add a drawing to the worksheet $helper->log('Add a drawing to the worksheet'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing(); +$drawing = new MemoryDrawing(); $drawing->setName('Sample image'); $drawing->setDescription('Sample image'); $drawing->setImageResource($gdImage); -$drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG); -$drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT); +$drawing->setRenderingFunction(MemoryDrawing::RENDERING_JPEG); +$drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT); $drawing->setHeight(36); $drawing->setWorksheet($spreadsheet->getActiveSheet()); diff --git a/samples/26_Utf8.php b/samples/26_Utf8.php index 105b0f94..790640a0 100644 --- a/samples/26_Utf8.php +++ b/samples/26_Utf8.php @@ -1,16 +1,19 @@ log('Load Xlsx template file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); +$reader = IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load(__DIR__ . '/templates/26template.xlsx'); /* at this point, we could do some manipulations with the template, but we skip this step */ @@ -18,7 +21,7 @@ $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']); // Export to PDF (.pdf) $helper->log('Write to PDF format'); -\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName); +Settings::setPdfRendererName($rendererName); $helper->write($spreadsheet, __FILE__, ['Pdf']); // Remove first two rows with field headers before exporting to CSV @@ -28,7 +31,7 @@ $worksheet->removeRow(1, 2); // Export to CSV (.csv) $helper->log('Write to CSV format'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv'); +$writer = IOFactory::createWriter($spreadsheet, 'Csv'); $filename = $helper->getFilename(__FILE__, 'csv'); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/27_Images_Xls.php b/samples/27_Images_Xls.php index 8fc7bf2b..4923efe2 100644 --- a/samples/27_Images_Xls.php +++ b/samples/27_Images_Xls.php @@ -1,10 +1,12 @@ log('Load Xlsx template file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls'); +$reader = IOFactory::createReader('Xls'); $spreadsheet = $reader->load(__DIR__ . '/templates/27template.xls'); // Save diff --git a/samples/28_Iterator.php b/samples/28_Iterator.php index 95bed125..5dbb49e4 100644 --- a/samples/28_Iterator.php +++ b/samples/28_Iterator.php @@ -1,16 +1,19 @@ getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); +$writer = new Xlsx($sampleSpreadsheet); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); $callStartTime = microtime(true); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); +$reader = IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load($filename); $helper->logRead('Xlsx', $filename, $callStartTime); $helper->log('Iterate worksheets'); diff --git a/samples/29_Advanced_value_binder.php b/samples/29_Advanced_value_binder.php index 260a612b..7f22c8f0 100644 --- a/samples/29_Advanced_value_binder.php +++ b/samples/29_Advanced_value_binder.php @@ -1,5 +1,7 @@ log('Set value binder'); -\PhpOffice\PhpSpreadsheet\Cell::setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder()); +Cell::setValueBinder(new Cell\AdvancedValueBinder()); // Create new Spreadsheet object $helper->log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/30_Template.php b/samples/30_Template.php index ed6f588e..4c6d867b 100644 --- a/samples/30_Template.php +++ b/samples/30_Template.php @@ -1,9 +1,12 @@ log('Load from Xls template'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls'); +$reader = IOFactory::createReader('Xls'); $spreadsheet = $reader->load(__DIR__ . '/templates/30template.xls'); $helper->log('Add new data to the template'); @@ -21,7 +24,7 @@ $data = [['title' => 'Excel for dummies', ], ]; -$spreadsheet->getActiveSheet()->setCellValue('D1', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time())); +$spreadsheet->getActiveSheet()->setCellValue('D1', Date::PHPToExcel(time())); $baseRow = 5; foreach ($data as $r => $dataRow) { diff --git a/samples/31_Document_properties_write.php b/samples/31_Document_properties_write.php index 76aeaa62..15936ffa 100644 --- a/samples/31_Document_properties_write.php +++ b/samples/31_Document_properties_write.php @@ -1,11 +1,14 @@ load($inputFileName); $helper->logRead($inputFileType, $inputFileName, $callStartTime); @@ -18,7 +21,7 @@ $spreadsheet->getProperties()->setTitle('Office 2007 XLSX Test Document') // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); @@ -28,7 +31,7 @@ $helper->logEndingNotes(); // Reread File $helper->log('Reread Xlsx file'); -$spreadsheetRead = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); +$spreadsheetRead = IOFactory::load($filename); // Set properties $helper->log('Get properties'); @@ -53,9 +56,9 @@ $customProperties = $spreadsheet->getProperties()->getCustomProperties(); foreach ($customProperties as $customProperty) { $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty); $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty); - if ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE) { + if ($propertyType == Properties::PROPERTY_TYPE_DATE) { $formattedValue = date('d-M-Y H:i:s', $propertyValue); - } elseif ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN) { + } elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) { $formattedValue = $propertyValue ? 'TRUE' : 'FALSE'; } else { $formattedValue = $propertyValue; diff --git a/samples/31_Document_properties_write_xls.php b/samples/31_Document_properties_write_xls.php index 38f15354..a427be18 100644 --- a/samples/31_Document_properties_write_xls.php +++ b/samples/31_Document_properties_write_xls.php @@ -1,11 +1,14 @@ load($inputFileName); $helper->logRead($inputFileType, $inputFileName, $callStartTime); @@ -18,7 +21,7 @@ $spreadsheet->getProperties()->setTitle('Office 95 XLS Test Document') // Save Excel 95 file $filename = $helper->getFilename(__FILE__, 'xls'); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); +$writer = IOFactory::createWriter($spreadsheet, 'Xls'); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); @@ -28,7 +31,7 @@ $helper->logEndingNotes(); // Reread File $helper->log('Reread Xls file'); -$spreadsheetRead = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); +$spreadsheetRead = IOFactory::load($filename); // Set properties $helper->log('Get properties'); @@ -53,9 +56,9 @@ $customProperties = $spreadsheet->getProperties()->getCustomProperties(); foreach ($customProperties as $customProperty) { $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty); $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty); - if ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE) { + if ($propertyType == Properties::PROPERTY_TYPE_DATE) { $formattedValue = date('d-M-Y H:i:s', $propertyValue); - } elseif ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN) { + } elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) { $formattedValue = $propertyValue ? 'TRUE' : 'FALSE'; } else { $formattedValue = $propertyValue; diff --git a/samples/32_Chart_read_write.php b/samples/32_Chart_read_write.php index 2ae0b8ae..6668280c 100644 --- a/samples/32_Chart_read_write.php +++ b/samples/32_Chart_read_write.php @@ -1,5 +1,7 @@ log('File ' . $inputFileNameShort . ' does not exist'); continue; } - $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); + $reader = IOFactory::createReader($inputFileType); $reader->setIncludeCharts(true); $callStartTime = microtime(true); $spreadsheet = $reader->load($inputFileName); @@ -69,7 +71,7 @@ foreach ($inputFileNames as $inputFileName) { } $outputFileName = $helper->getFilename($inputFileName); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); + $writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($outputFileName); diff --git a/samples/32_Chart_read_write_HTML.php b/samples/32_Chart_read_write_HTML.php index aa697efd..ac2d1e1b 100644 --- a/samples/32_Chart_read_write_HTML.php +++ b/samples/32_Chart_read_write_HTML.php @@ -1,14 +1,17 @@ log('NOTICE: Please set the $rendererName and $rendererLibraryPath values at the top of this script as appropriate for your directory structure'); return; @@ -35,7 +38,7 @@ foreach ($inputFileNames as $inputFileName) { $helper->log("Load Test from $inputFileType file " . $inputFileNameShort); - $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); + $reader = IOFactory::createReader($inputFileType); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($inputFileName); @@ -83,7 +86,7 @@ foreach ($inputFileNames as $inputFileName) { // Save $filename = $helper->getFilename($inputFileName); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Html'); + $writer = IOFactory::createWriter($spreadsheet, 'Html'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/32_Chart_read_write_PDF.php b/samples/32_Chart_read_write_PDF.php index d41f6728..ffd4ba40 100644 --- a/samples/32_Chart_read_write_PDF.php +++ b/samples/32_Chart_read_write_PDF.php @@ -1,22 +1,25 @@ log('NOTICE: Please set the $rendererName and $rendererLibraryPath values at the top of this script as appropriate for your directory structure'); return; @@ -43,7 +46,7 @@ foreach ($inputFileNames as $inputFileName) { $helper->log("Load Test from $inputFileType file " . $inputFileNameShort); - $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); + $reader = IOFactory::createReader($inputFileType); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($inputFileName); @@ -91,7 +94,7 @@ foreach ($inputFileNames as $inputFileName) { // Save $filename = $helper->getFilename($inputFileName); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf'); + $writer = IOFactory::createWriter($spreadsheet, 'Pdf'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_area.php b/samples/33_Chart_create_area.php index 550f8133..76a9f478 100644 --- a/samples/33_Chart_create_area.php +++ b/samples/33_Chart_create_area.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -35,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -45,15 +53,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_AREACHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_AREACHART, // plotType + DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -61,15 +69,15 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_TOPRIGHT, null, false); +$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test %age-Stacked Area Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test %age-Stacked Area Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -89,7 +97,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_bar.php b/samples/33_Chart_create_bar.php index 6889956b..96ac5ef7 100644 --- a/samples/33_Chart_create_bar.php +++ b/samples/33_Chart_create_bar.php @@ -1,5 +1,6 @@ getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_bar_stacked.php b/samples/33_Chart_create_bar_stacked.php index f4bb87bc..af9fb542 100644 --- a/samples/33_Chart_create_bar_stacked.php +++ b/samples/33_Chart_create_bar_stacked.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -35,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -45,15 +53,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STACKED, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_STACKED, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -61,18 +69,18 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a horizontal bar rather than a vertical column graph -$series->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_BAR); +$series->setPlotDirection(DataSeries::DIRECTION_BAR); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -92,7 +100,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_column.php b/samples/33_Chart_create_column.php index 1d4023cf..12903ea6 100644 --- a/samples/33_Chart_create_column.php +++ b/samples/33_Chart_create_column.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -35,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -45,15 +53,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -61,18 +69,18 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a vertical column rather than a horizontal bar graph -$series->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_COL); +$series->setPlotDirection(DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Column Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Column Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -92,7 +100,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_column_2.php b/samples/33_Chart_create_column_2.php index d459dd5b..8ea8d791 100644 --- a/samples/33_Chart_create_column_2.php +++ b/samples/33_Chart_create_column_2.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -31,9 +39,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 'Budget' - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 'Forecast' - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$E$1', null, 1), // 'Actual' + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 'Budget' + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 'Forecast' + new DataSeriesValues('String', 'Worksheet!$E$1', null, 1), // 'Actual' ]; // Set the X-Axis Labels // Datatype @@ -43,7 +51,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012 + new DataSeriesValues('String', 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,15 +61,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$E$2:$E$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$E$2:$E$13', null, 12), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -69,19 +77,19 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a vertical column rather than a horizontal bar graph -$series->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_COL); +$series->setPlotDirection(DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_BOTTOM, null, false); +$legend = new Legend(Legend::POSITION_BOTTOM, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Grouped Column Chart'); -$xAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Financial Period'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Grouped Column Chart'); +$xAxisLabel = new Title('Financial Period'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -101,7 +109,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_composite.php b/samples/33_Chart_create_composite.php index 57abd991..d050a3e9 100644 --- a/samples/33_Chart_create_composite.php +++ b/samples/33_Chart_create_composite.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -31,13 +39,13 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // Temperature + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // Temperature ]; $dataSeriesLabels2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // Rainfall + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // Rainfall ]; $dataSeriesLabels3 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // Humidity + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // Humidity ]; // Set the X-Axis Labels @@ -48,7 +56,7 @@ $dataSeriesLabels3 = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec ]; // Set the Data values for each data series we want to plot @@ -59,13 +67,13 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', null, 12), ]; // Build the dataseries -$series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping +$series1 = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues1) - 1), // plotOrder $dataSeriesLabels1, // plotLabel $xAxisTickValues, // plotCategory @@ -73,7 +81,7 @@ $series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a vertical column rather than a horizontal bar graph -$series1->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_COL); +$series1->setPlotDirection(DataSeries::DIRECTION_COL); // Set the Data values for each data series we want to plot // Datatype @@ -83,13 +91,13 @@ $series1->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION // Data values // Data Marker $dataSeriesValues2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), ]; // Build the dataseries -$series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_LINECHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping +$series2 = new DataSeries( + DataSeries::TYPE_LINECHART, // plotType + DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2) - 1), // plotOrder $dataSeriesLabels2, // plotLabel null, // plotCategory @@ -104,13 +112,13 @@ $series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( // Data values // Data Marker $dataSeriesValues3 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), ]; // Build the dataseries -$series3 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_AREACHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping +$series3 = new DataSeries( + DataSeries::TYPE_AREACHART, // plotType + DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2) - 1), // plotOrder $dataSeriesLabels3, // plotLabel null, // plotCategory @@ -118,14 +126,14 @@ $series3 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series1, $series2, $series3]); +$plotArea = new PlotArea(null, [$series1, $series2, $series3]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Average Weather Chart for Crete'); +$title = new Title('Average Weather Chart for Crete'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -145,7 +153,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_line.php b/samples/33_Chart_create_line.php index 556f9530..b2d6e4f3 100644 --- a/samples/33_Chart_create_line.php +++ b/samples/33_Chart_create_line.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -35,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -45,15 +53,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_LINECHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STACKED, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_LINECHART, // plotType + DataSeries::GROUPING_STACKED, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -61,15 +69,15 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_TOPRIGHT, null, false); +$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Stacked Line Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Stacked Line Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -89,7 +97,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_multiple_charts.php b/samples/33_Chart_create_multiple_charts.php index d8ce1a20..fe20b76d 100644 --- a/samples/33_Chart_create_multiple_charts.php +++ b/samples/33_Chart_create_multiple_charts.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -35,7 +43,7 @@ $dataSeriesLabels1 = [ // Data values // Data Marker $xAxisTickValues1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -45,15 +53,15 @@ $xAxisTickValues1 = [ // Data values // Data Marker $dataSeriesValues1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_AREACHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping +$series1 = new DataSeries( + DataSeries::TYPE_AREACHART, // plotType + DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping range(0, count($dataSeriesValues1) - 1), // plotOrder $dataSeriesLabels1, // plotLabel $xAxisTickValues1, // plotCategory @@ -61,15 +69,15 @@ $series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set the series in the plot area -$plotArea1 = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series1]); +$plotArea1 = new PlotArea(null, [$series1]); // Set the chart legend -$legend1 = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_TOPRIGHT, null, false); +$legend1 = new Legend(Legend::POSITION_TOPRIGHT, null, false); -$title1 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test %age-Stacked Area Chart'); -$yAxisLabel1 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title1 = new Title('Test %age-Stacked Area Chart'); +$yAxisLabel1 = new Title('Value ($k)'); // Create the chart -$chart1 = new \PhpOffice\PhpSpreadsheet\Chart( +$chart1 = new Chart( 'chart1', // name $title1, // title $legend1, // legend @@ -95,9 +103,9 @@ $worksheet->addChart($chart1); // Data values // Data Marker $dataSeriesLabels2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -107,7 +115,7 @@ $dataSeriesLabels2 = [ // Data values // Data Marker $xAxisTickValues2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -117,15 +125,15 @@ $xAxisTickValues2 = [ // Data values // Data Marker $dataSeriesValues2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping +$series2 = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2) - 1), // plotOrder $dataSeriesLabels2, // plotLabel $xAxisTickValues2, // plotCategory @@ -133,18 +141,18 @@ $series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a vertical column rather than a horizontal bar graph -$series2->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_COL); +$series2->setPlotDirection(DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotArea2 = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series2]); +$plotArea2 = new PlotArea(null, [$series2]); // Set the chart legend -$legend2 = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend2 = new Legend(Legend::POSITION_RIGHT, null, false); -$title2 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Column Chart'); -$yAxisLabel2 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title2 = new Title('Test Column Chart'); +$yAxisLabel2 = new Title('Value ($k)'); // Create the chart -$chart2 = new \PhpOffice\PhpSpreadsheet\Chart( +$chart2 = new Chart( 'chart2', // name $title2, // title $legend2, // legend @@ -164,7 +172,7 @@ $worksheet->addChart($chart2); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_pie.php b/samples/33_Chart_create_pie.php index c8a23909..895e0429 100644 --- a/samples/33_Chart_create_pie.php +++ b/samples/33_Chart_create_pie.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,7 +31,7 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 ]; // Set the X-Axis Labels // Datatype @@ -33,7 +41,7 @@ $dataSeriesLabels1 = [ // Data values // Data Marker $xAxisTickValues1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -43,12 +51,12 @@ $xAxisTickValues1 = [ // Data values // Data Marker $dataSeriesValues1 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), ]; // Build the dataseries -$series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_PIECHART, // plotType +$series1 = new DataSeries( + DataSeries::TYPE_PIECHART, // plotType null, // plotGrouping (Pie charts don't have any grouping) range(0, count($dataSeriesValues1) - 1), // plotOrder $dataSeriesLabels1, // plotLabel @@ -57,19 +65,19 @@ $series1 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set up a layout object for the Pie chart -$layout1 = new \PhpOffice\PhpSpreadsheet\Chart\Layout(); +$layout1 = new Chart\Layout(); $layout1->setShowVal(true); $layout1->setShowPercent(true); // Set the series in the plot area -$plotArea1 = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea($layout1, [$series1]); +$plotArea1 = new PlotArea($layout1, [$series1]); // Set the chart legend -$legend1 = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend1 = new Legend(Legend::POSITION_RIGHT, null, false); -$title1 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Pie Chart'); +$title1 = new Title('Test Pie Chart'); // Create the chart -$chart1 = new \PhpOffice\PhpSpreadsheet\Chart( +$chart1 = new Chart( 'chart1', // name $title1, // title $legend1, // legend @@ -95,7 +103,7 @@ $worksheet->addChart($chart1); // Data values // Data Marker $dataSeriesLabels2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 ]; // Set the X-Axis Labels // Datatype @@ -105,7 +113,7 @@ $dataSeriesLabels2 = [ // Data values // Data Marker $xAxisTickValues2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -115,12 +123,12 @@ $xAxisTickValues2 = [ // Data values // Data Marker $dataSeriesValues2 = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), ]; // Build the dataseries -$series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_DONUTCHART, // plotType +$series2 = new DataSeries( + DataSeries::TYPE_DONUTCHART, // plotType null, // plotGrouping (Donut charts don't have any grouping) range(0, count($dataSeriesValues2) - 1), // plotOrder $dataSeriesLabels2, // plotLabel @@ -129,17 +137,17 @@ $series2 = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set up a layout object for the Pie chart -$layout2 = new \PhpOffice\PhpSpreadsheet\Chart\Layout(); +$layout2 = new Chart\Layout(); $layout2->setShowVal(true); $layout2->setShowCatName(true); // Set the series in the plot area -$plotArea2 = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea($layout2, [$series2]); +$plotArea2 = new PlotArea($layout2, [$series2]); -$title2 = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Donut Chart'); +$title2 = new Title('Test Donut Chart'); // Create the chart -$chart2 = new \PhpOffice\PhpSpreadsheet\Chart( +$chart2 = new Chart( 'chart2', // name $title2, // title null, // legend @@ -159,7 +167,7 @@ $worksheet->addChart($chart2); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_radar.php b/samples/33_Chart_create_radar.php index 2a978792..df81f38c 100644 --- a/samples/33_Chart_create_radar.php +++ b/samples/33_Chart_create_radar.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -31,8 +39,8 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -42,8 +50,8 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,13 +61,13 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_RADARCHART, // plotType +$series = new DataSeries( + DataSeries::TYPE_RADARCHART, // plotType null, // plotGrouping (Radar charts don't have any grouping) range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel @@ -67,21 +75,21 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( $dataSeriesValues, // plotValues null, // plotDirection null, // smooth line - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::STYLE_MARKER // plotStyle + DataSeries::STYLE_MARKER // plotStyle ); // Set up a layout object for the Pie chart -$layout = new \PhpOffice\PhpSpreadsheet\Chart\Layout(); +$layout = new Chart\Layout(); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea($layout, [$series]); +$plotArea = new PlotArea($layout, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Radar Chart'); +$title = new Title('Test Radar Chart'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -101,7 +109,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_scatter.php b/samples/33_Chart_create_scatter.php index 205113ab..df5564d7 100644 --- a/samples/33_Chart_create_scatter.php +++ b/samples/33_Chart_create_scatter.php @@ -1,9 +1,17 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -23,13 +31,13 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -39,14 +47,14 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_SCATTERCHART, // plotType +$series = new DataSeries( + DataSeries::TYPE_SCATTERCHART, // plotType null, // plotGrouping (Scatter charts don't have any grouping) range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel @@ -54,19 +62,19 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( $dataSeriesValues, // plotValues null, // plotDirection null, // smooth line - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::STYLE_LINEMARKER // plotStyle + DataSeries::STYLE_LINEMARKER // plotStyle ); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_TOPRIGHT, null, false); +$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Scatter Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Scatter Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend @@ -86,7 +94,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_stock.php b/samples/33_Chart_create_stock.php index eea2a430..78d16e3f 100644 --- a/samples/33_Chart_create_stock.php +++ b/samples/33_Chart_create_stock.php @@ -1,9 +1,18 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -18,7 +27,7 @@ $worksheet->fromArray( 'A1', true ); -$worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_00); +$worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER_00); // Set the Labels for each data series we want to plot // Datatype @@ -28,10 +37,10 @@ $worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSp // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), //Max / Open - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), //Min / Close - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), //Min Threshold / Min - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$E$1', null, 1), //Max Threshold / Max + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), //Max / Open + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), //Min / Close + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), //Min Threshold / Min + new DataSeriesValues('String', 'Worksheet!$E$1', null, 1), //Max Threshold / Max ]; // Set the X-Axis Labels // Datatype @@ -41,7 +50,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$6', null, 5), // Counts + new DataSeriesValues('String', 'Worksheet!$A$2:$A$6', null, 5), // Counts ]; // Set the Data values for each data series we want to plot // Datatype @@ -51,15 +60,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$6', null, 5), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$6', null, 5), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$6', null, 5), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$E$2:$E$6', null, 5), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$6', null, 5), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$6', null, 5), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$6', null, 5), + new DataSeriesValues('Number', 'Worksheet!$E$2:$E$6', null, 5), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_STOCKCHART, // plotType +$series = new DataSeries( + DataSeries::TYPE_STOCKCHART, // plotType null, // plotGrouping - if we set this to not null, then xlsx throws error range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel @@ -68,16 +77,16 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Stock Chart'); -$xAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Counts'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Values'); +$title = new Title('Test Stock Chart'); +$xAxisLabel = new Title('Counts'); +$yAxisLabel = new Title('Values'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'stock-chart', // name $title, // title $legend, // legend @@ -97,7 +106,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/34_Chart_update.php b/samples/34_Chart_update.php index 0a3c6e5a..bed5241d 100644 --- a/samples/34_Chart_update.php +++ b/samples/34_Chart_update.php @@ -1,16 +1,18 @@ getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); +$writer = new Xlsx($sampleSpreadsheet); $writer->save($filename); $helper->log('Load from Xlsx file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); +$reader = IOFactory::createReader('Xlsx'); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($filename); @@ -29,7 +31,7 @@ $worksheet->fromArray( // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); +$writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/35_Chart_render.php b/samples/35_Chart_render.php index b472f206..a63b28ef 100644 --- a/samples/35_Chart_render.php +++ b/samples/35_Chart_render.php @@ -1,14 +1,17 @@ log('NOTICE: Please set the $rendererName and $rendererLibraryPath values at the top of this script as appropriate for your directory structure'); return; @@ -35,7 +38,7 @@ foreach ($inputFileNames as $inputFileName) { $helper->log("Load Test from $inputFileType file ", $inputFileNameShort); - $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); + $reader = IOFactory::createReader($inputFileType); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($inputFileName); diff --git a/samples/37_Page_layout_view.php b/samples/37_Page_layout_view.php index 42cc1beb..2cdb3e12 100644 --- a/samples/37_Page_layout_view.php +++ b/samples/37_Page_layout_view.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -23,7 +26,7 @@ $spreadsheet->setActiveSheetIndex(0) ->setCellValue('B2', 'world!'); // Set the page layout view as page layout -$spreadsheet->getActiveSheet()->getSheetView()->setView(\PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT); +$spreadsheet->getActiveSheet()->getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT); // Save $helper->write($spreadsheet, __FILE__); diff --git a/samples/38_Clone_worksheet.php b/samples/38_Clone_worksheet.php index aa555c39..b55b9025 100644 --- a/samples/38_Clone_worksheet.php +++ b/samples/38_Clone_worksheet.php @@ -1,10 +1,12 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); diff --git a/samples/39_Dropdown.php b/samples/39_Dropdown.php index d4c0306e..bb68c3e9 100644 --- a/samples/39_Dropdown.php +++ b/samples/39_Dropdown.php @@ -1,10 +1,14 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -39,7 +43,7 @@ foreach ($continents as $key => $filename) { $spreadsheet->getActiveSheet() ->fromArray($countries, null, $column . '1'); $spreadsheet->addNamedRange( - new \PhpOffice\PhpSpreadsheet\NamedRange( + new NamedRange( $continent, $spreadsheet->getActiveSheet(), $column . '1:' . $column . $countryCount @@ -61,7 +65,7 @@ $spreadsheet->getActiveSheet() ->setVisible(false); $spreadsheet->addNamedRange( - new \PhpOffice\PhpSpreadsheet\NamedRange( + new NamedRange( 'Continents', $spreadsheet->getActiveSheet(), $continentColumn . '1:' . $continentColumn . count($continents) @@ -85,8 +89,8 @@ $spreadsheet->getActiveSheet() $validation = $spreadsheet->getActiveSheet() ->getCell('B1') ->getDataValidation(); -$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST) - ->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION) +$validation->setType(DataValidation::TYPE_LIST) + ->setErrorStyle(DataValidation::STYLE_INFORMATION) ->setAllowBlank(false) ->setShowInputMessage(true) ->setShowErrorMessage(true) @@ -106,8 +110,8 @@ $spreadsheet->getActiveSheet() $validation = $spreadsheet->getActiveSheet() ->getCell('B3') ->getDataValidation(); -$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST) - ->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION) +$validation->setType(DataValidation::TYPE_LIST) + ->setErrorStyle(DataValidation::STYLE_INFORMATION) ->setAllowBlank(false) ->setShowInputMessage(true) ->setShowErrorMessage(true) diff --git a/samples/40_Duplicate_style.php b/samples/40_Duplicate_style.php index dca84817..4a006f90 100644 --- a/samples/40_Duplicate_style.php +++ b/samples/40_Duplicate_style.php @@ -1,15 +1,19 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $helper->log('Create styles array'); $styles = []; for ($i = 0; $i < 10; ++$i) { - $style = new \PhpOffice\PhpSpreadsheet\Style(); + $style = new Style(); $style->getFont()->setSize($i + 4); $styles[] = $style; } @@ -20,7 +24,7 @@ for ($col = 0; $col < 50; ++$col) { for ($row = 0; $row < 100; ++$row) { $str = ($row + $col); $style = $styles[$row % 10]; - $coord = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col) . ($row + 1); + $coord = Cell::stringFromColumnIndex($col) . ($row + 1); $worksheet->setCellValue($coord, $str); $worksheet->duplicateStyle($style, $coord); } diff --git a/samples/42_RichText.php b/samples/42_RichText.php index 53b1c573..88db805c 100644 --- a/samples/42_RichText.php +++ b/samples/42_RichText.php @@ -1,10 +1,13 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -48,7 +51,7 @@ $html4 = 'H2SO4 is the chemical formula for Sulphuric acid $html5 = 'bold, italic, bold+italic'; -$wizard = new \PhpOffice\PhpSpreadsheet\Helper\Html(); +$wizard = new HtmlHelper(); $richText = $wizard->toRichTextObject($html1); $spreadsheet->getActiveSheet() diff --git a/samples/43_Merge_workbooks.php b/samples/43_Merge_workbooks.php index 6173a2d5..57721a4a 100644 --- a/samples/43_Merge_workbooks.php +++ b/samples/43_Merge_workbooks.php @@ -1,17 +1,19 @@ log('Load MergeBook1 from Xlsx file'); $filename1 = __DIR__ . '/templates/43mergeBook1.xlsx'; $callStartTime = microtime(true); -$spreadsheet1 = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename1); +$spreadsheet1 = IOFactory::load($filename1); $helper->logRead('Xlsx', $filename1, $callStartTime); $helper->log('Load MergeBook2 from Xlsx file'); $filename2 = __DIR__ . '/templates/43mergeBook2.xlsx'; $callStartTime = microtime(true); -$spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename2); +$spreadsheet2 = IOFactory::load($filename2); $helper->logRead('Xlsx', $filename2, $callStartTime); foreach ($spreadsheet2->getSheetNames() as $sheetName) { diff --git a/samples/44_Worksheet_info.php b/samples/44_Worksheet_info.php index 71849ca4..cacb9ae6 100644 --- a/samples/44_Worksheet_info.php +++ b/samples/44_Worksheet_info.php @@ -1,15 +1,18 @@ getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); +$writer = new Xlsx($sampleSpreadsheet); $writer->save($filename); -$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($filename); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); +$inputFileType = IOFactory::identify($filename); +$reader = IOFactory::createReader($inputFileType); $sheetList = $reader->listWorksheetNames($filename); $sheetInfo = $reader->listWorksheetInfo($filename); diff --git a/samples/45_Quadratic_equation_solver.php b/samples/45_Quadratic_equation_solver.php index f5e11e47..39f6685d 100644 --- a/samples/45_Quadratic_equation_solver.php +++ b/samples/45_Quadratic_equation_solver.php @@ -1,4 +1,6 @@
@@ -28,13 +30,13 @@ if (isset($_POST['submit'])) { echo '
Roots:
'; $discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')'; - $discriminant = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($discriminantFormula); + $discriminant = Calculation::getInstance()->calculateFormula($discriminantFormula); $r1Formula = '=IMDIV(IMSUM(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . ')'; $r2Formula = '=IF(' . $discriminant . '=0,"Only one root",IMDIV(IMSUB(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . '))'; - echo \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($r1Formula) . '
'; - echo \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($r2Formula) . '
'; + echo Calculation::getInstance()->calculateFormula($r1Formula) . '
'; + echo Calculation::getInstance()->calculateFormula($r2Formula) . '
'; $callEndTime = microtime(true); $helper->logEndingNotes(); } diff --git a/samples/Header.php b/samples/Header.php index b406ba1b..e9ada9f7 100644 --- a/samples/Header.php +++ b/samples/Header.php @@ -2,11 +2,13 @@ /** * Header file. */ +use PhpOffice\PhpSpreadsheet\Helper\Sample; + error_reporting(E_ALL); require_once __DIR__ . '/../src/Bootstrap.php'; -$helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample(); +$helper = new Sample(); if (!defined('EOL')) { define('EOL', $helper->isCli() ? PHP_EOL : '
'); } diff --git a/samples/templates/chartSpreadsheet.php b/samples/templates/chartSpreadsheet.php index f6fb8b00..c462f533 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -1,6 +1,14 @@ getActiveSheet(); $worksheet->fromArray( [ @@ -20,9 +28,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -32,7 +40,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -42,15 +50,15 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries -$series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_BARCHART, // plotType - \PhpOffice\PhpSpreadsheet\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping +$series = new DataSeries( + DataSeries::TYPE_BARCHART, // plotType + DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues) - 1), // plotOrder $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory @@ -58,18 +66,18 @@ $series = new \PhpOffice\PhpSpreadsheet\Chart\DataSeries( ); // Set additional dataseries parameters // Make it a horizontal bar rather than a vertical column graph -$series->setPlotDirection(\PhpOffice\PhpSpreadsheet\Chart\DataSeries::DIRECTION_BAR); +$series->setPlotDirection(DataSeries::DIRECTION_BAR); // Set the series in the plot area -$plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]); +$plotArea = new PlotArea(null, [$series]); // Set the chart legend -$legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend(\PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false); +$legend = new Legend(Legend::POSITION_RIGHT, null, false); -$title = new \PhpOffice\PhpSpreadsheet\Chart\Title('Test Bar Chart'); -$yAxisLabel = new \PhpOffice\PhpSpreadsheet\Chart\Title('Value ($k)'); +$title = new Title('Test Bar Chart'); +$yAxisLabel = new Title('Value ($k)'); // Create the chart -$chart = new \PhpOffice\PhpSpreadsheet\Chart( +$chart = new Chart( 'chart1', // name $title, // title $legend, // legend diff --git a/samples/templates/largeSpreadsheet.php b/samples/templates/largeSpreadsheet.php index 76ecb5d0..2205bf6f 100644 --- a/samples/templates/largeSpreadsheet.php +++ b/samples/templates/largeSpreadsheet.php @@ -1,8 +1,10 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set properties'); diff --git a/samples/templates/sampleSpreadsheet.php b/samples/templates/sampleSpreadsheet.php index 67bd9fd9..0ab6ebc1 100644 --- a/samples/templates/sampleSpreadsheet.php +++ b/samples/templates/sampleSpreadsheet.php @@ -1,8 +1,21 @@ log('Create new Spreadsheet object'); -$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); +$spreadsheet = new Spreadsheet(); // Set document properties $helper->log('Set document properties'); @@ -18,8 +31,8 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw') $helper->log('Add some data'); $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->setCellValue('B1', 'Invoice'); -$spreadsheet->getActiveSheet()->setCellValue('D1', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y')))); -$spreadsheet->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX15); +$spreadsheet->getActiveSheet()->setCellValue('D1', Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y')))); +$spreadsheet->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_XLSX15); $spreadsheet->getActiveSheet()->setCellValue('E1', '#12566'); $spreadsheet->getActiveSheet()->setCellValue('A3', 'Product Id'); @@ -81,13 +94,13 @@ $spreadsheet->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEE // Add rich-text string $helper->log('Add rich-text string'); -$richText = new \PhpOffice\PhpSpreadsheet\RichText(); +$richText = new RichText(); $richText->createText('This invoice is '); $payable = $richText->createTextRun('payable within thirty days after the end of the month'); $payable->getFont()->setBold(true); $payable->getFont()->setItalic(true); -$payable->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN)); +$payable->getFont()->setColor(new Color(Color::COLOR_DARKGREEN)); $richText->createText(', unless specified otherwise on the invoice.'); @@ -105,7 +118,7 @@ $spreadsheet->getActiveSheet()->protectCells('A3:E13', 'PhpSpreadsheet'); // Set cell number formats $helper->log('Set cell number formats'); -$spreadsheet->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); +$spreadsheet->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); // Set column widths $helper->log('Set column widths'); @@ -118,23 +131,23 @@ $helper->log('Set fonts'); $spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara'); $spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); $spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); -$spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); -$spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE); +$spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(Font::UNDERLINE_SINGLE); +$spreadsheet->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(Color::COLOR_WHITE); -$spreadsheet->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE); -$spreadsheet->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE); +$spreadsheet->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(Color::COLOR_WHITE); +$spreadsheet->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(Color::COLOR_WHITE); $spreadsheet->getActiveSheet()->getStyle('D13')->getFont()->setBold(true); $spreadsheet->getActiveSheet()->getStyle('E13')->getFont()->setBold(true); // Set alignments $helper->log('Set alignments'); -$spreadsheet->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); -$spreadsheet->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); -$spreadsheet->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); +$spreadsheet->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); +$spreadsheet->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); +$spreadsheet->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); -$spreadsheet->getActiveSheet()->getStyle('A18')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY); -$spreadsheet->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); +$spreadsheet->getActiveSheet()->getStyle('A18')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_JUSTIFY); +$spreadsheet->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); $spreadsheet->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true); @@ -143,7 +156,7 @@ $helper->log('Set thin black border outline around column'); $styleThinBlackBorderOutline = [ 'borders' => [ 'outline' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'style' => Border::BORDER_THIN, 'color' => ['argb' => 'FF000000'], ], ], @@ -155,7 +168,7 @@ $helper->log('Set thick brown border outline around Total'); $styleThickBrownBorderOutline = [ 'borders' => [ 'outline' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK, + 'style' => Border::BORDER_THICK, 'color' => ['argb' => 'FF993300'], ], ], @@ -164,7 +177,7 @@ $spreadsheet->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickB // Set fills $helper->log('Set fills'); -$spreadsheet->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID); +$spreadsheet->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(Fill::FILL_SOLID); $spreadsheet->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080'); // Set style for header row using alternative method @@ -175,15 +188,15 @@ $spreadsheet->getActiveSheet()->getStyle('A3:E3')->applyFromArray( 'bold' => true, ], 'alignment' => [ - 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT, + 'horizontal' => Alignment::HORIZONTAL_RIGHT, ], 'borders' => [ 'top' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'style' => Border::BORDER_THIN, ], ], 'fill' => [ - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR, + 'type' => Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => [ 'argb' => 'FFA0A0A0', @@ -198,11 +211,11 @@ $spreadsheet->getActiveSheet()->getStyle('A3:E3')->applyFromArray( $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray( [ 'alignment' => [ - 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT, + 'horizontal' => Alignment::HORIZONTAL_LEFT, ], 'borders' => [ 'left' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'style' => Border::BORDER_THIN, ], ], ] @@ -211,7 +224,7 @@ $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray( $spreadsheet->getActiveSheet()->getStyle('B3')->applyFromArray( [ 'alignment' => [ - 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT, + 'horizontal' => Alignment::HORIZONTAL_LEFT, ], ] ); @@ -220,7 +233,7 @@ $spreadsheet->getActiveSheet()->getStyle('E3')->applyFromArray( [ 'borders' => [ 'right' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'style' => Border::BORDER_THIN, ], ], ] @@ -228,24 +241,24 @@ $spreadsheet->getActiveSheet()->getStyle('E3')->applyFromArray( // Unprotect a cell $helper->log('Unprotect a cell'); -$spreadsheet->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED); +$spreadsheet->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(Protection::PROTECTION_UNPROTECTED); // Add a hyperlink to the sheet $helper->log('Add a hyperlink to an external website'); $spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); -$spreadsheet->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); +$spreadsheet->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); $helper->log('Add a hyperlink to another cell on a different worksheet within the workbook'); $spreadsheet->getActiveSheet()->setCellValue('E27', 'Terms and conditions'); $spreadsheet->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1"); $spreadsheet->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions'); -$spreadsheet->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); +$spreadsheet->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); // Add a drawing to the worksheet $helper->log('Add a drawing to the worksheet'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); +$drawing = new Drawing(); $drawing->setName('Logo'); $drawing->setDescription('Logo'); $drawing->setPath(__DIR__ . '/../images/officelogo.jpg'); @@ -254,7 +267,7 @@ $drawing->setWorksheet($spreadsheet->getActiveSheet()); // Add a drawing to the worksheet $helper->log('Add a drawing to the worksheet'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); +$drawing = new Drawing(); $drawing->setName('Paid'); $drawing->setDescription('Paid'); $drawing->setPath(__DIR__ . '/../images/paid.png'); @@ -267,7 +280,7 @@ $drawing->setWorksheet($spreadsheet->getActiveSheet()); // Add a drawing to the worksheet $helper->log('Add a drawing to the worksheet'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); +$drawing = new Drawing(); $drawing->setName('PhpSpreadsheet logo'); $drawing->setDescription('PhpSpreadsheet logo'); $drawing->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png'); @@ -290,8 +303,8 @@ $spreadsheet->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $spread // Set page orientation and size $helper->log('Set page orientation and size'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT); -$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT); +$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(PageSetup::PAPERSIZE_A4); // Rename first worksheet $helper->log('Rename first worksheet'); @@ -330,13 +343,13 @@ $helper->log('Set fonts'); $spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara'); $spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setSize(20); $spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); -$spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); +$spreadsheet->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(Font::UNDERLINE_SINGLE); $spreadsheet->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8); // Add a drawing to the worksheet $helper->log('Add a drawing to the worksheet'); -$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); +$drawing = new Drawing(); $drawing->setName('Terms and conditions'); $drawing->setDescription('Terms and conditions'); $drawing->setPath(__DIR__ . '/../images/termsconditions.jpg'); @@ -345,8 +358,8 @@ $drawing->setWorksheet($spreadsheet->getActiveSheet()); // Set page orientation and size $helper->log('Set page orientation and size'); -$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); -$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4); +$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); +$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(PageSetup::PAPERSIZE_A4); // Rename second worksheet $helper->log('Rename second worksheet'); diff --git a/src/Bootstrap.php b/src/Bootstrap.php index b7062b5a..455999fc 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -26,6 +26,7 @@ */ // This sucks, but we have to try to find the composer autoloader + $paths = [ __DIR__ . '/../vendor/autoload.php', // In case PhpSpreadsheet is cloned directly __DIR__ . '/../../../autoload.php', // In case PhpSpreadsheet is a composer dependency. diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index 46414a4a..684070ab 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -2066,7 +2066,7 @@ class Calculation } if (!isset(self::$instance) || (self::$instance === null)) { - self::$instance = new \PhpOffice\PhpSpreadsheet\Calculation(); + self::$instance = new self(); } return self::$instance; @@ -2084,7 +2084,7 @@ class Calculation /** * Flush the calculation cache for any existing instance of this class - * but only if a \PhpOffice\PhpSpreadsheet\Calculation instance exists. + * but only if a Calculation instance exists. */ public function flushInstance() { diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 72e2a88e..b490dc00 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -116,12 +118,12 @@ class Database $k = array_search($criteriaName, $fieldNames); if (isset($dataValues[$k])) { $dataValue = $dataValues[$k]; - $dataValue = (is_string($dataValue)) ? \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($dataValue)) : $dataValue; + $dataValue = (is_string($dataValue)) ? Calculation::wrapResult(strtoupper($dataValue)) : $dataValue; $testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList); } } // evaluate the criteria against the row data - $result = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue('=' . $testConditionList); + $result = Calculation::getInstance()->_calculateFormulaValue('=' . $testConditionList); // If the row failed to meet the criteria, remove it from the database if (!$result) { unset($database[$dataRow]); diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 782b0828..d8a1d000 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -90,7 +93,7 @@ class DateTime return Functions::VALUE(); } if ((is_object($dateValue)) && ($dateValue instanceof \DateTime)) { - $dateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateValue); + $dateValue = Date::PHPToExcel($dateValue); } else { $saveReturnDateType = Functions::getReturnDateType(); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); @@ -122,7 +125,7 @@ class DateTime private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) { // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); $oMonth = (int) $PHPDateObject->format('m'); $oYear = (int) $PHPDateObject->format('Y'); @@ -172,7 +175,7 @@ class DateTime $retValue = false; switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: - $retValue = (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time()); + $retValue = (float) Date::PHPToExcel(time()); break; case Functions::RETURNDATE_PHP_NUMERIC: $retValue = (int) time(); @@ -210,16 +213,16 @@ class DateTime $saveTimeZone = date_default_timezone_get(); date_default_timezone_set('UTC'); $retValue = false; - $excelDateTime = floor(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time())); + $excelDateTime = floor(Date::PHPToExcel(time())); switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: $retValue = (float) $excelDateTime; break; case Functions::RETURNDATE_PHP_NUMERIC: - $retValue = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateTime); + $retValue = (int) Date::excelToTimestamp($excelDateTime); break; case Functions::RETURNDATE_PHP_OBJECT: - $retValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateTime); + $retValue = Date::excelToDateTimeObject($excelDateTime); break; } date_default_timezone_set($saveTimeZone); @@ -285,16 +288,16 @@ class DateTime $day = Functions::flattenSingleValue($day); if (($month !== null) && (!is_numeric($month))) { - $month = \PhpOffice\PhpSpreadsheet\Shared\Date::monthStringToNumber($month); + $month = Date::monthStringToNumber($month); } if (($day !== null) && (!is_numeric($day))) { - $day = \PhpOffice\PhpSpreadsheet\Shared\Date::dayStringToNumber($day); + $day = Date::dayStringToNumber($day); } - $year = ($year !== null) ? \PhpOffice\PhpSpreadsheet\Shared\StringHelper::testStringAsNumeric($year) : 0; - $month = ($month !== null) ? \PhpOffice\PhpSpreadsheet\Shared\StringHelper::testStringAsNumeric($month) : 0; - $day = ($day !== null) ? \PhpOffice\PhpSpreadsheet\Shared\StringHelper::testStringAsNumeric($day) : 0; + $year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0; + $month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0; + $day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0; if ((!is_numeric($year)) || (!is_numeric($month)) || (!is_numeric($day))) { @@ -304,7 +307,7 @@ class DateTime $month = (int) $month; $day = (int) $day; - $baseYear = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); + $baseYear = Date::getExcelCalendar(); // Validate parameters if ($year < ($baseYear - 1900)) { return Functions::NAN(); @@ -334,14 +337,14 @@ class DateTime } // Execute function - $excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($year, $month, $day); + $excelDateValue = Date::formattedPHPToExcel($year, $month, $day); switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: return (float) $excelDateValue; case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue); + return (int) Date::excelToTimestamp($excelDateValue); case Functions::RETURNDATE_PHP_OBJECT: - return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDateValue); + return Date::excelToDateTimeObject($excelDateValue); } } @@ -427,14 +430,14 @@ class DateTime switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: $date = 0; - $calendar = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); - if ($calendar != \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900) { + $calendar = Date::getExcelCalendar(); + if ($calendar != Date::CALENDAR_WINDOWS_1900) { $date = 1; } - return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); + return (float) Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 + return (int) Date::excelToTimestamp(Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 case Functions::RETURNDATE_PHP_OBJECT: $dayAdjust = 0; if ($hour < 0) { @@ -570,7 +573,7 @@ class DateTime return Functions::VALUE(); } $excelDateValue = floor( - \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + Date::formattedPHPToExcel( $PHPDateArray['year'], $PHPDateArray['month'], $PHPDateArray['day'], @@ -583,7 +586,7 @@ class DateTime case Functions::RETURNDATE_EXCEL: return (float) $excelDateValue; case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue); + return (int) Date::excelToTimestamp($excelDateValue); case Functions::RETURNDATE_PHP_OBJECT: return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00'); } @@ -629,7 +632,7 @@ class DateTime $PHPDateArray = date_parse($timeValue); if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { - $excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + $excelDateValue = Date::formattedPHPToExcel( $PHPDateArray['year'], $PHPDateArray['month'], $PHPDateArray['day'], @@ -638,14 +641,14 @@ class DateTime $PHPDateArray['second'] ); } else { - $excelDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1; + $excelDateValue = Date::formattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1; } switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: return (float) $excelDateValue; case Functions::RETURNDATE_PHP_NUMERIC: - return (int) $phpDateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDateValue + 25569) - 3600; + return (int) $phpDateValue = Date::excelToTimestamp($excelDateValue + 25569) - 3600; case Functions::RETURNDATE_PHP_OBJECT: return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']); } @@ -686,12 +689,12 @@ class DateTime // Execute function $difference = $endDate - $startDate; - $PHPStartDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($startDate); + $PHPStartDateObject = Date::excelToDateTimeObject($startDate); $startDays = $PHPStartDateObject->format('j'); $startMonths = $PHPStartDateObject->format('n'); $startYears = $PHPStartDateObject->format('Y'); - $PHPEndDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($endDate); + $PHPEndDateObject = Date::excelToDateTimeObject($endDate); $endDays = $PHPEndDateObject->format('j'); $endMonths = $PHPEndDateObject->format('n'); $endYears = $PHPEndDateObject->format('Y'); @@ -818,12 +821,12 @@ class DateTime } // Execute function - $PHPStartDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($startDate); + $PHPStartDateObject = Date::excelToDateTimeObject($startDate); $startDay = $PHPStartDateObject->format('j'); $startMonth = $PHPStartDateObject->format('n'); $startYear = $PHPStartDateObject->format('Y'); - $PHPEndDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($endDate); + $PHPEndDateObject = Date::excelToDateTimeObject($endDate); $endDay = $PHPEndDateObject->format('j'); $endMonth = $PHPEndDateObject->format('n'); $endYear = $PHPEndDateObject->format('Y'); @@ -1116,9 +1119,9 @@ class DateTime case Functions::RETURNDATE_EXCEL: return (float) $endDate; case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($endDate); + return (int) Date::excelToTimestamp($endDate); case Functions::RETURNDATE_PHP_OBJECT: - return \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($endDate); + return Date::excelToDateTimeObject($endDate); } } @@ -1151,7 +1154,7 @@ class DateTime } // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); return (int) $PHPDateObject->format('j'); } @@ -1195,7 +1198,7 @@ class DateTime } // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); $DoW = $PHPDateObject->format('w'); $firstDay = 1; @@ -1271,7 +1274,7 @@ class DateTime } // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); $dayOfYear = $PHPDateObject->format('z'); $PHPDateObject->modify('-' . $dayOfYear . ' days'); $firstDayOfFirstWeek = $PHPDateObject->format('w'); @@ -1314,7 +1317,7 @@ class DateTime } // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); return (int) $PHPDateObject->format('n'); } @@ -1346,7 +1349,7 @@ class DateTime } // Execute function - $PHPDateObject = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateValue); + $PHPDateObject = Date::excelToDateTimeObject($dateValue); return (int) $PHPDateObject->format('Y'); } @@ -1387,7 +1390,7 @@ class DateTime } elseif ($timeValue < 0.0) { return Functions::NAN(); } - $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); + $timeValue = Date::excelToTimestamp($timeValue); return (int) gmdate('G', $timeValue); } @@ -1428,7 +1431,7 @@ class DateTime } elseif ($timeValue < 0.0) { return Functions::NAN(); } - $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); + $timeValue = Date::excelToTimestamp($timeValue); return (int) gmdate('i', $timeValue); } @@ -1469,7 +1472,7 @@ class DateTime } elseif ($timeValue < 0.0) { return Functions::NAN(); } - $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue); + $timeValue = Date::excelToTimestamp($timeValue); return (int) gmdate('s', $timeValue); } @@ -1513,9 +1516,9 @@ class DateTime switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: - return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject); + return (float) Date::PHPToExcel($PHPDateObject); case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject)); + return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject)); case Functions::RETURNDATE_PHP_OBJECT: return $PHPDateObject; } @@ -1562,9 +1565,9 @@ class DateTime switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: - return (float) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject); + return (float) Date::PHPToExcel($PHPDateObject); case Functions::RETURNDATE_PHP_NUMERIC: - return (int) \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDateObject)); + return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject)); case Functions::RETURNDATE_PHP_OBJECT: return $PHPDateObject; } diff --git a/src/PhpSpreadsheet/Calculation/Exception.php b/src/PhpSpreadsheet/Calculation/Exception.php index 6a9711fc..fa1b91c6 100644 --- a/src/PhpSpreadsheet/Calculation/Exception.php +++ b/src/PhpSpreadsheet/Calculation/Exception.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +26,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Exception extends \PhpOffice\PhpSpreadsheet\Exception +class Exception extends PhpSpreadsheetException { /** * Error handler callback. diff --git a/src/PhpSpreadsheet/Calculation/ExceptionHandler.php b/src/PhpSpreadsheet/Calculation/ExceptionHandler.php index a8b82405..fd2233c9 100644 --- a/src/PhpSpreadsheet/Calculation/ExceptionHandler.php +++ b/src/PhpSpreadsheet/Calculation/ExceptionHandler.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -31,7 +33,7 @@ class ExceptionHandler */ public function __construct() { - set_error_handler([\PhpOffice\PhpSpreadsheet\Calculation\Exception::class, 'errorHandlerCallback'], E_ALL); + set_error_handler([CalculationException::class, 'errorHandlerCallback'], E_ALL); } /** diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 4c80a684..305494be 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -3,6 +3,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; /* FINANCIAL_MAX_ITERATIONS */ +use PhpOffice\PhpSpreadsheet\Shared\Date; + define('FINANCIAL_MAX_ITERATIONS', 128); /* FINANCIAL_PRECISION */ @@ -64,10 +66,10 @@ class Financial { $months = 12 / $frequency; - $result = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($maturity); + $result = Date::excelToDateTimeObject($maturity); $eom = self::isLastDayOfMonth($result); - while ($settlement < \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($result)) { + while ($settlement < Date::PHPToExcel($result)) { $result->modify('-' . $months . ' months'); } if ($next) { @@ -78,7 +80,7 @@ class Financial $result->modify('-1 day'); } - return \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($result); + return Date::PHPToExcel($result); } private static function isValidFrequency($frequency) diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 88346ed0..b13e987d 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -3,6 +3,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; /* MAX_VALUE */ +use PhpOffice\PhpSpreadsheet\Calculation; + define('MAX_VALUE', 1.2e308); /* 2 / PI */ @@ -298,7 +300,7 @@ class Functions } if (!in_array($condition[0], ['>', '<', '='])) { if (!is_numeric($condition)) { - $condition = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($condition)); + $condition = Calculation::wrapResult(strtoupper($condition)); } return '=' . $condition; @@ -308,7 +310,7 @@ class Functions if (!is_numeric($operand)) { $operand = str_replace('"', '""', $operand); - $operand = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($operand)); + $operand = Calculation::wrapResult(strtoupper($operand)); } return $operator . $operand; diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 25bacafc..5492cc6e 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -98,9 +100,9 @@ class Logical $returnValue = $returnValue && ($arg != 0); } elseif (is_string($arg)) { $arg = strtoupper($arg); - if (($arg == 'TRUE') || ($arg == \PhpOffice\PhpSpreadsheet\Calculation::getTRUE())) { + if (($arg == 'TRUE') || ($arg == Calculation::getTRUE())) { $arg = true; - } elseif (($arg == 'FALSE') || ($arg == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE())) { + } elseif (($arg == 'FALSE') || ($arg == Calculation::getFALSE())) { $arg = false; } else { return Functions::VALUE(); @@ -155,9 +157,9 @@ class Logical $returnValue = $returnValue || ($arg != 0); } elseif (is_string($arg)) { $arg = strtoupper($arg); - if (($arg == 'TRUE') || ($arg == \PhpOffice\PhpSpreadsheet\Calculation::getTRUE())) { + if (($arg == 'TRUE') || ($arg == Calculation::getTRUE())) { $arg = true; - } elseif (($arg == 'FALSE') || ($arg == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE())) { + } elseif (($arg == 'FALSE') || ($arg == Calculation::getFALSE())) { $arg = false; } else { return Functions::VALUE(); @@ -200,9 +202,9 @@ class Logical $logical = Functions::flattenSingleValue($logical); if (is_string($logical)) { $logical = strtoupper($logical); - if (($logical == 'TRUE') || ($logical == \PhpOffice\PhpSpreadsheet\Calculation::getTRUE())) { + if (($logical == 'TRUE') || ($logical == Calculation::getTRUE())) { return false; - } elseif (($logical == 'FALSE') || ($logical == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE())) { + } elseif (($logical == 'FALSE') || ($logical == Calculation::getFALSE())) { return true; } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 8359b0ba..010aea93 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Cell; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -72,7 +75,7 @@ class LookupRef } if ((!is_bool($referenceStyle)) || $referenceStyle) { $rowRelative = $columnRelative = '$'; - $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column - 1); + $column = Cell::stringFromColumnIndex($column - 1); if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; } @@ -118,7 +121,7 @@ class LookupRef foreach ($cellAddress as $columnKey => $value) { $columnKey = preg_replace('/[^a-z]/i', '', $columnKey); - return (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnKey); + return (int) Cell::columnIndexFromString($columnKey); } } else { if (strpos($cellAddress, '!') !== false) { @@ -130,14 +133,14 @@ class LookupRef $endAddress = preg_replace('/[^a-z]/i', '', $endAddress); $returnValue = []; do { - $returnValue[] = (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startAddress); + $returnValue[] = (int) Cell::columnIndexFromString($startAddress); } while ($startAddress++ != $endAddress); return $returnValue; } $cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress); - return (int) \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($cellAddress); + return (int) Cell::columnIndexFromString($cellAddress); } } @@ -164,7 +167,7 @@ class LookupRef reset($cellAddress); $isMatrix = (is_numeric(key($cellAddress))); - list($columns, $rows) = \PhpOffice\PhpSpreadsheet\Calculation::_getMatrixDimensions($cellAddress); + list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress); if ($isMatrix) { return $rows; @@ -245,7 +248,7 @@ class LookupRef reset($cellAddress); $isMatrix = (is_numeric(key($cellAddress))); - list($columns, $rows) = \PhpOffice\PhpSpreadsheet\Calculation::_getMatrixDimensions($cellAddress); + list($columns, $rows) = Calculation::_getMatrixDimensions($cellAddress); if ($isMatrix) { return $columns; @@ -264,11 +267,11 @@ class LookupRef * * @param string $linkURL Value to check, is also the value returned when no error * @param string $displayName Value to return when testValue is an error condition - * @param \PhpOffice\PhpSpreadsheet\Cell $pCell The cell to set the hyperlink in + * @param Cell $pCell The cell to set the hyperlink in * * @return mixed The value of $displayName (or $linkURL if $displayName was blank) */ - public static function HYPERLINK($linkURL = '', $displayName = null, \PhpOffice\PhpSpreadsheet\Cell $pCell = null) + public static function HYPERLINK($linkURL = '', $displayName = null, Cell $pCell = null) { $linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL); $displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName); @@ -299,13 +302,13 @@ class LookupRef * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010 * * @param cellAddress $cellAddress The cell address of the current cell (containing this formula) - * @param \PhpOffice\PhpSpreadsheet\Cell $pCell The current cell (containing this formula) + * @param Cell $pCell The current cell (containing this formula) * * @return mixed The cells referenced by cellAddress * * @todo Support for the optional a1 parameter introduced in Excel 2010 */ - public static function INDIRECT($cellAddress = null, \PhpOffice\PhpSpreadsheet\Cell $pCell = null) + public static function INDIRECT($cellAddress = null, Cell $pCell = null) { $cellAddress = Functions::flattenSingleValue($cellAddress); if (is_null($cellAddress) || $cellAddress === '') { @@ -318,9 +321,9 @@ class LookupRef list($cellAddress1, $cellAddress2) = explode(':', $cellAddress); } - if ((!preg_match('/^' . \PhpOffice\PhpSpreadsheet\Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || - ((!is_null($cellAddress2)) && (!preg_match('/^' . \PhpOffice\PhpSpreadsheet\Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) { - if (!preg_match('/^' . \PhpOffice\PhpSpreadsheet\Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) { + if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || + ((!is_null($cellAddress2)) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) { + if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) { return Functions::REF(); } @@ -332,7 +335,7 @@ class LookupRef $pSheet = $pCell->getWorksheet(); } - return \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, false); + return Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, false); } if (strpos($cellAddress, '!') !== false) { @@ -343,7 +346,7 @@ class LookupRef $pSheet = $pCell->getWorksheet(); } - return \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false); + return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false); } /** @@ -374,11 +377,11 @@ class LookupRef * @param mixed $columns * @param null|mixed $height * @param null|mixed $width - * @param \PhpOffice\PhpSpreadsheet\Cell $pCell + * @param Cell $pCell * * @return string A reference to a cell or range of cells */ - public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, \PhpOffice\PhpSpreadsheet\Cell $pCell = null) + public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, Cell $pCell = null) { $rows = Functions::flattenSingleValue($rows); $columns = Functions::flattenSingleValue($columns); @@ -402,23 +405,23 @@ class LookupRef } else { $startCell = $endCell = $cellAddress; } - list($startCellColumn, $startCellRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($startCell); - list($endCellColumn, $endCellRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($endCell); + list($startCellColumn, $startCellRow) = Cell::coordinateFromString($startCell); + list($endCellColumn, $endCellRow) = Cell::coordinateFromString($endCell); $startCellRow += $rows; - $startCellColumn = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startCellColumn) - 1; + $startCellColumn = Cell::columnIndexFromString($startCellColumn) - 1; $startCellColumn += $columns; if (($startCellRow <= 0) || ($startCellColumn < 0)) { return Functions::REF(); } - $endCellColumn = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($endCellColumn) - 1; + $endCellColumn = Cell::columnIndexFromString($endCellColumn) - 1; if (($width != null) && (!is_object($width))) { $endCellColumn = $startCellColumn + $width - 1; } else { $endCellColumn += $columns; } - $startCellColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($startCellColumn); + $startCellColumn = Cell::stringFromColumnIndex($startCellColumn); if (($height != null) && (!is_object($height))) { $endCellRow = $startCellRow + $height - 1; @@ -429,7 +432,7 @@ class LookupRef if (($endCellRow <= 0) || ($endCellColumn < 0)) { return Functions::REF(); } - $endCellColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($endCellColumn); + $endCellColumn = Cell::stringFromColumnIndex($endCellColumn); $cellAddress = $startCellColumn . $startCellRow; if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) { @@ -442,7 +445,7 @@ class LookupRef $pSheet = $pCell->getWorksheet(); } - return \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false); + return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false); } /** diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 6ea7ba66..25200205 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -567,10 +571,10 @@ class MathTrig } try { - $matrix = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixData); + $matrix = new Matrix($matrixData); return $matrix->det(); - } catch (\PhpOffice\PhpSpreadsheet\Exception $ex) { + } catch (PhpSpreadsheetException $ex) { return Functions::VALUE(); } } @@ -621,10 +625,10 @@ class MathTrig } try { - $matrix = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixData); + $matrix = new Matrix($matrixData); return $matrix->inverse()->getArray(); - } catch (\PhpOffice\PhpSpreadsheet\Exception $ex) { + } catch (PhpSpreadsheetException $ex) { return Functions::VALUE(); } } @@ -663,7 +667,7 @@ class MathTrig } ++$rowA; } - $matrixA = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixAData); + $matrixA = new Matrix($matrixAData); $rowB = 0; foreach ($matrixData2 as $matrixRow) { if (!is_array($matrixRow)) { @@ -679,14 +683,14 @@ class MathTrig } ++$rowB; } - $matrixB = new \PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix($matrixBData); + $matrixB = new Matrix($matrixBData); if ($columnA != $rowB) { return Functions::VALUE(); } return $matrixA->times($matrixB)->getArray(); - } catch (\PhpOffice\PhpSpreadsheet\Exception $ex) { + } catch (PhpSpreadsheetException $ex) { return Functions::VALUE(); } } @@ -1231,11 +1235,11 @@ class MathTrig foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { $arg = str_replace('"', '""', $arg); - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria $returnValue += $sumArgs[$key]; } @@ -1280,10 +1284,10 @@ class MathTrig // Loop through arguments foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria $returnValue += $sumArgs[$key]; } diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 2f743e70..b379b1ba 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -3,6 +3,9 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; /* LOG_GAMMA_X_MAX_VALUE */ +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Shared\Trend\Trend; + define('LOG_GAMMA_X_MAX_VALUE', 2.55e305); /* XMININ */ @@ -883,10 +886,10 @@ class Statistical $aCount = 0; foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if ((is_null($returnValue)) || ($arg > $returnValue)) { $returnValue += $arg; ++$aCount; @@ -1194,7 +1197,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getCorrelation(); } @@ -1317,10 +1320,10 @@ class Statistical // Loop through arguments foreach ($aArgs as $arg) { if (!is_numeric($arg)) { - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria ++$returnValue; } @@ -1355,7 +1358,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getCovariance(); } @@ -1649,7 +1652,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getValueOfYForX($xValue); } @@ -1829,7 +1832,7 @@ class Statistical $newValues = Functions::flattenArray($newValues); $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); - $bestFitExponential = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); + $bestFitExponential = Trend::calculate(Trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); if (empty($newValues)) { $newValues = $bestFitExponential->getXValues(); } @@ -1956,7 +1959,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getIntersect(); } @@ -2084,7 +2087,7 @@ class Statistical return 0; } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues, $const); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues, $const); if ($stats) { return [ [ @@ -2153,7 +2156,7 @@ class Statistical return 1; } - $bestFitExponential = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); + $bestFitExponential = Trend::calculate(Trend::TREND_EXPONENTIAL, $yValues, $xValues, $const); if ($stats) { return [ [ @@ -2347,10 +2350,10 @@ class Statistical // Loop through arguments foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if ((is_null($returnValue)) || ($arg > $returnValue)) { $returnValue = $arg; } @@ -2510,10 +2513,10 @@ class Statistical // Loop through arguments foreach ($aArgs as $key => $arg) { if (!is_numeric($arg)) { - $arg = \PhpOffice\PhpSpreadsheet\Calculation::wrapResult(strtoupper($arg)); + $arg = Calculation::wrapResult(strtoupper($arg)); } $testCondition = '=' . $arg . $condition; - if (\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) { if ((is_null($returnValue)) || ($arg < $returnValue)) { $returnValue = $arg; } @@ -3005,7 +3008,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getGoodnessOfFit(); } @@ -3075,7 +3078,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getSlope(); } @@ -3379,7 +3382,7 @@ class Statistical return Functions::DIV0(); } - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues); return $bestFitLinear->getStdevOfResiduals(); } @@ -3530,7 +3533,7 @@ class Statistical $newValues = Functions::flattenArray($newValues); $const = (is_null($const)) ? true : (bool) Functions::flattenSingleValue($const); - $bestFitLinear = \PhpOffice\PhpSpreadsheet\Shared\trend\trend::calculate(\PhpOffice\PhpSpreadsheet\Shared\trend\trend::TREND_LINEAR, $yValues, $xValues, $const); + $bestFitLinear = Trend::calculate(Trend::TREND_LINEAR, $yValues, $xValues, $const); if (empty($newValues)) { $newValues = $bestFitLinear->getXValues(); } diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index fd9cd7a9..ed4b8b9c 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -2,6 +2,11 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -67,7 +72,7 @@ class TextData $stringValue = Functions::flattenSingleValue($stringValue); if (is_bool($stringValue)) { - return ($stringValue) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE(); } if (self::$invalidChars == null) { @@ -92,7 +97,7 @@ class TextData { $stringValue = Functions::flattenSingleValue($stringValue); if (is_bool($stringValue)) { - return ($stringValue) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE(); } if (is_string($stringValue) || is_numeric($stringValue)) { @@ -119,7 +124,7 @@ class TextData if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { $characters = (int) $characters; } else { - $characters = ($characters) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $characters = ($characters) ? Calculation::getTRUE() : Calculation::getFALSE(); } } @@ -147,7 +152,7 @@ class TextData if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { $arg = (int) $arg; } else { - $arg = ($arg) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $arg = ($arg) ? Calculation::getTRUE() : Calculation::getFALSE(); } } $returnValue .= $arg; @@ -191,7 +196,7 @@ class TextData $value = MathTrig::MROUND($value, $round); } - return \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString($value, $mask); + return NumberFormat::toFormattedString($value, $mask); } /** @@ -211,11 +216,11 @@ class TextData if (!is_bool($needle)) { if (is_bool($haystack)) { - $haystack = ($haystack) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $haystack = ($haystack) ? Calculation::getTRUE() : Calculation::getFALSE(); } - if (($offset > 0) && (\PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($haystack) > $offset)) { - if (\PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($needle) == 0) { + if (($offset > 0) && (StringHelper::countCharacters($haystack) > $offset)) { + if (StringHelper::countCharacters($needle) == 0) { return $offset; } @@ -246,11 +251,11 @@ class TextData if (!is_bool($needle)) { if (is_bool($haystack)) { - $haystack = ($haystack) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $haystack = ($haystack) ? Calculation::getTRUE() : Calculation::getFALSE(); } - if (($offset > 0) && (\PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($haystack) > $offset)) { - if (\PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($needle) == 0) { + if (($offset > 0) && (StringHelper::countCharacters($haystack) > $offset)) { + if (StringHelper::countCharacters($needle) == 0) { return $offset; } @@ -314,7 +319,7 @@ class TextData } if (is_bool($value)) { - $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE(); } return mb_substr($value, 0, $chars, 'UTF-8'); @@ -340,7 +345,7 @@ class TextData } if (is_bool($value)) { - $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE(); } if (empty($chars)) { @@ -368,7 +373,7 @@ class TextData } if (is_bool($value)) { - $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE(); } return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8'); @@ -386,7 +391,7 @@ class TextData $value = Functions::flattenSingleValue($value); if (is_bool($value)) { - $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $value = ($value) ? Calculation::getTRUE() : Calculation::getFALSE(); } return mb_strlen($value, 'UTF-8'); @@ -406,10 +411,10 @@ class TextData $mixedCaseString = Functions::flattenSingleValue($mixedCaseString); if (is_bool($mixedCaseString)) { - $mixedCaseString = ($mixedCaseString) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE(); } - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::strToLower($mixedCaseString); + return StringHelper::strToLower($mixedCaseString); } /** @@ -426,10 +431,10 @@ class TextData $mixedCaseString = Functions::flattenSingleValue($mixedCaseString); if (is_bool($mixedCaseString)) { - $mixedCaseString = ($mixedCaseString) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE(); } - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::strToUpper($mixedCaseString); + return StringHelper::strToUpper($mixedCaseString); } /** @@ -446,10 +451,10 @@ class TextData $mixedCaseString = Functions::flattenSingleValue($mixedCaseString); if (is_bool($mixedCaseString)) { - $mixedCaseString = ($mixedCaseString) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); + $mixedCaseString = ($mixedCaseString) ? Calculation::getTRUE() : Calculation::getFALSE(); } - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::strToTitle($mixedCaseString); + return StringHelper::strToTitle($mixedCaseString); } /** @@ -543,11 +548,11 @@ class TextData $value = Functions::flattenSingleValue($value); $format = Functions::flattenSingleValue($format); - if ((is_string($value)) && (!is_numeric($value)) && \PhpOffice\PhpSpreadsheet\Shared\Date::isDateTimeFormatCode($format)) { + if ((is_string($value)) && (!is_numeric($value)) && Date::isDateTimeFormatCode($format)) { $value = DateTime::DATEVALUE($value); } - return (string) \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString($value, $format); + return (string) NumberFormat::toFormattedString($value, $format); } /** @@ -563,9 +568,9 @@ class TextData if (!is_numeric($value)) { $numberValue = str_replace( - \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getThousandsSeparator(), + StringHelper::getThousandsSeparator(), '', - trim($value, " \t\n\r\0\x0B" . \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getCurrencyCode()) + trim($value, " \t\n\r\0\x0B" . StringHelper::getCurrencyCode()) ); if (is_numeric($numberValue)) { return (float) $numberValue; diff --git a/src/PhpSpreadsheet/Calculation/Token/Stack.php b/src/PhpSpreadsheet/Calculation/Token/Stack.php index efa63011..16b8635f 100644 --- a/src/PhpSpreadsheet/Calculation/Token/Stack.php +++ b/src/PhpSpreadsheet/Calculation/Token/Stack.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Token; +use PhpOffice\PhpSpreadsheet\Calculation; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -65,7 +67,7 @@ class Stack 'reference' => $reference, ]; if ($type == 'Function') { - $localeFunction = \PhpOffice\PhpSpreadsheet\Calculation::localeFunc($value); + $localeFunction = Calculation::localeFunc($value); if ($localeFunction != $value) { $this->stack[($this->count - 1)]['localeValue'] = $localeFunction; } diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index ba960839..f7f161fd 100644 --- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -2,6 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,36 +36,36 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder /** * Bind value to a cell. * - * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to + * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * * @return bool */ - public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null) + public function bindValue(Cell $cell, $value = null) { // sanitize UTF-8 strings if (is_string($value)) { - $value = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::sanitizeUTF8($value); + $value = StringHelper::sanitizeUTF8($value); } // Find out data type $dataType = parent::dataTypeForValue($value); // Style logic - strings - if ($dataType === DataType::TYPE_STRING && !$value instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($dataType === DataType::TYPE_STRING && !$value instanceof RichText) { // Test for booleans using locale-setting - if ($value == \PhpOffice\PhpSpreadsheet\Calculation::getTRUE()) { + if ($value == Calculation::getTRUE()) { $cell->setValueExplicit(true, DataType::TYPE_BOOL); return true; - } elseif ($value == \PhpOffice\PhpSpreadsheet\Calculation::getFALSE()) { + } elseif ($value == Calculation::getFALSE()) { $cell->setValueExplicit(false, DataType::TYPE_BOOL); return true; } // Check for number in scientific format - if (preg_match('/^' . \PhpOffice\PhpSpreadsheet\Calculation::CALCULATION_REGEXP_NUMBER . '$/', $value)) { + if (preg_match('/^' . Calculation::CALCULATION_REGEXP_NUMBER . '$/', $value)) { $cell->setValueExplicit((float) $value, DataType::TYPE_NUMERIC); return true; @@ -98,15 +105,15 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder $cell->setValueExplicit($value, DataType::TYPE_NUMERIC); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) - ->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00); + ->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_PERCENTAGE_00); return true; } // Check for currency - $currencyCode = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getCurrencyCode(); - $decimalSeparator = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getDecimalSeparator(); - $thousandsSeparator = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getThousandsSeparator(); + $currencyCode = StringHelper::getCurrencyCode(); + $decimalSeparator = StringHelper::getDecimalSeparator(); + $thousandsSeparator = StringHelper::getThousandsSeparator(); if (preg_match('/^' . preg_quote($currencyCode) . ' *(\d{1,3}(' . preg_quote($thousandsSeparator) . '\d{3})*|(\d+))(' . preg_quote($decimalSeparator) . '\d{2})?$/', $value)) { // Convert value to number $value = (float) trim(str_replace([$currencyCode, $thousandsSeparator, $decimalSeparator], ['', '', '.'], $value)); @@ -114,7 +121,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) ->getNumberFormat()->setFormatCode( - str_replace('$', $currencyCode, \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE) + str_replace('$', $currencyCode, NumberFormat::FORMAT_CURRENCY_USD_SIMPLE) ); return true; @@ -124,7 +131,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder $cell->setValueExplicit($value, DataType::TYPE_NUMERIC); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) - ->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); + ->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); return true; } @@ -137,7 +144,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder $cell->setValueExplicit($days, DataType::TYPE_NUMERIC); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) - ->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME3); + ->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_TIME3); return true; } @@ -151,13 +158,13 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder $cell->setValueExplicit($days, DataType::TYPE_NUMERIC); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) - ->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4); + ->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_TIME4); return true; } // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' - if (($d = \PhpOffice\PhpSpreadsheet\Shared\Date::stringToExcel($value)) !== false) { + if (($d = Date::stringToExcel($value)) !== false) { // Convert value to number $cell->setValueExplicit($d, DataType::TYPE_NUMERIC); // Determine style. Either there is a time part or not. Look for ':' @@ -174,7 +181,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder // Check for newline character "\n" if (strpos($value, "\n") !== false) { - $value = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::sanitizeUTF8($value); + $value = StringHelper::sanitizeUTF8($value); $cell->setValueExplicit($value, DataType::TYPE_STRING); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index 2f41b66c..b308fe74 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -71,13 +74,13 @@ class DataType */ public static function checkString($pValue) { - if ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($pValue instanceof RichText) { // TODO: Sanitize Rich-Text string (max. character count is 32,767) return $pValue; } // string must never be longer than 32,767 characters, truncate if necessary - $pValue = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::substring($pValue, 0, 32767); + $pValue = StringHelper::substring($pValue, 0, 32767); // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" $pValue = str_replace(["\r\n", "\r"], "\n", $pValue); diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index f9e7729f..a0fc5209 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -2,6 +2,11 @@ namespace PhpOffice\PhpSpreadsheet\Cell; +use DateTime; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,21 +34,21 @@ class DefaultValueBinder implements IValueBinder /** * Bind value to a cell. * - * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to + * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * * @return bool */ - public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null) + public function bindValue(Cell $cell, $value = null) { // sanitize UTF-8 strings if (is_string($value)) { - $value = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::sanitizeUTF8($value); + $value = StringHelper::sanitizeUTF8($value); } elseif (is_object($value)) { // Handle any objects that might be injected - if ($value instanceof \DateTime) { + if ($value instanceof DateTime) { $value = $value->format('Y-m-d H:i:s'); - } elseif (!($value instanceof \PhpOffice\PhpSpreadsheet\RichText)) { + } elseif (!($value instanceof RichText)) { $value = (string) $value; } } @@ -69,7 +74,7 @@ class DefaultValueBinder implements IValueBinder return DataType::TYPE_NULL; } elseif ($pValue === '') { return DataType::TYPE_STRING; - } elseif ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { + } elseif ($pValue instanceof RichText) { return DataType::TYPE_INLINE; } elseif ($pValue[0] === '=' && strlen($pValue) > 1) { return DataType::TYPE_FORMULA; diff --git a/src/PhpSpreadsheet/Cell/IValueBinder.php b/src/PhpSpreadsheet/Cell/IValueBinder.php index 191eb844..72813b2c 100644 --- a/src/PhpSpreadsheet/Cell/IValueBinder.php +++ b/src/PhpSpreadsheet/Cell/IValueBinder.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Cell; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,10 +31,10 @@ interface IValueBinder /** * Bind value to a cell. * - * @param \PhpOffice\PhpSpreadsheet\Cell $cell Cell to bind value to + * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * * @return bool */ - public function bindValue(\PhpOffice\PhpSpreadsheet\Cell $cell, $value = null); + public function bindValue(Cell $cell, $value = null); } diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 092736a6..63be0d41 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -388,7 +390,7 @@ class DataSeries return $this; } - public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet) + public function refresh(Worksheet $worksheet) { foreach ($this->plotValues as $plotValues) { if ($plotValues !== null) { diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 82813400..4fee7c28 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -2,6 +2,11 @@ namespace PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -111,9 +116,9 @@ class DataSeriesValues * * @param string $dataType Datatype of this data series * Typical values are: - * \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_STRING + * DataSeriesValues::DATASERIES_TYPE_STRING * Normally used for axis point values - * \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER + * DataSeriesValues::DATASERIES_TYPE_NUMBER * Normally used for chart data values * * @throws Exception @@ -277,17 +282,17 @@ class DataSeriesValues */ public function setDataValues($dataValues) { - $this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($dataValues); + $this->dataValues = Functions::flattenArray($dataValues); $this->pointCount = count($dataValues); return $this; } - public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet, $flatten = true) + public function refresh(Worksheet $worksheet, $flatten = true) { if ($this->dataSource !== null) { - $calcEngine = \PhpOffice\PhpSpreadsheet\Calculation::getInstance($worksheet->getParent()); - $newDataValues = \PhpOffice\PhpSpreadsheet\Calculation::unwrapResult( + $calcEngine = Calculation::getInstance($worksheet->getParent()); + $newDataValues = Calculation::unwrapResult( $calcEngine->_calculateFormulaValue( '=' . $this->dataSource, null, @@ -295,7 +300,7 @@ class DataSeriesValues ) ); if ($flatten) { - $this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($newDataValues); + $this->dataValues = Functions::flattenArray($newDataValues); foreach ($this->dataValues as &$dataValue) { if ((!empty($dataValue)) && ($dataValue[0] == '#')) { $dataValue = 0.0; @@ -308,9 +313,9 @@ class DataSeriesValues list(, $cellRange) = $cellRange; } - $dimensions = \PhpOffice\PhpSpreadsheet\Cell::rangeDimension(str_replace('$', '', $cellRange)); + $dimensions = Cell::rangeDimension(str_replace('$', '', $cellRange)); if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { - $this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($newDataValues); + $this->dataValues = Functions::flattenArray($newDataValues); } else { $newArray = array_values(array_shift($newDataValues)); foreach ($newArray as $i => $newDataSet) { diff --git a/src/PhpSpreadsheet/Chart/Exception.php b/src/PhpSpreadsheet/Chart/Exception.php index 57562b73..9c19cfd7 100644 --- a/src/PhpSpreadsheet/Chart/Exception.php +++ b/src/PhpSpreadsheet/Chart/Exception.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +26,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Exception extends \PhpOffice\PhpSpreadsheet\Exception +class Exception extends PhpSpreadsheetException { /** * Error handler callback. diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index 5c16db84..0dd12cd4 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -124,7 +126,7 @@ class PlotArea return $this; } - public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet) + public function refresh(Worksheet $worksheet) { foreach ($this->plotSeries as $plotSeries) { $plotSeries->refresh($worksheet); diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index 834d06d8..53883f45 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; +use PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\Settings; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -105,7 +108,7 @@ class JpGraph } else { // Format labels according to any formatting code if (!is_null($datasetLabelFormatCode)) { - $datasetLabels[$i] = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode); + $datasetLabels[$i] = NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode); } } ++$testCurrentIndex; @@ -542,7 +545,7 @@ class JpGraph private function renderAreaChart($groupCount, $dimensions = '2d') { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_line.php'; $this->renderCartesianPlotArea(); @@ -553,7 +556,7 @@ class JpGraph private function renderLineChart($groupCount, $dimensions = '2d') { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_line.php'; $this->renderCartesianPlotArea(); @@ -564,7 +567,7 @@ class JpGraph private function renderBarChart($groupCount, $dimensions = '2d') { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_bar.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_bar.php'; $this->renderCartesianPlotArea(); @@ -575,9 +578,9 @@ class JpGraph private function renderScatterChart($groupCount) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_regstat.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_scatter.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_regstat.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_line.php'; $this->renderCartesianPlotArea('linlin'); @@ -588,7 +591,7 @@ class JpGraph private function renderBubbleChart($groupCount) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_scatter.php'; $this->renderCartesianPlotArea('linlin'); @@ -599,9 +602,9 @@ class JpGraph private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_pie.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_pie.php'; if ($dimensions == '3d') { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_pie3d.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_pie3d.php'; } $this->renderPiePlotArea($doughnut); @@ -675,7 +678,7 @@ class JpGraph private function renderRadarChart($groupCount) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_radar.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_radar.php'; $this->renderRadarPlotArea(); @@ -686,7 +689,7 @@ class JpGraph private function renderStockChart($groupCount) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_stock.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_stock.php'; $this->renderCartesianPlotArea('intint'); @@ -697,7 +700,7 @@ class JpGraph private function renderContourChart($groupCount, $dimensions) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_contour.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_contour.php'; $this->renderCartesianPlotArea('intint'); @@ -708,11 +711,11 @@ class JpGraph private function renderCombinationChart($groupCount, $dimensions, $outputDestination) { - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_bar.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_scatter.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_regstat.php'; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . 'jpgraph_line.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_line.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_bar.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_scatter.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_regstat.php'; + require_once Settings::getChartRendererPath() . 'jpgraph_line.php'; $this->renderCartesianPlotArea(); @@ -848,11 +851,11 @@ class JpGraph /** * Create a new jpgraph. */ - public function __construct(\PhpOffice\PhpSpreadsheet\Chart $chart) + public function __construct(Chart $chart) { $this->graph = null; $this->chart = $chart; - require_once \PhpOffice\PhpSpreadsheet\Settings::getChartRendererPath() . '/jpgraph.php'; + require_once Settings::getChartRendererPath() . '/jpgraph.php'; } } diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 137b6f90..daef9040 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheet\Collection; use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Worksheet; use Psr\SimpleCache\CacheInterface; @@ -124,7 +125,7 @@ class Cells * * @param Cell $cell Cell to update * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Cell */ @@ -138,7 +139,7 @@ class Cells * * @param string $pCoord Coordinate of the cell to delete * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function delete($pCoord) { @@ -342,7 +343,7 @@ class Cells $stored = $newCollection->cache->setMultiple($newValues); if (!$stored) { $newCollection->__destruct(); - throw new \PhpOffice\PhpSpreadsheet\Exception('Failed to copy cells in cache'); + throw new PhpSpreadsheetException('Failed to copy cells in cache'); } return $newCollection; @@ -382,7 +383,7 @@ class Cells * Store cell data in cache for the current cell object if it's "dirty", * and the 'nullify' the current cell object. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ private function storeCurrentCell() { @@ -392,7 +393,7 @@ class Cells $stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell); if (!$stored) { $this->__destruct(); - throw new \PhpOffice\PhpSpreadsheet\Exception("Failed to store cell {$this->currentCoordinate} in cache"); + throw new PhpSpreadsheetException("Failed to store cell {$this->currentCoordinate} in cache"); } $this->currentCellIsDirty = false; } @@ -407,7 +408,7 @@ class Cells * @param string $pCoord Coordinate of the cell to update * @param Cell $cell Cell to update * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Cell */ @@ -430,7 +431,7 @@ class Cells * * @param string $pCoord Coordinate of the cell * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Cell Cell that was found, or null if not found */ @@ -449,7 +450,7 @@ class Cells // Check if the entry that has been requested actually exists $cell = $this->cache->get($this->cachePrefix . $pCoord); if ($cell === null) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Cell entry {$pCoord} no longer exists in cache. This probably means that the cache was cleared by someone else."); + throw new PhpSpreadsheetException("Cell entry {$pCoord} no longer exists in cache. This probably means that the cache was cleared by someone else."); } // Set current entry to the requested entry diff --git a/src/PhpSpreadsheet/Collection/Memory.php b/src/PhpSpreadsheet/Collection/Memory.php index 966b84ba..a32551b0 100644 --- a/src/PhpSpreadsheet/Collection/Memory.php +++ b/src/PhpSpreadsheet/Collection/Memory.php @@ -2,13 +2,15 @@ namespace PhpOffice\PhpSpreadsheet\Collection; +use Psr\SimpleCache\CacheInterface; + /** * This is the default implementation for in-memory cell collection. * * Alternatives implementation should leverage off-memory, non-volatile storage * to reduce overall memory usage. */ -class Memory implements \Psr\SimpleCache\CacheInterface +class Memory implements CacheInterface { private $cache = []; diff --git a/src/PhpSpreadsheet/Document/Security.php b/src/PhpSpreadsheet/Document/Security.php index 6bb99b97..0175dcc4 100644 --- a/src/PhpSpreadsheet/Document/Security.php +++ b/src/PhpSpreadsheet/Document/Security.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Document; +use PhpOffice\PhpSpreadsheet\Shared\PasswordHasher; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -173,7 +175,7 @@ class Security public function setRevisionsPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { - $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); + $pValue = PasswordHasher::hashPassword($pValue); } $this->revisionsPassword = $pValue; @@ -201,7 +203,7 @@ class Security public function setWorkbookPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { - $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); + $pValue = PasswordHasher::hashPassword($pValue); } $this->workbookPassword = $pValue; diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 67b3c481..a968a931 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -6,6 +6,9 @@ use DOMDocument; use DOMElement; use DOMNode; use DOMText; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Style\Color; +use PhpOffice\PhpSpreadsheet\Style\Font; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -625,7 +628,7 @@ class Html // Discard excess white space $dom->preserveWhiteSpace = false; - $this->richTextObject = new \PhpOffice\PhpSpreadsheet\RichText(); + $this->richTextObject = new RichText(); $this->parseElements($dom); // Clean any further spurious whitespace @@ -663,7 +666,7 @@ class Html $richtextRun->getFont()->setSize($this->size); } if ($this->color) { - $richtextRun->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color('ff' . $this->color)); + $richtextRun->getFont()->setColor(new Color('ff' . $this->color)); } if ($this->bold) { $richtextRun->getFont()->setBold(true); @@ -672,7 +675,7 @@ class Html $richtextRun->getFont()->setItalic(true); } if ($this->underline) { - $richtextRun->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); + $richtextRun->getFont()->setUnderline(Font::UNDERLINE_SINGLE); } if ($this->superscript) { $richtextRun->getFont()->setSuperScript(true); diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index e6cf1530..c538fe95 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -4,6 +4,8 @@ namespace PhpOffice\PhpSpreadsheet\Helper; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\IWriter; +use ReflectionClass; /** * Helper class to be used in sample code. @@ -164,15 +166,17 @@ class Sample /** * Log a line about the write operation. * - * @param \PhpOffice\PhpSpreadsheet\Writer\IWriter $writer + * @param IWriter $writer * @param string $path * @param float $callStartTime + * + * @throws \ReflectionException */ - public function logWrite(\PhpOffice\PhpSpreadsheet\Writer\IWriter $writer, $path, $callStartTime) + public function logWrite(IWriter $writer, $path, $callStartTime) { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; - $reflection = new \ReflectionClass($writer); + $reflection = new ReflectionClass($writer); $format = $reflection->getShortName(); $message = "Write {$format} format to {$path} in " . sprintf('%.4f', $callTime) . ' seconds'; diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index c0d064b7..7924e37e 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; /** @@ -266,7 +268,7 @@ class Csv extends BaseReader implements IReader $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); } - $worksheetInfo[0]['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); + $worksheetInfo[0]['lastColumnLetter'] = Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; // Close file @@ -282,12 +284,12 @@ class Csv extends BaseReader implements IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename) { // Create new Spreadsheet - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); + $spreadsheet = new Spreadsheet(); // Load into this instance return $this->loadIntoExisting($pFilename, $spreadsheet); @@ -339,7 +341,7 @@ class Csv extends BaseReader implements IReader if ($rowDatum != '' && $this->readFilter->readCell($columnLetter, $currentRow)) { // Convert encoding if necessary if ($this->inputEncoding !== 'UTF-8') { - $rowDatum = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); + $rowDatum = StringHelper::convertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); } // Set cell value diff --git a/src/PhpSpreadsheet/Reader/Exception.php b/src/PhpSpreadsheet/Reader/Exception.php index 167ab4ac..5f2ce05d 100644 --- a/src/PhpSpreadsheet/Reader/Exception.php +++ b/src/PhpSpreadsheet/Reader/Exception.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +26,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Exception extends \PhpOffice\PhpSpreadsheet\Exception +class Exception extends PhpSpreadsheetException { /** * Error handler callback. diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index c6418704..313fcf00 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -3,8 +3,20 @@ namespace PhpOffice\PhpSpreadsheet\Reader; use DateTimeZone; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\NamedRange; +use PhpOffice\PhpSpreadsheet\ReferenceHelper; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Settings; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Borders; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Font; +use XMLReader; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -52,7 +64,7 @@ class Gnumeric extends BaseReader implements IReader public function __construct() { $this->readFilter = new DefaultReadFilter(); - $this->referenceHelper = \PhpOffice\PhpSpreadsheet\ReferenceHelper::getInstance(); + $this->referenceHelper = ReferenceHelper::getInstance(); } /** @@ -97,7 +109,7 @@ class Gnumeric extends BaseReader implements IReader File::assertFile($pFilename); $xml = new XMLReader(); - $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()); + $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2, true); $worksheetNames = []; @@ -126,7 +138,7 @@ class Gnumeric extends BaseReader implements IReader File::assertFile($pFilename); $xml = new XMLReader(); - $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()); + $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2, true); $worksheetInfo = []; @@ -154,7 +166,7 @@ class Gnumeric extends BaseReader implements IReader break; } } - $tmpInfo['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $worksheetInfo[] = $tmpInfo; } } @@ -216,7 +228,7 @@ class Gnumeric extends BaseReader implements IReader $gFileData = $this->gzfileGetContents($pFilename); - $xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); $namespacesMeta = $xml->getNamespaces(true); $gnmXML = $xml->children($namespacesMeta['gnm']); @@ -387,7 +399,7 @@ class Gnumeric extends BaseReader implements IReader $maxCol = $column; } - $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $column = Cell::stringFromColumnIndex($column); // Read cell? if ($this->getReadFilter() !== null) { @@ -398,7 +410,7 @@ class Gnumeric extends BaseReader implements IReader $ValueType = $cellAttributes->ValueType; $ExprID = (string) $cellAttributes->ExprID; - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA; + $type = Cell\DataType::TYPE_FORMULA; if ($ExprID > '') { if (((string) $cell) > '') { $this->expressions[$ExprID] = [ @@ -417,27 +429,27 @@ class Gnumeric extends BaseReader implements IReader $worksheetName ); } - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA; + $type = Cell\DataType::TYPE_FORMULA; } else { switch ($ValueType) { case '10': // NULL - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL; + $type = Cell\DataType::TYPE_NULL; break; case '20': // Boolean - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL; + $type = Cell\DataType::TYPE_BOOL; $cell = ($cell == 'TRUE') ? true : false; break; case '30': // Integer $cell = (int) $cell; // Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case case '40': // Float - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; + $type = Cell\DataType::TYPE_NUMERIC; break; case '50': // Error - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR; + $type = Cell\DataType::TYPE_ERROR; break; case '60': // String - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING; + $type = Cell\DataType::TYPE_STRING; break; case '70': // Cell Range case '80': // Array @@ -459,11 +471,11 @@ class Gnumeric extends BaseReader implements IReader $styleAttributes = $styleRegion->attributes(); if (($styleAttributes['startRow'] <= $maxRow) && ($styleAttributes['startCol'] <= $maxCol)) { - $startColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex((int) $styleAttributes['startCol']); + $startColumn = Cell::stringFromColumnIndex((int) $styleAttributes['startCol']); $startRow = $styleAttributes['startRow'] + 1; $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol']; - $endColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($endColumn); + $endColumn = Cell::stringFromColumnIndex($endColumn); $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow']; $endRow += 1; $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow; @@ -472,45 +484,45 @@ class Gnumeric extends BaseReader implements IReader // We still set the number format mask for date/time values, even if readDataOnly is true if ((!$this->readDataOnly) || - (\PhpOffice\PhpSpreadsheet\Shared\Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { + (Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { $styleArray = []; $styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; // If readDataOnly is false, we set all formatting information if (!$this->readDataOnly) { switch ($styleAttributes['HAlign']) { case '1': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL; break; case '2': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT; break; case '4': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT; break; case '8': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER; break; case '16': case '64': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER_CONTINUOUS; break; case '32': - $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY; + $styleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY; break; } switch ($styleAttributes['VAlign']) { case '1': - $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP; + $styleArray['alignment']['vertical'] = Alignment::VERTICAL_TOP; break; case '2': - $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM; + $styleArray['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM; break; case '4': - $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER; + $styleArray['alignment']['vertical'] = Alignment::VERTICAL_CENTER; break; case '8': - $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY; + $styleArray['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY; break; } @@ -528,64 +540,64 @@ class Gnumeric extends BaseReader implements IReader $styleArray['fill']['endcolor']['rgb'] = $RGB2; switch ($shade) { case '1': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID; + $styleArray['fill']['type'] = Fill::FILL_SOLID; break; case '2': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR; + $styleArray['fill']['type'] = Fill::FILL_GRADIENT_LINEAR; break; case '3': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH; + $styleArray['fill']['type'] = Fill::FILL_GRADIENT_PATH; break; case '4': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKDOWN; break; case '5': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKGRAY; break; case '6': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKGRID; break; case '7': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKHORIZONTAL; break; case '8': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKTRELLIS; break; case '9': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKUP; break; case '10': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKVERTICAL; break; case '11': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_GRAY0625; break; case '12': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_GRAY125; break; case '13': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTDOWN; break; case '14': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTGRAY; break; case '15': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTGRID; break; case '16': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL; break; case '17': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTTRELLIS; break; case '18': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTUP; break; case '19': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTVERTICAL; break; case '20': - $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY; + $styleArray['fill']['type'] = Fill::FILL_PATTERN_MEDIUMGRAY; break; } } @@ -598,19 +610,19 @@ class Gnumeric extends BaseReader implements IReader $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; switch ($fontAttributes['Underline']) { case '1': - $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE; + $styleArray['font']['underline'] = Font::UNDERLINE_SINGLE; break; case '2': - $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE; + $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLE; break; case '3': - $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING; + $styleArray['font']['underline'] = Font::UNDERLINE_SINGLEACCOUNTING; break; case '4': - $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING; + $styleArray['font']['underline'] = Font::UNDERLINE_DOUBLEACCOUNTING; break; default: - $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE; + $styleArray['font']['underline'] = Font::UNDERLINE_NONE; break; } switch ($fontAttributes['Script']) { @@ -637,13 +649,13 @@ class Gnumeric extends BaseReader implements IReader } if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH; + $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_BOTH; } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP; + $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_UP; } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes()); - $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN; + $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_DOWN; } } if (isset($styleRegion->Style->HyperLink)) { @@ -668,19 +680,19 @@ class Gnumeric extends BaseReader implements IReader $hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false; $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; while ($c < $column) { - $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); + $spreadsheet->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); ++$c; } while (($c < ($column + $columnCount)) && ($c <= $maxCol)) { - $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($columnWidth); + $spreadsheet->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($columnWidth); if ($hidden) { - $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setVisible(false); + $spreadsheet->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setVisible(false); } ++$c; } } while ($c <= $maxCol) { - $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); + $spreadsheet->getActiveSheet()->getColumnDimension(Cell::stringFromColumnIndex($c))->setWidth($defaultWidth); ++$c; } } @@ -740,7 +752,7 @@ class Gnumeric extends BaseReader implements IReader $range[0] = trim($range[0], "'"); if ($worksheet = $spreadsheet->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); - $spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange($name, $worksheet, $extractedRange)); + $spreadsheet->addNamedRange(new NamedRange($name, $worksheet, $extractedRange)); } } } @@ -758,46 +770,46 @@ class Gnumeric extends BaseReader implements IReader switch ($borderAttributes['Style']) { case '0': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE; + $styleArray['style'] = Border::BORDER_NONE; break; case '1': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $styleArray['style'] = Border::BORDER_THIN; break; case '2': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM; + $styleArray['style'] = Border::BORDER_MEDIUM; break; case '3': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT; + $styleArray['style'] = Border::BORDER_SLANTDASHDOT; break; case '4': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED; + $styleArray['style'] = Border::BORDER_DASHED; break; case '5': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK; + $styleArray['style'] = Border::BORDER_THICK; break; case '6': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE; + $styleArray['style'] = Border::BORDER_DOUBLE; break; case '7': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED; + $styleArray['style'] = Border::BORDER_DOTTED; break; case '8': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED; + $styleArray['style'] = Border::BORDER_MEDIUMDASHED; break; case '9': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT; + $styleArray['style'] = Border::BORDER_DASHDOT; break; case '10': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT; + $styleArray['style'] = Border::BORDER_MEDIUMDASHDOT; break; case '11': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT; + $styleArray['style'] = Border::BORDER_DASHDOTDOT; break; case '12': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT; + $styleArray['style'] = Border::BORDER_MEDIUMDASHDOTDOT; break; case '13': - $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT; + $styleArray['style'] = Border::BORDER_MEDIUMDASHDOTDOT; break; } @@ -806,7 +818,7 @@ class Gnumeric extends BaseReader implements IReader private function parseRichText($is) { - $value = new \PhpOffice\PhpSpreadsheet\RichText(); + $value = new RichText(); $value->createText($is); return $value; diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 2f0aa473..4db753b5 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -6,7 +6,12 @@ use DOMDocument; use DOMElement; use DOMNode; use DOMText; +use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Color; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Worksheet; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -98,16 +103,16 @@ class Html extends BaseReader implements IReader 'font' => [ 'underline' => true, 'color' => [ - 'argb' => \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLUE, + 'argb' => Color::COLOR_BLUE, ], ], ], // Blue underlined 'hr' => [ 'borders' => [ 'bottom' => [ - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'style' => Border::BORDER_THIN, 'color' => [ - \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK, + Color::COLOR_BLACK, ], ], ], @@ -276,12 +281,12 @@ class Html extends BaseReader implements IReader /** * @param DOMNode $element - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet + * @param Worksheet $sheet * @param int $row * @param string $column * @param string $cellContent */ - protected function processDomElement(DOMNode $element, \PhpOffice\PhpSpreadsheet\Worksheet $sheet, &$row, &$column, &$cellContent) + protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent) { foreach ($element->childNodes as $child) { if ($child instanceof DOMText) { @@ -450,7 +455,7 @@ class Html extends BaseReader implements IReader ++$columnTo; } $range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1); - foreach (\PhpOffice\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($range) as $value) { + foreach (Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); @@ -458,7 +463,7 @@ class Html extends BaseReader implements IReader } elseif (isset($attributeArray['rowspan'])) { //create merging rowspan $range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1); - foreach (\PhpOffice\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($range) as $value) { + foreach (Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); @@ -474,7 +479,7 @@ class Html extends BaseReader implements IReader $sheet->getStyle($column . $row)->applyFromArray( [ 'fill' => [ - 'type' => PHPExcel_Style_Fill::FILL_SOLID, + 'type' => Fill::FILL_SOLID, 'color' => ['rgb' => $attributeArray['bgcolor']], ], ] diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 7ef8d48b..3d4bfa99 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -42,7 +42,7 @@ interface IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename); } diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 13f48ea4..e82d2d4e 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -5,9 +5,16 @@ namespace PhpOffice\PhpSpreadsheet\Reader; use DateTime; use DateTimeZone; use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Cell\DataType; +use PhpOffice\PhpSpreadsheet\Document\Properties; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Settings; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use XMLReader; use ZipArchive; /** @@ -76,7 +83,7 @@ class Ods extends BaseReader implements IReader $xml = simplexml_load_string( $this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $namespacesContent = $xml->getNamespaces(true); if (isset($namespacesContent['manifest'])) { @@ -119,11 +126,11 @@ class Ods extends BaseReader implements IReader $worksheetNames = []; - $xml = new \XMLReader(); + $xml = new XMLReader(); $xml->xml( $this->securityScanFile('zip://' . realpath($pFilename) . '#content.xml'), null, - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $xml->setParserProperty(2, true); @@ -140,12 +147,12 @@ class Ods extends BaseReader implements IReader } // Now read each node until we find our first table:table node while ($xml->read()) { - if ($xml->name == 'table:table' && $xml->nodeType == \XMLReader::ELEMENT) { + if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) { // Loop through each table:table node reading the table:name attribute for each worksheet name do { $worksheetNames[] = $xml->getAttribute('table:name'); $xml->next(); - } while ($xml->name == 'table:table' && $xml->nodeType == \XMLReader::ELEMENT); + } while ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT); } } } @@ -173,11 +180,11 @@ class Ods extends BaseReader implements IReader throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.'); } - $xml = new \XMLReader(); + $xml = new XMLReader(); $res = $xml->xml( $this->securityScanFile('zip://' . realpath($pFilename) . '#content.xml'), null, - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $xml->setParserProperty(2, true); @@ -194,7 +201,7 @@ class Ods extends BaseReader implements IReader } // Now read each node until we find our first table:table node while ($xml->read()) { - if ($xml->name == 'table:table' && $xml->nodeType == \XMLReader::ELEMENT) { + if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) { $worksheetNames[] = $xml->getAttribute('table:name'); $tmpInfo = [ @@ -209,7 +216,7 @@ class Ods extends BaseReader implements IReader $currCells = 0; do { $xml->read(); - if ($xml->name == 'table:table-row' && $xml->nodeType == \XMLReader::ELEMENT) { + if ($xml->name == 'table:table-row' && $xml->nodeType == XMLReader::ELEMENT) { $rowspan = $xml->getAttribute('table:number-rows-repeated'); $rowspan = empty($rowspan) ? 1 : $rowspan; $tmpInfo['totalRows'] += $rowspan; @@ -218,14 +225,14 @@ class Ods extends BaseReader implements IReader // Step into the row $xml->read(); do { - if ($xml->name == 'table:table-cell' && $xml->nodeType == \XMLReader::ELEMENT) { + if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) { if (!$xml->isEmptyElement) { ++$currCells; $xml->next(); } else { $xml->read(); } - } elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == \XMLReader::ELEMENT) { + } elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == XMLReader::ELEMENT) { $mergeSize = $xml->getAttribute('table:number-columns-repeated'); $currCells += $mergeSize; $xml->read(); @@ -236,7 +243,7 @@ class Ods extends BaseReader implements IReader $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells); $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; - $tmpInfo['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $worksheetInfo[] = $tmpInfo; } } @@ -252,12 +259,12 @@ class Ods extends BaseReader implements IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename) { // Create new Spreadsheet - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); + $spreadsheet = new Spreadsheet(); // Load into this instance return $this->loadIntoExisting($pFilename, $spreadsheet); @@ -281,13 +288,13 @@ class Ods extends BaseReader implements IReader * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ - public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) { File::assertFile($pFilename); @@ -306,7 +313,7 @@ class Ods extends BaseReader implements IReader $xml = simplexml_load_string( $this->securityScan($zip->getFromName('meta.xml')), 'SimpleXMLElement', - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $namespacesMeta = $xml->getNamespaces(true); @@ -359,26 +366,26 @@ class Ods extends BaseReader implements IReader $docProps->setCreated($creationDate); break; case 'user-defined': - $propertyValueType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_STRING; + $propertyValueType = Properties::PROPERTY_TYPE_STRING; foreach ($propertyValueAttributes as $key => $value) { if ($key == 'name') { $propertyValueName = (string) $value; } elseif ($key == 'value-type') { switch ($value) { case 'date': - $propertyValue = \PhpOffice\PhpSpreadsheet\Document\Properties::convertProperty($propertyValue, 'date'); - $propertyValueType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE; + $propertyValue = Properties::convertProperty($propertyValue, 'date'); + $propertyValueType = Properties::PROPERTY_TYPE_DATE; break; case 'boolean': - $propertyValue = \PhpOffice\PhpSpreadsheet\Document\Properties::convertProperty($propertyValue, 'bool'); - $propertyValueType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN; + $propertyValue = Properties::convertProperty($propertyValue, 'bool'); + $propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN; break; case 'float': - $propertyValue = \PhpOffice\PhpSpreadsheet\Document\Properties::convertProperty($propertyValue, 'r4'); - $propertyValueType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT; + $propertyValue = Properties::convertProperty($propertyValue, 'r4'); + $propertyValueType = Properties::PROPERTY_TYPE_FLOAT; break; default: - $propertyValueType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_STRING; + $propertyValueType = Properties::PROPERTY_TYPE_STRING; } } } @@ -395,7 +402,7 @@ class Ods extends BaseReader implements IReader $dom = new \DOMDocument('1.01', 'UTF-8'); $dom->loadXML( $this->securityScan($zip->getFromName('content.xml')), - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $officeNs = $dom->lookupNamespaceUri('office'); @@ -563,7 +570,7 @@ class Ods extends BaseReader implements IReader if (floor($dataValue) == $dataValue) { $dataValue = (int) $dataValue; } - $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00; + $formatting = NumberFormat::FORMAT_PERCENTAGE_00; break; case 'currency': $type = DataType::TYPE_NUMERIC; @@ -572,7 +579,7 @@ class Ods extends BaseReader implements IReader if (floor($dataValue) == $dataValue) { $dataValue = (int) $dataValue; } - $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; + $formatting = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; break; case 'float': $type = DataType::TYPE_NUMERIC; @@ -597,7 +604,7 @@ class Ods extends BaseReader implements IReader $dateObj->format('Y m d H i s') ); - $dataValue = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel( + $dataValue = Date::formattedPHPToExcel( $year, $month, $day, @@ -607,11 +614,11 @@ class Ods extends BaseReader implements IReader ); if ($dataValue != floor($dataValue)) { - $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX15 + $formatting = NumberFormat::FORMAT_DATE_XLSX15 . ' ' - . \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4; + . NumberFormat::FORMAT_DATE_TIME4; } else { - $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX15; + $formatting = NumberFormat::FORMAT_DATE_XLSX15; } break; case 'time': @@ -619,12 +626,12 @@ class Ods extends BaseReader implements IReader $timeValue = $cellData->getAttributeNS($officeNs, 'time-value'); - $dataValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel( + $dataValue = Date::PHPToExcel( strtotime( '01-01-1970 ' . implode(':', sscanf($timeValue, 'PT%dH%dM%dS')) ) ); - $formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4; + $formatting = NumberFormat::FORMAT_DATE_TIME4; break; default: $dataValue = null; @@ -723,11 +730,11 @@ class Ods extends BaseReader implements IReader $columnTo = $columnID; if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned')) { - $columnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnID); + $columnIndex = Cell::columnIndexFromString($columnID); $columnIndex += (int) $cellData->getAttributeNS($tableNs, 'number-columns-spanned'); $columnIndex -= 2; - $columnTo = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnIndex); + $columnTo = Cell::stringFromColumnIndex($columnIndex); } $rowTo = $rowID; @@ -795,11 +802,11 @@ class Ods extends BaseReader implements IReader /** * @param string $is * - * @return \PhpOffice\PhpSpreadsheet\RichText + * @return RichText */ private function parseRichText($is) { - $value = new \PhpOffice\PhpSpreadsheet\RichText(); + $value = new RichText(); $value->createText($is); return $value; diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index dbe2cd0f..5a0950a6 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -2,6 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Border; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -151,7 +157,7 @@ class Slk extends BaseReader implements IReader $columnIndex = 0; // convert SYLK encoded $rowData to UTF-8 - $rowData = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::SYLKtoUTF8($rowData); + $rowData = StringHelper::SYLKtoUTF8($rowData); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) @@ -178,7 +184,7 @@ class Slk extends BaseReader implements IReader } } - $worksheetInfo[0]['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); + $worksheetInfo[0]['lastColumnLetter'] = Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; // Close file @@ -194,12 +200,12 @@ class Slk extends BaseReader implements IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename) { // Create new Spreadsheet - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); + $spreadsheet = new Spreadsheet(); // Load into this instance return $this->loadIntoExisting($pFilename, $spreadsheet); @@ -209,13 +215,13 @@ class Slk extends BaseReader implements IReader * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * * @param string $pFilename - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ - public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) { // Open file if (!$this->canRead($pFilename)) { @@ -241,7 +247,7 @@ class Slk extends BaseReader implements IReader // loop through one row (line) at a time in the file while (($rowData = fgets($fileHandle)) !== false) { // convert SYLK encoded $rowData to UTF-8 - $rowData = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::SYLKtoUTF8($rowData); + $rowData = StringHelper::SYLKtoUTF8($rowData); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) @@ -274,16 +280,16 @@ class Slk extends BaseReader implements IReader $formatArray['font']['bold'] = true; break; case 'T': - $formatArray['borders']['top']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $formatArray['borders']['top']['style'] = Border::BORDER_THIN; break; case 'B': - $formatArray['borders']['bottom']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $formatArray['borders']['bottom']['style'] = Border::BORDER_THIN; break; case 'L': - $formatArray['borders']['left']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $formatArray['borders']['left']['style'] = Border::BORDER_THIN; break; case 'R': - $formatArray['borders']['right']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $formatArray['borders']['right']['style'] = Border::BORDER_THIN; break; } } @@ -342,7 +348,7 @@ class Slk extends BaseReader implements IReader if ($columnReference[0] == '[') { $columnReference = $column + trim($columnReference, '[]'); } - $A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; + $A1CellReference = Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } @@ -355,13 +361,13 @@ class Slk extends BaseReader implements IReader break; } } - $columnLetter = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column - 1); - $cellData = \PhpOffice\PhpSpreadsheet\Calculation::unwrapResult($cellData); + $columnLetter = Cell::stringFromColumnIndex($column - 1); + $cellData = Calculation::unwrapResult($cellData); // Set cell value $spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData); if ($hasCalculatedValue) { - $cellData = \PhpOffice\PhpSpreadsheet\Calculation::unwrapResult($cellData); + $cellData = Calculation::unwrapResult($cellData); $spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setCalculatedValue($cellData); } // Read cell formatting @@ -395,16 +401,16 @@ class Slk extends BaseReader implements IReader $styleData['font']['bold'] = true; break; case 'T': - $styleData['borders']['top']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $styleData['borders']['top']['style'] = Border::BORDER_THIN; break; case 'B': - $styleData['borders']['bottom']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $styleData['borders']['bottom']['style'] = Border::BORDER_THIN; break; case 'L': - $styleData['borders']['left']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $styleData['borders']['left']['style'] = Border::BORDER_THIN; break; case 'R': - $styleData['borders']['right']['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN; + $styleData['borders']['right']['style'] = Border::BORDER_THIN; break; } } @@ -412,22 +418,22 @@ class Slk extends BaseReader implements IReader } } if (($formatStyle > '') && ($column > '') && ($row > '')) { - $columnLetter = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column - 1); + $columnLetter = Cell::stringFromColumnIndex($column - 1); if (isset($this->formats[$formatStyle])) { $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->formats[$formatStyle]); } } if ((!empty($styleData)) && ($column > '') && ($row > '')) { - $columnLetter = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column - 1); + $columnLetter = Cell::stringFromColumnIndex($column - 1); $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData); } if ($columnWidth > '') { if ($startCol == $endCol) { - $startCol = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($startCol - 1); + $startCol = Cell::stringFromColumnIndex($startCol - 1); $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); } else { - $startCol = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($startCol - 1); - $endCol = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($endCol - 1); + $startCol = Cell::stringFromColumnIndex($startCol - 1); + $endCol = Cell::stringFromColumnIndex($endCol - 1); $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); do { $spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 801b27d7..a7fe48e4 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -2,7 +2,31 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Cell\DataValidation; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\NamedRange; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\CodePage; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\Escher; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE; use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Shared\OLE; +use PhpOffice\PhpSpreadsheet\Shared\OLERead; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Borders; +use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PhpOffice\PhpSpreadsheet\Style\Protection; +use PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -194,7 +218,7 @@ class Xls extends BaseReader implements IReader /** * Workbook to be returned by the reader. * - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadsheet; @@ -426,13 +450,13 @@ class Xls extends BaseReader implements IReader try { // Use ParseXL for the hard work. - $ole = new \PhpOffice\PhpSpreadsheet\Shared\OLERead(); + $ole = new OLERead(); // get excel data $ole->read($pFilename); return true; - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { return false; } } @@ -586,7 +610,7 @@ class Xls extends BaseReader implements IReader } } - $tmpInfo['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; $worksheetInfo[] = $tmpInfo; @@ -602,7 +626,7 @@ class Xls extends BaseReader implements IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename) { @@ -610,7 +634,7 @@ class Xls extends BaseReader implements IReader $this->loadOLE($pFilename); // Initialisations - $this->spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); + $this->spreadsheet = new Spreadsheet(); $this->spreadsheet->removeSheetByIndex(0); // remove 1st sheet if (!$this->readDataOnly) { $this->spreadsheet->removeCellStyleXfByIndex(0); // remove the default style @@ -762,7 +786,7 @@ class Xls extends BaseReader implements IReader // treat MSODRAWINGGROUP records, workbook-level Escher if (!$this->readDataOnly && $this->drawingGroupData) { - $escherWorkbook = new \PhpOffice\PhpSpreadsheet\Shared\Escher(); + $escherWorkbook = new Escher(); $reader = new Xls\Escher($escherWorkbook); $escherWorkbook = $reader->load($this->drawingGroupData); } @@ -980,7 +1004,7 @@ class Xls extends BaseReader implements IReader // treat MSODRAWING records, sheet-level Escher if (!$this->readDataOnly && $this->drawingData) { - $escherWorksheet = new \PhpOffice\PhpSpreadsheet\Shared\Escher(); + $escherWorksheet = new Escher(); $reader = new Xls\Escher($escherWorksheet); $escherWorksheet = $reader->load($this->drawingData); @@ -1000,8 +1024,8 @@ class Xls extends BaseReader implements IReader } // calculate the width and height of the shape - list($startColumn, $startRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($spContainer->getStartCoordinates()); - list($endColumn, $endRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($spContainer->getEndCoordinates()); + list($startColumn, $startRow) = Cell::coordinateFromString($spContainer->getStartCoordinates()); + list($endColumn, $endRow) = Cell::coordinateFromString($spContainer->getEndCoordinates()); $startOffsetX = $spContainer->getStartOffsetX(); $startOffsetY = $spContainer->getStartOffsetY(); @@ -1047,7 +1071,7 @@ class Xls extends BaseReader implements IReader // need check because some blip types are not supported by Escher reader such as EMF if ($blip = $BSE->getBlip()) { $ih = imagecreatefromstring($blip->getData()); - $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing(); + $drawing = new MemoryDrawing(); $drawing->setImageResource($ih); // width, height, offsetX, offsetY @@ -1058,13 +1082,13 @@ class Xls extends BaseReader implements IReader $drawing->setOffsetY($offsetY); switch ($blipType) { - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG: - $drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG); - $drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_JPEG); + case BSE::BLIPTYPE_JPEG: + $drawing->setRenderingFunction(MemoryDrawing::RENDERING_JPEG); + $drawing->setMimeType(MemoryDrawing::MIMETYPE_JPEG); break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG: - $drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_PNG); - $drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_PNG); + case BSE::BLIPTYPE_PNG: + $drawing->setRenderingFunction(MemoryDrawing::RENDERING_PNG); + $drawing->setMimeType(MemoryDrawing::MIMETYPE_PNG); break; } @@ -1082,10 +1106,10 @@ class Xls extends BaseReader implements IReader // treat SHAREDFMLA records if ($this->version == self::XLS_BIFF8) { foreach ($this->sharedFormulaParts as $cell => $baseCell) { - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($cell); + list($column, $row) = Cell::coordinateFromString($cell); if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($column, $row, $this->phpSheet->getTitle())) { $formula = $this->getFormulaFromStructure($this->sharedFormulas[$baseCell], $cell); - $this->phpSheet->getCell($cell)->setValueExplicit('=' . $formula, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA); + $this->phpSheet->getCell($cell)->setValueExplicit('=' . $formula, Cell\DataType::TYPE_FORMULA); } } } @@ -1157,8 +1181,8 @@ class Xls extends BaseReader implements IReader $coordinateStrings = explode(':', $extractedRange); if (count($coordinateStrings) == 2) { - list($firstColumn, $firstRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($coordinateStrings[0]); - list($lastColumn, $lastRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($coordinateStrings[1]); + list($firstColumn, $firstRow) = Cell::coordinateFromString($coordinateStrings[0]); + list($lastColumn, $lastRow) = Cell::coordinateFromString($coordinateStrings[1]); if ($firstColumn == 'A' and $lastColumn == 'IV') { // then we have repeating rows @@ -1187,7 +1211,7 @@ class Xls extends BaseReader implements IReader $scope = ($definedName['scope'] == 0) ? null : $this->spreadsheet->getSheetByName($this->sheets[$definedName['scope'] - 1]['name']); - $this->spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange((string) $definedName['name'], $docSheet, $extractedRange, $localOnly, $scope)); + $this->spreadsheet->addNamedRange(new NamedRange((string) $definedName['name'], $docSheet, $extractedRange, $localOnly, $scope)); } } // Named Value @@ -1263,7 +1287,7 @@ class Xls extends BaseReader implements IReader private function loadOLE($pFilename) { // OLE reader - $ole = new \PhpOffice\PhpSpreadsheet\Shared\OLERead(); + $ole = new OLERead(); // get excel data, $ole->read($pFilename); // Get workbook data: workbook stream + sheet streams @@ -1334,12 +1358,12 @@ class Xls extends BaseReader implements IReader case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::getInt4d($this->summaryInformation, $secOffset + 4 + $offset); $value = substr($this->summaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($value, 'UTF-8', $codePage); + $value = StringHelper::convertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) // PHP-time - $value = \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE2LocalDate(substr($this->summaryInformation, $secOffset + 4 + $offset, 8)); + $value = OLE::OLE2LocalDate(substr($this->summaryInformation, $secOffset + 4 + $offset, 8)); break; case 0x47: // Clipboard format // not needed yet, fix later if necessary @@ -1348,7 +1372,7 @@ class Xls extends BaseReader implements IReader switch ($id) { case 0x01: // Code Page - $codePage = \PhpOffice\PhpSpreadsheet\Shared\CodePage::numberToName($value); + $codePage = CodePage::numberToName($value); break; case 0x02: // Title $this->spreadsheet->getProperties()->setTitle($value); @@ -1472,12 +1496,12 @@ class Xls extends BaseReader implements IReader case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::getInt4d($this->documentSummaryInformation, $secOffset + 4 + $offset); $value = substr($this->documentSummaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($value, 'UTF-8', $codePage); + $value = StringHelper::convertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) // PHP-Time - $value = \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE2LocalDate(substr($this->documentSummaryInformation, $secOffset + 4 + $offset, 8)); + $value = OLE::OLE2LocalDate(substr($this->documentSummaryInformation, $secOffset + 4 + $offset, 8)); break; case 0x47: // Clipboard format // not needed yet, fix later if necessary @@ -1486,7 +1510,7 @@ class Xls extends BaseReader implements IReader switch ($id) { case 0x01: // Code Page - $codePage = \PhpOffice\PhpSpreadsheet\Shared\CodePage::numberToName($value); + $codePage = CodePage::numberToName($value); break; case 0x02: // Category $this->spreadsheet->getProperties()->setCategory($value); @@ -1636,7 +1660,7 @@ class Xls extends BaseReader implements IReader // it is possible to use a compressed format, // which omits the high bytes of all characters, if they are all zero if (($is16Bit & 0x01) === 0) { - $textStr = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::ConvertEncoding($textStr, 'UTF-8', 'ISO-8859-1'); + $textStr = StringHelper::ConvertEncoding($textStr, 'UTF-8', 'ISO-8859-1'); } else { $textStr = $this->decodeCodepage($textStr); } @@ -1861,7 +1885,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; code page identifier $codepage = self::getInt2d($recordData, 0); - $this->codepage = \PhpOffice\PhpSpreadsheet\Shared\CodePage::numberToName($codepage); + $this->codepage = CodePage::numberToName($codepage); } /** @@ -1885,9 +1909,9 @@ class Xls extends BaseReader implements IReader $this->pos += 4 + $length; // offset: 0; size: 2; 0 = base 1900, 1 = base 1904 - \PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar(\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900); + Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); if (ord($recordData[0]) == 1) { - \PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar(\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904); + Date::setExcelCalendar(Date::CALENDAR_MAC_1904); } } @@ -1903,7 +1927,7 @@ class Xls extends BaseReader implements IReader $this->pos += 4 + $length; if (!$this->readDataOnly) { - $objFont = new \PhpOffice\PhpSpreadsheet\Style\Font(); + $objFont = new Font(); // offset: 0; size: 2; height of the font (in twips = 1/20 of a point) $size = self::getInt2d($recordData, 0); @@ -1953,16 +1977,16 @@ class Xls extends BaseReader implements IReader case 0x00: break; // no underline case 0x01: - $objFont->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); + $objFont->setUnderline(Font::UNDERLINE_SINGLE); break; case 0x02: - $objFont->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE); + $objFont->setUnderline(Font::UNDERLINE_DOUBLE); break; case 0x21: - $objFont->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING); + $objFont->setUnderline(Font::UNDERLINE_SINGLEACCOUNTING); break; case 0x22: - $objFont->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING); + $objFont->setUnderline(Font::UNDERLINE_DOUBLEACCOUNTING); break; } @@ -2040,7 +2064,7 @@ class Xls extends BaseReader implements IReader // move stream pointer to next record $this->pos += 4 + $length; - $objStyle = new \PhpOffice\PhpSpreadsheet\Style(); + $objStyle = new Style(); if (!$this->readDataOnly) { // offset: 0; size: 2; Index to FONT record @@ -2058,7 +2082,7 @@ class Xls extends BaseReader implements IReader if (isset($this->formats[$numberFormatIndex])) { // then we have user-defined format code $numberformat = ['code' => $this->formats[$numberFormatIndex]]; - } elseif (($code = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') { + } elseif (($code = NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') { // then we have built-in format code $numberformat = ['code' => $code]; } else { @@ -2072,11 +2096,11 @@ class Xls extends BaseReader implements IReader $xfTypeProt = self::getInt2d($recordData, 4); // bit 0; mask 0x01; 1 = cell is locked $isLocked = (0x01 & $xfTypeProt) >> 0; - $objStyle->getProtection()->setLocked($isLocked ? \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT : \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED); + $objStyle->getProtection()->setLocked($isLocked ? Protection::PROTECTION_INHERIT : Protection::PROTECTION_UNPROTECTED); // bit 1; mask 0x02; 1 = Formula is hidden $isHidden = (0x02 & $xfTypeProt) >> 1; - $objStyle->getProtection()->setHidden($isHidden ? \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED : \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED); + $objStyle->getProtection()->setHidden($isHidden ? Protection::PROTECTION_PROTECTED : Protection::PROTECTION_UNPROTECTED); // bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF $isCellStyleXf = (0x04 & $xfTypeProt) >> 2; @@ -2086,25 +2110,25 @@ class Xls extends BaseReader implements IReader $horAlign = (0x07 & ord($recordData[6])) >> 0; switch ($horAlign) { case 0: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_GENERAL); break; case 1: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT); break; case 2: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); break; case 3: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); break; case 4: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_FILL); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_FILL); break; case 5: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_JUSTIFY); break; case 6: - $objStyle->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS); + $objStyle->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER_CONTINUOUS); break; } // bit 3, mask 0x08; wrap text @@ -2121,16 +2145,16 @@ class Xls extends BaseReader implements IReader $vertAlign = (0x70 & ord($recordData[6])) >> 4; switch ($vertAlign) { case 0: - $objStyle->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP); + $objStyle->getAlignment()->setVertical(Alignment::VERTICAL_TOP); break; case 1: - $objStyle->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); + $objStyle->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); break; case 2: - $objStyle->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM); + $objStyle->getAlignment()->setVertical(Alignment::VERTICAL_BOTTOM); break; case 3: - $objStyle->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY); + $objStyle->getAlignment()->setVertical(Alignment::VERTICAL_JUSTIFY); break; } @@ -2195,13 +2219,13 @@ class Xls extends BaseReader implements IReader $diagonalUp = (0x80000000 & self::getInt4d($recordData, 10)) >> 31 ? true : false; if ($diagonalUp == false && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(\PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_NONE); + $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_NONE); } elseif ($diagonalUp == true && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(\PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP); + $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_UP); } elseif ($diagonalUp == false && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(\PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN); + $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_DOWN); } elseif ($diagonalUp == true && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(\PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH); + $objStyle->getBorders()->setDiagonalDirection(Borders::DIAGONAL_BOTH); } // offset: 14; size: 4; @@ -2562,16 +2586,16 @@ class Xls extends BaseReader implements IReader // offset: 4; size: 1; sheet state switch (ord($recordData[4])) { case 0x00: - $sheetState = \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VISIBLE; + $sheetState = Worksheet::SHEETSTATE_VISIBLE; break; case 0x01: - $sheetState = \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_HIDDEN; + $sheetState = Worksheet::SHEETSTATE_HIDDEN; break; case 0x02: - $sheetState = \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VERYHIDDEN; + $sheetState = Worksheet::SHEETSTATE_VERYHIDDEN; break; default: - $sheetState = \PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VISIBLE; + $sheetState = Worksheet::SHEETSTATE_VISIBLE; break; } @@ -2768,7 +2792,7 @@ class Xls extends BaseReader implements IReader try { $formula = $this->getFormulaFromStructure($formulaStructure); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { $formula = ''; } @@ -3064,7 +3088,7 @@ class Xls extends BaseReader implements IReader $cl = self::getInt2d($recordData, 2 + 6 * $i + 4); // not sure why two column indexes are necessary? - $this->phpSheet->setBreakByColumnAndRow($cf, $r, \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW); + $this->phpSheet->setBreakByColumnAndRow($cf, $r, Worksheet::BREAK_ROW); } } } @@ -3091,7 +3115,7 @@ class Xls extends BaseReader implements IReader $rl = self::getInt2d($recordData, 2 + 6 * $i + 4); // not sure why two row indexes are necessary? - $this->phpSheet->setBreakByColumnAndRow($c, $rf, \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_COLUMN); + $this->phpSheet->setBreakByColumnAndRow($c, $rf, Worksheet::BREAK_COLUMN); } } } @@ -3292,10 +3316,10 @@ class Xls extends BaseReader implements IReader $this->phpSheet->getPageSetup()->setPaperSize($paperSize); switch ($isPortrait) { case 0: - $this->phpSheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE); + $this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE); break; case 1: - $this->phpSheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT); + $this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT); break; } @@ -3562,7 +3586,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; index to column $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -3580,7 +3604,7 @@ class Xls extends BaseReader implements IReader } // add cell - $cell->setValueExplicit($numValue, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC); + $cell->setValueExplicit($numValue, Cell\DataType::TYPE_NUMERIC); } } @@ -3606,7 +3630,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; index to column $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); $emptyCell = true; // Read cell? @@ -3620,18 +3644,18 @@ class Xls extends BaseReader implements IReader // add cell if (($fmtRuns = $this->sst[$index]['fmtRuns']) && !$this->readDataOnly) { // then we should treat as rich text - $richText = new \PhpOffice\PhpSpreadsheet\RichText(); + $richText = new RichText(); $charPos = 0; $sstCount = count($this->sst[$index]['fmtRuns']); for ($i = 0; $i <= $sstCount; ++$i) { if (isset($fmtRuns[$i])) { - $text = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::substring($this->sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); + $text = StringHelper::substring($this->sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); $charPos = $fmtRuns[$i]['charPos']; } else { - $text = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::substring($this->sst[$index]['value'], $charPos, \PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($this->sst[$index]['value'])); + $text = StringHelper::substring($this->sst[$index]['value'], $charPos, StringHelper::countCharacters($this->sst[$index]['value'])); } - if (\PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($text) > 0) { + if (StringHelper::countCharacters($text) > 0) { if ($i == 0) { // first text run, no style $richText->createText($text); } else { @@ -3651,13 +3675,13 @@ class Xls extends BaseReader implements IReader } if ($this->readEmptyCells || trim($richText->getPlainText()) !== '') { $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($richText, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); + $cell->setValueExplicit($richText, Cell\DataType::TYPE_STRING); $emptyCell = false; } } else { if ($this->readEmptyCells || trim($this->sst[$index]['value']) !== '') { $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($this->sst[$index]['value'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); + $cell->setValueExplicit($this->sst[$index]['value'], Cell\DataType::TYPE_STRING); $emptyCell = false; } } @@ -3699,7 +3723,7 @@ class Xls extends BaseReader implements IReader $offset = 4; for ($i = 0; $i < $columns; ++$i) { - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($colFirst + $i); + $columnString = Cell::stringFromColumnIndex($colFirst + $i); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -3715,7 +3739,7 @@ class Xls extends BaseReader implements IReader } // add cell value - $cell->setValueExplicit($numValue, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC); + $cell->setValueExplicit($numValue, Cell\DataType::TYPE_NUMERIC); } $offset += 6; @@ -3743,7 +3767,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size 2; index to column $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -3759,7 +3783,7 @@ class Xls extends BaseReader implements IReader } // add cell value - $cell->setValueExplicit($numValue, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC); + $cell->setValueExplicit($numValue, Cell\DataType::TYPE_NUMERIC); } } @@ -3784,7 +3808,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; col index $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); // offset: 20: size: variable; formula structure $formulaStructure = substr($recordData, 20); @@ -3808,7 +3832,7 @@ class Xls extends BaseReader implements IReader // get the base cell, grab tExp token $baseRow = self::getInt2d($formulaStructure, 3); $baseCol = self::getInt2d($formulaStructure, 5); - $this->_baseCell = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($baseCol) . ($baseRow + 1); + $this->_baseCell = Cell::stringFromColumnIndex($baseCol) . ($baseRow + 1); } // Read cell? @@ -3826,7 +3850,7 @@ class Xls extends BaseReader implements IReader // offset: 6; size: 8; result of the formula if ((ord($recordData[6]) == 0) && (ord($recordData[12]) == 255) && (ord($recordData[13]) == 255)) { // String formula. Result follows in appended STRING record - $dataType = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING; + $dataType = Cell\DataType::TYPE_STRING; // read possible SHAREDFMLA record $code = self::getInt2d($this->data, $this->pos); @@ -3840,23 +3864,23 @@ class Xls extends BaseReader implements IReader && (ord($recordData[12]) == 255) && (ord($recordData[13]) == 255)) { // Boolean formula. Result is in +2; 0=false, 1=true - $dataType = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL; + $dataType = Cell\DataType::TYPE_BOOL; $value = (bool) ord($recordData[8]); } elseif ((ord($recordData[6]) == 2) && (ord($recordData[12]) == 255) && (ord($recordData[13]) == 255)) { // Error formula. Error code is in +2 - $dataType = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR; + $dataType = Cell\DataType::TYPE_ERROR; $value = Xls\ErrorCode::lookup(ord($recordData[8])); } elseif ((ord($recordData[6]) == 3) && (ord($recordData[12]) == 255) && (ord($recordData[13]) == 255)) { // Formula result is a null string - $dataType = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL; + $dataType = Cell\DataType::TYPE_NULL; $value = ''; } else { // forumla result is a number, first 14 bytes like _NUMBER record - $dataType = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; + $dataType = Cell\DataType::TYPE_NUMERIC; $value = self::extractNumber(substr($recordData, 6, 8)); } @@ -3875,8 +3899,8 @@ class Xls extends BaseReader implements IReader throw new Exception('Not BIFF8. Can only read BIFF8 formulas'); } $formula = $this->getFormulaFromStructure($formulaStructure); // get formula in human language - $cell->setValueExplicit('=' . $formula, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + $cell->setValueExplicit('=' . $formula, Cell\DataType::TYPE_FORMULA); + } catch (PhpSpreadsheetException $e) { $cell->setValueExplicit($value, $dataType); } } else { @@ -3968,7 +3992,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; column index $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -3987,13 +4011,13 @@ class Xls extends BaseReader implements IReader $value = (bool) $boolErr; // add cell value - $cell->setValueExplicit($value, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL); + $cell->setValueExplicit($value, Cell\DataType::TYPE_BOOL); break; case 1: // error type $value = Xls\ErrorCode::lookup($boolErr); // add cell value - $cell->setValueExplicit($value, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR); + $cell->setValueExplicit($value, Cell\DataType::TYPE_ERROR); break; } @@ -4030,7 +4054,7 @@ class Xls extends BaseReader implements IReader // add style information if (!$this->readDataOnly && $this->readEmptyCells) { for ($i = 0; $i < $length / 2 - 3; ++$i) { - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($fc + $i); + $columnString = Cell::stringFromColumnIndex($fc + $i); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -4066,7 +4090,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; index to column $column = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column); + $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -4084,7 +4108,7 @@ class Xls extends BaseReader implements IReader } if ($this->readEmptyCells || trim($value) !== '') { $cell = $this->phpSheet->getCell($columnString . ($row + 1)); - $cell->setValueExplicit($value, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); + $cell->setValueExplicit($value, Cell\DataType::TYPE_STRING); if (!$this->readDataOnly) { // add cell style @@ -4110,7 +4134,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; col index $col = self::getInt2d($recordData, 2); - $columnString = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col); + $columnString = Cell::stringFromColumnIndex($col); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { @@ -4237,9 +4261,9 @@ class Xls extends BaseReader implements IReader //FIXME: set $firstVisibleRow and $firstVisibleColumn - if ($this->phpSheet->getSheetView()->getView() !== \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT) { + if ($this->phpSheet->getSheetView()->getView() !== SheetView::SHEETVIEW_PAGE_LAYOUT) { //NOTE: this setting is inferior to page layout view(Excel2007-) - $view = $isPageBreakPreview ? \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_NORMAL; + $view = $isPageBreakPreview ? SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : SheetView::SHEETVIEW_NORMAL; $this->phpSheet->getSheetView()->setView($view); if ($this->version === self::XLS_BIFF8) { $zoomScale = $isPageBreakPreview ? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; @@ -4280,7 +4304,7 @@ class Xls extends BaseReader implements IReader $fWhitespaceHidden = ($grbit >> 3) & 0x01; //no support if ($fPageLayoutView === 1) { - $this->phpSheet->getSheetView()->setView(\PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT); + $this->phpSheet->getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT); $this->phpSheet->getSheetView()->setZoomScale($wScalePLV); //set by Excel2007 only if SHEETVIEW_PAGE_LAYOUT } //otherwise, we cannot know whether SHEETVIEW_PAGE_LAYOUT or SHEETVIEW_PAGE_BREAK_PREVIEW. @@ -4327,7 +4351,7 @@ class Xls extends BaseReader implements IReader if ($this->frozen) { // frozen panes - $this->phpSheet->freezePane(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($px) . ($py + 1)); + $this->phpSheet->freezePane(Cell::stringFromColumnIndex($px) . ($py + 1)); } // unfrozen panes; split windows; not supported by PhpSpreadsheet core } @@ -4388,7 +4412,7 @@ class Xls extends BaseReader implements IReader $includeCellRange = true; if ($this->getReadFilter() !== null) { $includeCellRange = false; - $rangeBoundaries = \PhpOffice\PhpSpreadsheet\Cell::getRangeBoundaries($cellRangeAddress); + $rangeBoundaries = Cell::getRangeBoundaries($cellRangeAddress); ++$rangeBoundaries[1][0]; for ($row = $rangeBoundaries[0][1]; $row <= $rangeBoundaries[1][1]; ++$row) { for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; ++$column) { @@ -4446,7 +4470,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 8; cell range address of all cells containing this hyperlink try { $cellRange = $this->readBIFF8CellRangeAddressFixed($recordData); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { return; } @@ -4596,7 +4620,7 @@ class Xls extends BaseReader implements IReader } // apply the hyperlink to all the relevant cells - foreach (\PhpOffice\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($cellRange) as $coordinate) { + foreach (Cell::extractAllCellReferencesInRange($cellRange) as $coordinate) { $this->phpSheet->getCell($coordinate)->getHyperLink()->setUrl($url); } } @@ -4636,28 +4660,28 @@ class Xls extends BaseReader implements IReader $type = (0x0000000F & $options) >> 0; switch ($type) { case 0x00: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE; + $type = DataValidation::TYPE_NONE; break; case 0x01: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE; + $type = DataValidation::TYPE_WHOLE; break; case 0x02: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL; + $type = DataValidation::TYPE_DECIMAL; break; case 0x03: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST; + $type = DataValidation::TYPE_LIST; break; case 0x04: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE; + $type = DataValidation::TYPE_DATE; break; case 0x05: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME; + $type = DataValidation::TYPE_TIME; break; case 0x06: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH; + $type = DataValidation::TYPE_TEXTLENGTH; break; case 0x07: - $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM; + $type = DataValidation::TYPE_CUSTOM; break; } @@ -4665,13 +4689,13 @@ class Xls extends BaseReader implements IReader $errorStyle = (0x00000070 & $options) >> 4; switch ($errorStyle) { case 0x00: - $errorStyle = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP; + $errorStyle = DataValidation::STYLE_STOP; break; case 0x01: - $errorStyle = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_WARNING; + $errorStyle = DataValidation::STYLE_WARNING; break; case 0x02: - $errorStyle = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION; + $errorStyle = DataValidation::STYLE_INFORMATION; break; } @@ -4695,28 +4719,28 @@ class Xls extends BaseReader implements IReader $operator = (0x00F00000 & $options) >> 20; switch ($operator) { case 0x00: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN; + $operator = DataValidation::OPERATOR_BETWEEN; break; case 0x01: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN; + $operator = DataValidation::OPERATOR_NOTBETWEEN; break; case 0x02: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL; + $operator = DataValidation::OPERATOR_EQUAL; break; case 0x03: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL; + $operator = DataValidation::OPERATOR_NOTEQUAL; break; case 0x04: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN; + $operator = DataValidation::OPERATOR_GREATERTHAN; break; case 0x05: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN; + $operator = DataValidation::OPERATOR_LESSTHAN; break; case 0x06: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL; + $operator = DataValidation::OPERATOR_GREATERTHANOREQUAL; break; case 0x07: - $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL; + $operator = DataValidation::OPERATOR_LESSTHANOREQUAL; break; } @@ -4755,10 +4779,10 @@ class Xls extends BaseReader implements IReader $formula1 = $this->getFormulaFromStructure($formula1); // in list type validity, null characters are used as item separators - if ($type == \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST) { + if ($type == DataValidation::TYPE_LIST) { $formula1 = str_replace(chr(0), ',', $formula1); } - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { return; } $offset += $sz1; @@ -4775,7 +4799,7 @@ class Xls extends BaseReader implements IReader $formula2 = pack('v', $sz2) . $formula2; // prepend the length try { $formula2 = $this->getFormulaFromStructure($formula2); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { return; } $offset += $sz2; @@ -4786,7 +4810,7 @@ class Xls extends BaseReader implements IReader foreach ($cellRangeAddresses as $cellRange) { $stRange = $this->phpSheet->shrinkRangeToFit($cellRange); - foreach (\PhpOffice\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($stRange) as $coordinate) { + foreach (Cell::extractAllCellReferencesInRange($stRange) as $coordinate) { $objValidation = $this->phpSheet->getCell($coordinate)->getDataValidation(); $objValidation->setType($type); $objValidation->setErrorStyle($errorStyle); @@ -4981,7 +5005,7 @@ class Xls extends BaseReader implements IReader for ($i = 0; $i < $cref; ++$i) { try { $cellRange = $this->readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8)); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { return; } $cellRanges[] = $cellRange; @@ -5063,7 +5087,7 @@ class Xls extends BaseReader implements IReader } //imagepng($ih, 'image.png'); - $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); + $drawing = new Drawing(); $drawing->setPath($filename); $drawing->setWorksheet($this->phpSheet); break; @@ -6624,7 +6648,7 @@ class Xls extends BaseReader implements IReader $cellAddress = $this->readBIFF8CellAddress(substr($formulaData, 3, 4)); $data = "$sheetRange!$cellAddress"; - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { // deleted sheet reference $data = '#REF!'; } @@ -6642,7 +6666,7 @@ class Xls extends BaseReader implements IReader $cellRangeAddress = $this->readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); $data = "$sheetRange!$cellRangeAddress"; - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { // deleted sheet reference $data = '#REF!'; } @@ -6676,7 +6700,7 @@ class Xls extends BaseReader implements IReader // offset: 2; size: 2; index to column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex(0x00FF & self::getInt2d($cellAddressStructure, 2)); + $column = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($cellAddressStructure, 2)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($cellAddressStructure, 2))) { @@ -6702,8 +6726,8 @@ class Xls extends BaseReader implements IReader */ private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') { - list($baseCol, $baseRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($baseCell); - $baseCol = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($baseCol) - 1; + list($baseCol, $baseRow) = Cell::coordinateFromString($baseCell); + $baseCol = Cell::columnIndexFromString($baseCol) - 1; // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) $rowIndex = self::getInt2d($cellAddressStructure, 0); @@ -6715,11 +6739,11 @@ class Xls extends BaseReader implements IReader // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($cellAddressStructure, 2))) { - $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($colIndex); + $column = Cell::stringFromColumnIndex($colIndex); $column = '$' . $column; } else { $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; - $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($baseCol + $colIndex); + $column = Cell::stringFromColumnIndex($baseCol + $colIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) @@ -6764,8 +6788,8 @@ class Xls extends BaseReader implements IReader } // column index to letter - $fc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($fc); - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($lc); + $fc = Cell::stringFromColumnIndex($fc); + $lc = Cell::stringFromColumnIndex($lc); if ($fr == $lr and $fc == $lc) { return "$fc$fr"; @@ -6805,8 +6829,8 @@ class Xls extends BaseReader implements IReader } // column index to letter - $fc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($fc); - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($lc); + $fc = Cell::stringFromColumnIndex($fc); + $lc = Cell::stringFromColumnIndex($lc); if ($fr == $lr and $fc == $lc) { return "$fc$fr"; @@ -6838,7 +6862,7 @@ class Xls extends BaseReader implements IReader // offset: 4; size: 2; index to first column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $fc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 4)); + $fc = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 4)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($subData, 4))) { @@ -6853,7 +6877,7 @@ class Xls extends BaseReader implements IReader // offset: 6; size: 2; index to last column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 6)); + $lc = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 6)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($subData, 6))) { @@ -6880,8 +6904,8 @@ class Xls extends BaseReader implements IReader */ private function readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') { - list($baseCol, $baseRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($baseCell); - $baseCol = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($baseCol) - 1; + list($baseCol, $baseRow) = Cell::coordinateFromString($baseCell); + $baseCol = Cell::columnIndexFromString($baseCol) - 1; // TODO: if cell range is just a single cell, should this funciton // not just return e.g. 'A1' and not 'A1:A1' ? @@ -6900,12 +6924,12 @@ class Xls extends BaseReader implements IReader // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($subData, 4))) { // absolute column index - $fc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($fcIndex); + $fc = Cell::stringFromColumnIndex($fcIndex); $fc = '$' . $fc; } else { // column offset $fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256; - $fc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($baseCol + $fcIndex); + $fc = Cell::stringFromColumnIndex($baseCol + $fcIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) @@ -6924,17 +6948,17 @@ class Xls extends BaseReader implements IReader // bit: 7-0; mask 0x00FF; column index $lcIndex = 0x00FF & self::getInt2d($subData, 6); $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256; - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($baseCol + $lcIndex); + $lc = Cell::stringFromColumnIndex($baseCol + $lcIndex); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) if (!(0x4000 & self::getInt2d($subData, 6))) { // absolute column index - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($lcIndex); + $lc = Cell::stringFromColumnIndex($lcIndex); $lc = '$' . $lc; } else { // column offset $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256; - $lc = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($baseCol + $lcIndex); + $lc = Cell::stringFromColumnIndex($baseCol + $lcIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) @@ -7395,7 +7419,7 @@ class Xls extends BaseReader implements IReader $string = self::uncompressByteString($string); } - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($string, 'UTF-8', 'UTF-16LE'); + return StringHelper::convertEncoding($string, 'UTF-8', 'UTF-16LE'); } /** @@ -7425,7 +7449,7 @@ class Xls extends BaseReader implements IReader */ private function decodeCodepage($string) { - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($string, 'UTF-8', $this->codepage); + return StringHelper::convertEncoding($string, 'UTF-8', $this->codepage); } /** @@ -7467,7 +7491,7 @@ class Xls extends BaseReader implements IReader private function parseRichText($is) { - $value = new \PhpOffice\PhpSpreadsheet\RichText(); + $value = new RichText(); $value->createText($is); return $value; diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php index 32ea6148..6d3d6340 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls; +use PhpOffice\PhpSpreadsheet\Reader\Xls; + class Color { /** @@ -24,7 +26,7 @@ class Color } // default color table - if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) { + if ($version == Xls::XLS_BIFF8) { return Color\BIFF8::lookup($color); } diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index fd6ae1d1..270272c6 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -2,6 +2,16 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Reader\Xls; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -100,7 +110,7 @@ class Escher // Parse Escher stream while ($this->pos < $this->dataSize) { // offset: 2; size: 2: Record Type - $fbt = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos + 2); + $fbt = Xls::getInt2d($this->data, $this->pos + 2); switch ($fbt) { case self::DGGCONTAINER: @@ -172,15 +182,15 @@ class Escher private function readDefault() { // offset 0; size: 2; recVer and recInstance - $verInstance = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos); + $verInstance = Xls::getInt2d($this->data, $this->pos); // offset: 2; size: 2: Record Type - $fbt = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos + 2); + $fbt = Xls::getInt2d($this->data, $this->pos + 2); // bit: 0-3; mask: 0x000F; recVer $recVer = (0x000F & $verInstance) >> 0; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -192,14 +202,14 @@ class Escher */ private function readDggContainer() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // record is a container, read contents - $dggContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer(); + $dggContainer = new DggContainer(); $this->object->setDggContainer($dggContainer); $reader = new self($dggContainer); $reader->load($recordData); @@ -210,7 +220,7 @@ class Escher */ private function readDgg() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -222,14 +232,14 @@ class Escher */ private function readBstoreContainer() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // record is a container, read contents - $bstoreContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer(); + $bstoreContainer = new BstoreContainer(); $this->object->setBstoreContainer($bstoreContainer); $reader = new self($bstoreContainer); $reader->load($recordData); @@ -243,16 +253,16 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // add BSE to BstoreContainer - $BSE = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE(); + $BSE = new BSE(); $this->object->addBSE($BSE); $BSE->setBLIPType($recInstance); @@ -267,16 +277,16 @@ class Escher $rgbUid = substr($recordData, 2, 16); // offset: 18; size: 2; tag - $tag = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 18); + $tag = Xls::getInt2d($recordData, 18); // offset: 20; size: 4; size of BLIP in bytes - $size = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($recordData, 20); + $size = Xls::getInt4d($recordData, 20); // offset: 24; size: 4; number of references to this BLIP - $cRef = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($recordData, 24); + $cRef = Xls::getInt4d($recordData, 24); // offset: 28; size: 4; MSOFO file offset - $foDelay = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($recordData, 28); + $foDelay = Xls::getInt4d($recordData, 28); // offset: 32; size: 1; unused1 $unused1 = ord($recordData[32]); @@ -297,7 +307,7 @@ class Escher $blipData = substr($recordData, 36 + $cbName); // record is a container, read contents - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls\Escher($BSE); + $reader = new self($BSE); $reader->load($blipData); } @@ -309,9 +319,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -336,7 +346,7 @@ class Escher // offset: var; size: var; the raw image data $data = substr($recordData, $pos); - $blip = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); + $blip = new Blip(); $blip->setData($data); $this->object->setBlip($blip); @@ -350,9 +360,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -377,7 +387,7 @@ class Escher // offset: var; size: var; the raw image data $data = substr($recordData, $pos); - $blip = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); + $blip = new Blip(); $blip->setData($data); $this->object->setBlip($blip); @@ -391,9 +401,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -410,9 +420,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -424,7 +434,7 @@ class Escher */ private function readSplitMenuColors() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -436,16 +446,16 @@ class Escher */ private function readDgContainer() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // record is a container, read contents - $dgContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer(); + $dgContainer = new DgContainer(); $this->object->setDgContainer($dgContainer); - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls\Escher($dgContainer); + $reader = new self($dgContainer); $escher = $reader->load($recordData); } @@ -454,7 +464,7 @@ class Escher */ private function readDg() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -468,16 +478,16 @@ class Escher { // context is either context DgContainer or SpgrContainer - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // record is a container, read contents - $spgrContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer(); + $spgrContainer = new SpgrContainer(); - if ($this->object instanceof \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer) { + if ($this->object instanceof DgContainer) { // DgContainer $this->object->setSpgrContainer($spgrContainer); } else { @@ -494,11 +504,11 @@ class Escher */ private function readSpContainer() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // add spContainer to spgrContainer - $spContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); + $spContainer = new SpContainer(); $this->object->addChild($spContainer); // move stream pointer to next record @@ -514,7 +524,7 @@ class Escher */ private function readSpgr() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -529,9 +539,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -546,9 +556,9 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -560,38 +570,38 @@ class Escher */ private function readClientAnchor() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record $this->pos += 8 + $length; // offset: 2; size: 2; upper-left corner column index (0-based) - $c1 = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 2); + $c1 = Xls::getInt2d($recordData, 2); // offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width - $startOffsetX = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 4); + $startOffsetX = Xls::getInt2d($recordData, 4); // offset: 6; size: 2; upper-left corner row index (0-based) - $r1 = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 6); + $r1 = Xls::getInt2d($recordData, 6); // offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height - $startOffsetY = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 8); + $startOffsetY = Xls::getInt2d($recordData, 8); // offset: 10; size: 2; bottom-right corner column index (0-based) - $c2 = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 10); + $c2 = Xls::getInt2d($recordData, 10); // offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width - $endOffsetX = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 12); + $endOffsetX = Xls::getInt2d($recordData, 12); // offset: 14; size: 2; bottom-right corner row index (0-based) - $r2 = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 14); + $r2 = Xls::getInt2d($recordData, 14); // offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height - $endOffsetY = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($recordData, 16); + $endOffsetY = Xls::getInt2d($recordData, 16); // set the start coordinates - $this->object->setStartCoordinates(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c1) . ($r1 + 1)); + $this->object->setStartCoordinates(Cell::stringFromColumnIndex($c1) . ($r1 + 1)); // set the start offsetX $this->object->setStartOffsetX($startOffsetX); @@ -600,7 +610,7 @@ class Escher $this->object->setStartOffsetY($startOffsetY); // set the end coordinates - $this->object->setEndCoordinates(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c2) . ($r2 + 1)); + $this->object->setEndCoordinates(Cell::stringFromColumnIndex($c2) . ($r2 + 1)); // set the end offsetX $this->object->setEndOffsetX($endOffsetX); @@ -614,7 +624,7 @@ class Escher */ private function readClientData() { - $length = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($this->data, $this->pos + 4); + $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); // move stream pointer to next record @@ -637,7 +647,7 @@ class Escher $fopte = substr($data, 6 * $i, 6); // offset: 0; size: 2; opid - $opid = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt2d($fopte, 0); + $opid = Xls::getInt2d($fopte, 0); // bit: 0-13; mask: 0x3FFF; opid.opid $opidOpid = (0x3FFF & $opid) >> 0; @@ -649,7 +659,7 @@ class Escher $opidFComplex = (0x8000 & $opid) >> 15; // offset: 2; size: 4; the value for this property - $op = \PhpOffice\PhpSpreadsheet\Reader\Xls::getInt4d($fopte, 2); + $op = Xls::getInt4d($fopte, 2); if ($opidFComplex) { $complexData = substr($splicedComplexData, 0, $op); diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index a0e98187..3d39016d 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -19,6 +19,7 @@ use PhpOffice\PhpSpreadsheet\Style; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; +use XMLReader; use ZipArchive; /** @@ -219,7 +220,7 @@ class Xlsx extends BaseReader implements IReader $fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')]; - $xml = new \XMLReader(); + $xml = new XMLReader(); $res = $xml->xml( $this->securityScanFile( 'zip://' . File::realpath($pFilename) . '#' . "$dir/$fileWorksheet" @@ -231,12 +232,12 @@ class Xlsx extends BaseReader implements IReader $currCells = 0; while ($xml->read()) { - if ($xml->name == 'row' && $xml->nodeType == \XMLReader::ELEMENT) { + if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) { $row = $xml->getAttribute('r'); $tmpInfo['totalRows'] = $row; $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells); $currCells = 0; - } elseif ($xml->name == 'c' && $xml->nodeType == \XMLReader::ELEMENT) { + } elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) { ++$currCells; } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 48564d6d..2e6c1d84 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -3,6 +3,16 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Chart\DataSeries; +use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues; +use PhpOffice\PhpSpreadsheet\Chart\Layout; +use PhpOffice\PhpSpreadsheet\Chart\Legend; +use PhpOffice\PhpSpreadsheet\Chart\PlotArea; +use PhpOffice\PhpSpreadsheet\Chart\Title; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Style\Color; +use PhpOffice\PhpSpreadsheet\Style\Font; +use SimpleXMLElement; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -29,11 +39,11 @@ use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Chart { /** - * @param \SimpleXMLElement $component + * @param SimpleXMLElement $component * @param string $name * @param string $format */ - private static function getAttribute(\SimpleXMLElement $component, $name, $format) + private static function getAttribute(SimpleXMLElement $component, $name, $format) { $attributes = $component->attributes(); if (isset($attributes[$name])) { @@ -56,15 +66,15 @@ class Chart if (isset($color['rgb'])) { return (string) $color['rgb']; } elseif (isset($color['indexed'])) { - return \PhpOffice\PhpSpreadsheet\Style\Color::indexedColor($color['indexed'] - 7, $background)->getARGB(); + return Color::indexedColor($color['indexed'] - 7, $background)->getARGB(); } } /** - * @param \SimpleXMLElement $chartElements + * @param SimpleXMLElement $chartElements * @param string $chartName */ - public static function readChart(\SimpleXMLElement $chartElements, $chartName) + public static function readChart(SimpleXMLElement $chartElements, $chartName) { $namespacesChartMeta = $chartElements->getNamespaces(true); $chartElementsC = $chartElements->children($namespacesChartMeta['c']); @@ -164,9 +174,9 @@ class Chart } } if ($plotAreaLayout == null) { - $plotAreaLayout = new \PhpOffice\PhpSpreadsheet\Chart\Layout(); + $plotAreaLayout = new Layout(); } - $plotArea = new \PhpOffice\PhpSpreadsheet\Chart\PlotArea($plotAreaLayout, $plotSeries); + $plotArea = new PlotArea($plotAreaLayout, $plotSeries); self::setChartAttributes($plotAreaLayout, $plotAttributes); break; case 'plotVisOnly': @@ -195,7 +205,7 @@ class Chart break; } } - $legend = new \PhpOffice\PhpSpreadsheet\Chart\Legend($legendPos, $legendLayout, $legendOverlay); + $legend = new Legend($legendPos, $legendLayout, $legendOverlay); break; } } @@ -206,7 +216,7 @@ class Chart return $chart; } - private static function chartTitle(\SimpleXMLElement $titleDetails, array $namespacesChartMeta) + private static function chartTitle(SimpleXMLElement $titleDetails, array $namespacesChartMeta) { $caption = []; $titleLayout = null; @@ -228,7 +238,7 @@ class Chart } } - return new \PhpOffice\PhpSpreadsheet\Chart\Title($caption, $titleLayout); + return new Title($caption, $titleLayout); } private static function chartLayoutDetails($chartDetail, $namespacesChartMeta) @@ -245,7 +255,7 @@ class Chart $layout[$detailKey] = self::getAttribute($detail, 'val', 'string'); } - return new \PhpOffice\PhpSpreadsheet\Chart\Layout($layout); + return new Layout($layout); } private static function chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) @@ -297,7 +307,7 @@ class Chart } } - return new \PhpOffice\PhpSpreadsheet\Chart\DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); + return new DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); } private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) @@ -306,24 +316,24 @@ class Chart $seriesSource = (string) $seriesDetail->strRef->f; $seriesData = self::chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']), 's'); - return new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); } elseif (isset($seriesDetail->numRef)) { $seriesSource = (string) $seriesDetail->numRef->f; $seriesData = self::chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c'])); - return new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); } elseif (isset($seriesDetail->multiLvlStrRef)) { $seriesSource = (string) $seriesDetail->multiLvlStrRef->f; $seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']), 's'); $seriesData['pointCount'] = count($seriesData['dataValues']); - return new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); } elseif (isset($seriesDetail->multiLvlNumRef)) { $seriesSource = (string) $seriesDetail->multiLvlNumRef->f; $seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']), 's'); $seriesData['pointCount'] = count($seriesData['dataValues']); - return new \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); } return null; @@ -399,9 +409,9 @@ class Chart ]; } - private static function parseRichText(\SimpleXMLElement $titleDetailPart) + private static function parseRichText(SimpleXMLElement $titleDetailPart) { - $value = new \PhpOffice\PhpSpreadsheet\RichText(); + $value = new RichText(); foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { if (isset($titleDetailElement->t)) { @@ -419,7 +429,7 @@ class Chart $fontColor = (self::getAttribute($titleDetailElement->rPr, 'color', 'string')); if (!is_null($fontColor)) { - $objText->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(self::readColor($fontColor))); + $objText->getFont()->setColor(new Color(self::readColor($fontColor))); } $bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean'); @@ -444,11 +454,11 @@ class Chart $underscore = (self::getAttribute($titleDetailElement->rPr, 'u', 'string')); if (!is_null($underscore)) { if ($underscore == 'sng') { - $objText->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); + $objText->getFont()->setUnderline(Font::UNDERLINE_SINGLE); } elseif ($underscore == 'dbl') { - $objText->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE); + $objText->getFont()->setUnderline(Font::UNDERLINE_DOUBLE); } else { - $objText->getFont()->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE); + $objText->getFont()->setUnderline(Font::UNDERLINE_NONE); } } @@ -497,10 +507,10 @@ class Chart } /** - * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea + * @param Layout $plotArea * @param mixed $plotAttributes */ - private static function setChartAttributes(\PhpOffice\PhpSpreadsheet\Chart\Layout $plotArea, $plotAttributes) + private static function setChartAttributes(Layout $plotArea, $plotAttributes) { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) { switch ($plotAttributeKey) { diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 00e29808..d7aff065 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -2,8 +2,18 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use DateTimeZone; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Document\Properties; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Settings; +use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Font; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -126,7 +136,7 @@ class Xml extends BaseReader implements IReader $xml = simplexml_load_string( $this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $namespaces = $xml->getNamespaces(true); @@ -155,7 +165,7 @@ class Xml extends BaseReader implements IReader $xml = simplexml_load_string( $this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $namespaces = $xml->getNamespaces(true); @@ -201,7 +211,7 @@ class Xml extends BaseReader implements IReader } } - $tmpInfo['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); + $tmpInfo['lastColumnLetter'] = Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1; $worksheetInfo[] = $tmpInfo; @@ -218,7 +228,7 @@ class Xml extends BaseReader implements IReader * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load($pFilename) { @@ -288,41 +298,41 @@ class Xml extends BaseReader implements IReader * Loads from file into Spreadsheet instance. * * @param string $pFilename - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws Exception * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ - public function loadIntoExisting($pFilename, \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) { $fromFormats = ['\-', '\ ']; $toFormats = ['-', ' ']; $underlineStyles = [ - \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE, - \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE, - \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING, - \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE, - \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING, + Font::UNDERLINE_NONE, + Font::UNDERLINE_DOUBLE, + Font::UNDERLINE_DOUBLEACCOUNTING, + Font::UNDERLINE_SINGLE, + Font::UNDERLINE_SINGLEACCOUNTING, ]; $verticalAlignmentStyles = [ - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY, + Alignment::VERTICAL_BOTTOM, + Alignment::VERTICAL_TOP, + Alignment::VERTICAL_CENTER, + Alignment::VERTICAL_JUSTIFY, ]; $horizontalAlignmentStyles = [ - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY, + Alignment::HORIZONTAL_GENERAL, + Alignment::HORIZONTAL_LEFT, + Alignment::HORIZONTAL_RIGHT, + Alignment::HORIZONTAL_CENTER, + Alignment::HORIZONTAL_CENTER_CONTINUOUS, + Alignment::HORIZONTAL_JUSTIFY, ]; - $timezoneObj = new \DateTimeZone('Europe/London'); - $GMT = new \DateTimeZone('UTC'); + $timezoneObj = new DateTimeZone('Europe/London'); + $GMT = new DateTimeZone('UTC'); File::assertFile($pFilename); if (!$this->canRead($pFilename)) { @@ -332,7 +342,7 @@ class Xml extends BaseReader implements IReader $xml = simplexml_load_string( $this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', - \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() + Settings::getLibXmlLoaderOptions() ); $namespaces = $xml->getNamespaces(true); @@ -382,26 +392,26 @@ class Xml extends BaseReader implements IReader foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { $propertyAttributes = $propertyValue->attributes($namespaces['dt']); $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', ['self', 'hex2str'], $propertyName); - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_UNKNOWN; + $propertyType = Properties::PROPERTY_TYPE_UNKNOWN; switch ((string) $propertyAttributes) { case 'string': - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_STRING; + $propertyType = Properties::PROPERTY_TYPE_STRING; $propertyValue = trim($propertyValue); break; case 'boolean': - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN; + $propertyType = Properties::PROPERTY_TYPE_BOOLEAN; $propertyValue = (bool) $propertyValue; break; case 'integer': - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_INTEGER; + $propertyType = Properties::PROPERTY_TYPE_INTEGER; $propertyValue = (int) $propertyValue; break; case 'float': - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_FLOAT; + $propertyType = Properties::PROPERTY_TYPE_FLOAT; $propertyValue = (float) $propertyValue; break; case 'dateTime.tz': - $propertyType = \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE; + $propertyType = Properties::PROPERTY_TYPE_DATE; $propertyValue = strtotime(trim($propertyValue)); break; } @@ -443,7 +453,7 @@ class Xml extends BaseReader implements IReader foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { switch ($borderStyleKey) { case 'LineStyle': - $thisBorder['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM; + $thisBorder['style'] = Border::BORDER_MEDIUM; break; case 'Weight': break; @@ -550,7 +560,7 @@ class Xml extends BaseReader implements IReader foreach ($worksheet->Table->Column as $columnData) { $columnData_ss = $columnData->attributes($namespaces['ss']); if (isset($columnData_ss['Index'])) { - $columnID = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnData_ss['Index'] - 1); + $columnID = Cell::stringFromColumnIndex($columnData_ss['Index'] - 1); } if (isset($columnData_ss['Width'])) { $columnWidth = $columnData_ss['Width']; @@ -574,7 +584,7 @@ class Xml extends BaseReader implements IReader foreach ($rowData->Cell as $cell) { $cell_ss = $cell->attributes($namespaces['ss']); if (isset($cell_ss['Index'])) { - $columnID = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($cell_ss['Index'] - 1); + $columnID = Cell::stringFromColumnIndex($cell_ss['Index'] - 1); } $cellRange = $columnID . $rowID; @@ -589,7 +599,7 @@ class Xml extends BaseReader implements IReader $columnTo = $columnID; if (isset($cell_ss['MergeAcross'])) { $additionalMergedCells += (int) $cell_ss['MergeAcross']; - $columnTo = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex(\PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] - 1); + $columnTo = Cell::stringFromColumnIndex(Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] - 1); } $rowTo = $rowID; if (isset($cell_ss['MergeDown'])) { @@ -611,7 +621,7 @@ class Xml extends BaseReader implements IReader } if (isset($cell->Data)) { $cellValue = $cellData = $cell->Data; - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL; + $type = Cell\DataType::TYPE_NULL; $cellData_ss = $cellData->attributes($namespaces['ss']); if (isset($cellData_ss['Type'])) { $cellDataType = $cellData_ss['Type']; @@ -627,32 +637,32 @@ class Xml extends BaseReader implements IReader */ case 'String': $cellValue = self::convertStringEncoding($cellValue, $this->charSet); - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING; + $type = Cell\DataType::TYPE_STRING; break; case 'Number': - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; + $type = Cell\DataType::TYPE_NUMERIC; $cellValue = (float) $cellValue; if (floor($cellValue) == $cellValue) { $cellValue = (int) $cellValue; } break; case 'Boolean': - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL; + $type = Cell\DataType::TYPE_BOOL; $cellValue = ($cellValue != 0); break; case 'DateTime': - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC; - $cellValue = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(strtotime($cellValue)); + $type = Cell\DataType::TYPE_NUMERIC; + $cellValue = Date::PHPToExcel(strtotime($cellValue)); break; case 'Error': - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR; + $type = Cell\DataType::TYPE_ERROR; break; } } if ($hasCalculatedValue) { - $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA; - $columnNumber = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnID); + $type = Cell\DataType::TYPE_FORMULA; + $columnNumber = Cell::columnIndexFromString($columnID); if (substr($cellDataFormula, 0, 3) == 'of:') { $cellDataFormula = substr($cellDataFormula, 3); $temp = explode('"', $cellDataFormula); @@ -696,7 +706,7 @@ class Xml extends BaseReader implements IReader if ($columnReference[0] == '[') { $columnReference = $columnNumber + trim($columnReference, '[]'); } - $A1CellReference = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; + $A1CellReference = Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } } @@ -764,7 +774,7 @@ class Xml extends BaseReader implements IReader protected static function convertStringEncoding($string, $charset) { if ($charset != 'UTF-8') { - return \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($string, 'UTF-8', $charset); + return StringHelper::convertEncoding($string, 'UTF-8', $charset); } return $string; @@ -772,7 +782,7 @@ class Xml extends BaseReader implements IReader protected function parseRichText($is) { - $value = new \PhpOffice\PhpSpreadsheet\RichText(); + $value = new RichText(); $value->createText(self::convertStringEncoding($is, $this->charSet)); diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 30eb9436..5bd291f2 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -807,7 +807,7 @@ class ReferenceHelper /** * Update named formulas (i.e. containing worksheet references / named ranges). * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Object to update + * @param Spreadsheet $spreadsheet Object to update * @param string $oldName Old name (name to replace) * @param string $newName New name */ diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 90fc21a9..a4d74173 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Style\Font; + /** * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,7 +30,7 @@ class Run extends TextElement implements ITextElement /** * Font. * - * @var \PhpOffice\PhpSpreadsheet\Style\Font + * @var Font */ private $font; @@ -40,13 +43,13 @@ class Run extends TextElement implements ITextElement { // Initialise variables $this->setText($pText); - $this->font = new \PhpOffice\PhpSpreadsheet\Style\Font(); + $this->font = new Font(); } /** * Get font. * - * @return \PhpOffice\PhpSpreadsheet\Style\Font + * @return Font */ public function getFont() { @@ -56,13 +59,13 @@ class Run extends TextElement implements ITextElement /** * Set font. * - * @param \PhpOffice\PhpSpreadsheet\Style\Font $pFont Font + * @param Font $pFont Font * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return ITextElement */ - public function setFont(\PhpOffice\PhpSpreadsheet\Style\Font $pFont = null) + public function setFont(Font $pFont = null) { $this->font = $pFont; diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index 6e56d231..a6ece3a6 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -32,7 +34,7 @@ class CodePage * * @param int $codePage Microsoft Code Page Indentifier * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return string Code Page Name */ @@ -44,7 +46,7 @@ class CodePage case 437: return 'CP437'; // OEM US case 720: - throw new \PhpOffice\PhpSpreadsheet\Exception('Code page 720 not supported.'); // OEM Arabic + throw new PhpSpreadsheetException('Code page 720 not supported.'); // OEM Arabic case 737: return 'CP737'; // OEM Greek case 775: @@ -146,12 +148,12 @@ class CodePage case 32768: return 'MAC'; // Apple Roman case 32769: - throw new \PhpOffice\PhpSpreadsheet\Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3) + throw new PhpSpreadsheetException('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3) case 65000: return 'UTF-7'; // Unicode (UTF-7) case 65001: return 'UTF-8'; // Unicode (UTF-8) } - throw new \PhpOffice\PhpSpreadsheet\Exception('Unknown codepage: ' . $codePage); + throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage); } } diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index a7409e38..185e643a 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -2,6 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use DateTimeInterface; +use DateTimeZone; +use PhpOffice\PhpSpreadsheet\Calculation\DateTime; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -112,7 +119,7 @@ class Date /** * Set the Default timezone to use for dates. * - * @param string|\DateTimeZone $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions + * @param string|DateTimeZone $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions * * @throws \Exception * @@ -133,12 +140,12 @@ class Date /** * Return the Default timezone being used for dates. * - * @return \DateTimeZone The timezone being used as default for Excel timestamp to PHP DateTime object + * @return DateTimeZone The timezone being used as default for Excel timestamp to PHP DateTime object */ public static function getDefaultTimezone() { if (self::$defaultTimeZone === null) { - self::$defaultTimeZone = new \DateTimeZone('UTC'); + self::$defaultTimeZone = new DateTimeZone('UTC'); } return self::$defaultTimeZone; @@ -147,19 +154,19 @@ class Date /** * Validate a timezone. * - * @param string|\DateTimeZone $timeZone The timezone to validate, either as a timezone string or object + * @param string|DateTimeZone $timeZone The timezone to validate, either as a timezone string or object * * @throws \Exception * - * @return \DateTimeZone The timezone as a timezone object - * @return \DateTimeZone The timezone as a timezone object + * @return DateTimeZone The timezone as a timezone object + * @return DateTimeZone The timezone as a timezone object */ protected static function validateTimeZone($timeZone) { - if (is_object($timeZone) && $timeZone instanceof \DateTimeZone) { + if (is_object($timeZone) && $timeZone instanceof DateTimeZone) { return $timeZone; } elseif (is_string($timeZone)) { - return new \DateTimeZone($timeZone); + return new DateTimeZone($timeZone); } throw new \Exception('Invalid timezone'); } @@ -168,7 +175,7 @@ class Date * Convert a MS serialized datetime value from Excel to a PHP Date/Time object. * * @param int|float $excelTimestamp MS Excel serialized date/time value - * @param \DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, + * @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, * if you don't want to treat it as a UTC value * Use the default (UST) unless you absolutely need a conversion * @@ -209,7 +216,7 @@ class Date * Convert a MS serialized datetime value from Excel to a unix timestamp. * * @param int|float $excelTimestamp MS Excel serialized date/time value - * @param \DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, + * @param DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp, * if you don't want to treat it as a UTC value * Use the default (UST) unless you absolutely need a conversion * @@ -233,7 +240,7 @@ class Date */ public static function PHPToExcel($dateValue) { - if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) { + if ((is_object($dateValue)) && ($dateValue instanceof DateTimeInterface)) { return self::dateTimeToExcel($dateValue); } elseif (is_numeric($dateValue)) { return self::timestampToExcel($dateValue); @@ -247,11 +254,11 @@ class Date /** * Convert a PHP DateTime object to an MS Excel serialized date/time value. * - * @param \DateTimeInterface $dateValue PHP DateTime object + * @param DateTimeInterface $dateValue PHP DateTime object * * @return float MS Excel serialized date/time value */ - public static function dateTimeToExcel(\DateTimeInterface $dateValue) + public static function dateTimeToExcel(DateTimeInterface $dateValue) { return self::formattedPHPToExcel( $dateValue->format('Y'), @@ -266,7 +273,7 @@ class Date /** * Convert a Unix timestamp to an MS Excel serialized date/time value. * - * @param \DateTimeInterface $dateValue Unix Timestamp + * @param DateTimeInterface $dateValue Unix Timestamp * * @return float MS Excel serialized date/time value */ @@ -329,11 +336,11 @@ class Date /** * Is a given cell a date/time? * - * @param \PhpOffice\PhpSpreadsheet\Cell $pCell + * @param Cell $pCell * * @return bool */ - public static function isDateTime(\PhpOffice\PhpSpreadsheet\Cell $pCell) + public static function isDateTime(Cell $pCell) { return self::isDateTimeFormat( $pCell->getWorksheet()->getStyle( @@ -345,11 +352,11 @@ class Date /** * Is a given number format a date/time? * - * @param \PhpOffice\PhpSpreadsheet\Style\NumberFormat $pFormat + * @param NumberFormat $pFormat * * @return bool */ - public static function isDateTimeFormat(\PhpOffice\PhpSpreadsheet\Style\NumberFormat $pFormat) + public static function isDateTimeFormat(NumberFormat $pFormat) { return self::isDateTimeFormatCode($pFormat->getFormatCode()); } @@ -365,7 +372,7 @@ class Date */ public static function isDateTimeFormatCode($pFormatCode) { - if (strtolower($pFormatCode) === strtolower(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_GENERAL)) { + if (strtolower($pFormatCode) === strtolower(NumberFormat::FORMAT_GENERAL)) { // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) return false; } @@ -377,28 +384,28 @@ class Date // Switch on formatcode switch ($pFormatCode) { // Explicitly defined date formats - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DMYSLASH: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DMYMINUS: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DMMINUS: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_MYMINUS: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME1: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME2: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME3: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME5: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME6: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME7: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME8: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDDSLASH: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX14: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX15: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX16: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX17: - case \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_XLSX22: + case NumberFormat::FORMAT_DATE_YYYYMMDD: + case NumberFormat::FORMAT_DATE_YYYYMMDD2: + case NumberFormat::FORMAT_DATE_DDMMYYYY: + case NumberFormat::FORMAT_DATE_DMYSLASH: + case NumberFormat::FORMAT_DATE_DMYMINUS: + case NumberFormat::FORMAT_DATE_DMMINUS: + case NumberFormat::FORMAT_DATE_MYMINUS: + case NumberFormat::FORMAT_DATE_DATETIME: + case NumberFormat::FORMAT_DATE_TIME1: + case NumberFormat::FORMAT_DATE_TIME2: + case NumberFormat::FORMAT_DATE_TIME3: + case NumberFormat::FORMAT_DATE_TIME4: + case NumberFormat::FORMAT_DATE_TIME5: + case NumberFormat::FORMAT_DATE_TIME6: + case NumberFormat::FORMAT_DATE_TIME7: + case NumberFormat::FORMAT_DATE_TIME8: + case NumberFormat::FORMAT_DATE_YYYYMMDDSLASH: + case NumberFormat::FORMAT_DATE_XLSX14: + case NumberFormat::FORMAT_DATE_XLSX15: + case NumberFormat::FORMAT_DATE_XLSX16: + case NumberFormat::FORMAT_DATE_XLSX17: + case NumberFormat::FORMAT_DATE_XLSX22: return true; } @@ -446,15 +453,15 @@ class Date return false; } - $dateValueNew = \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEVALUE($dateValue); + $dateValueNew = DateTime::DATEVALUE($dateValue); - if ($dateValueNew === \PhpOffice\PhpSpreadsheet\Calculation\Functions::VALUE()) { + if ($dateValueNew === Functions::VALUE()) { return false; } if (strpos($dateValue, ':') !== false) { - $timeValue = \PhpOffice\PhpSpreadsheet\Calculation\DateTime::TIMEVALUE($dateValue); - if ($timeValue === \PhpOffice\PhpSpreadsheet\Calculation\Functions::VALUE()) { + $timeValue = DateTime::TIMEVALUE($dateValue); + if ($timeValue === Functions::VALUE()) { return false; } $dateValueNew += $timeValue; diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index 436112be..0f88b8d7 100644 --- a/src/PhpSpreadsheet/Shared/Drawing.php +++ b/src/PhpSpreadsheet/Shared/Drawing.php @@ -70,13 +70,13 @@ class Drawing $name = $pDefaultFont->getName(); $size = $pDefaultFont->getSize(); - if (isset(\PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size])) { + if (isset(Font::$defaultColumnWidths[$name][$size])) { // Exact width can be determined - $colWidth = $pValue * \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size]['width'] / \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size]['px']; + $colWidth = $pValue * Font::$defaultColumnWidths[$name][$size]['width'] / Font::$defaultColumnWidths[$name][$size]['px']; } else { // We don't have data for this particular font and size, use approximation by // extrapolating from Calibri 11 - $colWidth = $pValue * 11 * \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths['Calibri'][11]['width'] / \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths['Calibri'][11]['px'] / $size; + $colWidth = $pValue * 11 * Font::$defaultColumnWidths['Calibri'][11]['width'] / Font::$defaultColumnWidths['Calibri'][11]['px'] / $size; } return $colWidth; @@ -96,13 +96,13 @@ class Drawing $name = $pDefaultFont->getName(); $size = $pDefaultFont->getSize(); - if (isset(\PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size])) { + if (isset(Font::$defaultColumnWidths[$name][$size])) { // Exact width can be determined - $colWidth = $pValue * \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size]['px'] / \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths[$name][$size]['width']; + $colWidth = $pValue * Font::$defaultColumnWidths[$name][$size]['px'] / Font::$defaultColumnWidths[$name][$size]['width']; } else { // We don't have data for this particular font and size, use approximation by // extrapolating from Calibri 11 - $colWidth = $pValue * $size * \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths['Calibri'][11]['px'] / \PhpOffice\PhpSpreadsheet\Shared\Font::$defaultColumnWidths['Calibri'][11]['width'] / 11; + $colWidth = $pValue * $size * Font::$defaultColumnWidths['Calibri'][11]['px'] / Font::$defaultColumnWidths['Calibri'][11]['width'] / 11; } // Round pixels to closest integer diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index c2b6787a..cf5cef72 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,7 +31,7 @@ class SpContainer /** * Parent Shape Group Container. * - * @var \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer + * @var SpgrContainer */ private $parent; @@ -113,7 +115,7 @@ class SpContainer /** * Set parent Shape Group Container. * - * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer $parent + * @param SpgrContainer $parent */ public function setParent($parent) { @@ -123,7 +125,7 @@ class SpContainer /** * Get the parent Shape Group Container. * - * @return \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer + * @return SpgrContainer */ public function getParent() { @@ -379,7 +381,7 @@ class SpContainer $nestingLevel = 0; $parent = $this->getParent(); - while ($parent instanceof \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer) { + while ($parent instanceof SpgrContainer) { ++$nestingLevel; $parent = $parent->getParent(); } diff --git a/src/PhpSpreadsheet/Shared/File.php b/src/PhpSpreadsheet/Shared/File.php index 9efd83ff..3b7b64ba 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use InvalidArgumentException; use ZipArchive; /** @@ -151,16 +152,16 @@ class File * * @param string $filename * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public static function assertFile($filename) { if (!is_file($filename)) { - throw new \InvalidArgumentException('File "' . $filename . '" does not exist.'); + throw new InvalidArgumentException('File "' . $filename . '" does not exist.'); } if (!is_readable($filename)) { - throw new \InvalidArgumentException('Could not open "' . $filename . '" for reading.'); + throw new InvalidArgumentException('Could not open "' . $filename . '" for reading.'); } } } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index befc2751..33ce9ace 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\RichText; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -236,7 +239,7 @@ class Font * Calculate an (approximate) OpenXML column width, based on font size and text contained. * * @param \PhpOffice\PhpSpreadsheet\Style\Font $font Font object - * @param \PhpOffice\PhpSpreadsheet\RichText|string $cellText Text to calculate width + * @param RichText|string $cellText Text to calculate width * @param int $rotation Rotation angle * @param \PhpOffice\PhpSpreadsheet\Style\Font|null $defaultFont Font object * @@ -245,7 +248,7 @@ class Font public static function calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText = '', $rotation = 0, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont = null) { // If it is rich text, use plain text - if ($cellText instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($cellText instanceof RichText) { $cellText = $cellText->getPlainText(); } @@ -268,7 +271,7 @@ class Font // Width of text in pixels excl. padding // and addition because Excel adds some padding, just use approx width of 'n' glyph $columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation) + $columnWidthAdjust; - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { $approximate = true; } } @@ -294,14 +297,14 @@ class Font * @param \PhpOffice\PhpSpreadsheet\Style\Font * @param int $rotation * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return int */ public static function getTextWidthPixelsExact($text, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0) { if (!function_exists('imagettfbbox')) { - throw new \PhpOffice\PhpSpreadsheet\Exception('GD library needs to be enabled'); + throw new PhpSpreadsheetException('GD library needs to be enabled'); } // font size should really be supplied in pixels in GD2, @@ -421,7 +424,7 @@ class Font public static function getTrueTypeFontFileFromFont($font) { if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Valid directory to TrueType Font files not specified'); + throw new PhpSpreadsheetException('Valid directory to TrueType Font files not specified'); } $name = $font->getName(); @@ -510,7 +513,7 @@ class Font ); break; default: - throw new \PhpOffice\PhpSpreadsheet\Exception('Unknown font name "' . $name . '". Cannot map to TrueType font file'); + throw new PhpSpreadsheetException('Unknown font name "' . $name . '". Cannot map to TrueType font file'); break; } @@ -518,7 +521,7 @@ class Font // Check if file actually exists if (!file_exists($fontFile)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('TrueType Font file not found'); + throw new PhpSpreadsheetException('TrueType Font file not found'); } return $fontFile; diff --git a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php index 99d20d8f..99c27711 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\JAMA; +use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; + /** * Cholesky decomposition class. * @@ -137,8 +139,8 @@ class CholeskyDecomposition return new Matrix($X, $this->m, $nx); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixSPDException)); + throw new CalculationException(JAMAError(MatrixSPDException)); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MATRIX_DIMENSION_EXCEPTION)); + throw new CalculationException(JAMAError(MATRIX_DIMENSION_EXCEPTION)); } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php index bf4b1636..624e39f1 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\JAMA; +use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; + /** * For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n * unit lower triangular matrix L, an n-by-n upper triangular matrix U, @@ -124,7 +126,7 @@ class LUDecomposition } } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(Matrix::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(Matrix::ARGUMENT_TYPE_EXCEPTION); } } @@ -233,7 +235,7 @@ class LUDecomposition return $d; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(Matrix::MATRIX_DIMENSION_EXCEPTION); + throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION); } // function det() @@ -243,8 +245,8 @@ class LUDecomposition * * @param $B a Matrix with as many rows as A and any number of columns * - * @throws \PhpOffice\PhpSpreadsheet\Calculation\Exception illegalArgumentException Matrix row dimensions must agree - * @throws \PhpOffice\PhpSpreadsheet\Calculation\Exception runtimeException Matrix is singular + * @throws CalculationException illegalArgumentException Matrix row dimensions must agree + * @throws CalculationException runtimeException Matrix is singular * * @return X so that L*U*X = B(piv,:) */ @@ -277,8 +279,8 @@ class LUDecomposition return $X; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::MATRIX_SINGULAR_EXCEPTION); + throw new CalculationException(self::MATRIX_SINGULAR_EXCEPTION); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::MATRIX_SQUARE_EXCEPTION); + throw new CalculationException(self::MATRIX_SQUARE_EXCEPTION); } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index c1e096dc..e9ec3d06 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -13,6 +13,10 @@ namespace PhpOffice\PhpSpreadsheet\Shared\JAMA; * @license PHP v3.0 * @see http://math.nist.gov/javanumerics/jama/ */ +use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + class Matrix { const POLYMORPHIC_ARGUMENT_EXCEPTION = 'Invalid argument pattern for polymorphic function.'; @@ -86,15 +90,15 @@ class Matrix } } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARRAY_LENGTH_EXCEPTION); + throw new CalculationException(self::ARRAY_LENGTH_EXCEPTION); } break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } } @@ -167,12 +171,12 @@ class Matrix if ($i0 >= 0) { $m = $this->m - $i0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } if ($j0 >= 0) { $n = $this->n - $j0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } $R = new self($m, $n); for ($i = $i0; $i < $this->m; ++$i) { @@ -189,12 +193,12 @@ class Matrix if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } $R = new self($m + 1, $n + 1); for ($i = $i0; $i <= $iF; ++$i) { @@ -211,12 +215,12 @@ class Matrix if (count($RL) > 0) { $m = count($RL); } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } if (count($CL) > 0) { $n = count($CL); } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } $R = new self($m, $n); for ($i = 0; $i < $m; ++$i) { @@ -233,12 +237,12 @@ class Matrix if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } if (count($CL) > 0) { $n = count($CL); } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } $R = new self($m, $n); for ($i = $i0; $i < $iF; ++$i) { @@ -255,12 +259,12 @@ class Matrix if (count($RL) > 0) { $m = count($RL); } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_BOUNDS_EXCEPTION); + throw new CalculationException(self::ARGUMENT_BOUNDS_EXCEPTION); } $R = new self($m, $n + 1); for ($i = 0; $i < $m; ++$i) { @@ -272,11 +276,11 @@ class Matrix return $R; break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } } @@ -295,9 +299,9 @@ class Matrix if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) { return true; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::MATRIX_DIMENSION_EXCEPTION); + throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } // function checkMatrixDimensions() @@ -376,7 +380,7 @@ class Matrix return $this->getMatrix($i0, 0, $i0 + 1, $this->n); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } /** @@ -398,7 +402,7 @@ class Matrix return $this->getMatrix(0, $j0, $this->m, $j0 + 1); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } /** @@ -470,14 +474,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -489,7 +493,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -511,14 +515,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -528,23 +532,23 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($value); + $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] += $value; } else { - $this->A[$i][$j] = \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAN(); + $this->A[$i][$j] = Functions::NAN(); } } } return $this; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -566,14 +570,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -585,7 +589,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -607,14 +611,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -624,23 +628,23 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($value); + $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] -= $value; } else { - $this->A[$i][$j] = \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAN(); + $this->A[$i][$j] = Functions::NAN(); } } } return $this; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -663,14 +667,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -682,7 +686,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -705,14 +709,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -722,23 +726,23 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($value); + $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] *= $value; } else { - $this->A[$i][$j] = \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAN(); + $this->A[$i][$j] = Functions::NAN(); } } } return $this; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -761,14 +765,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -778,11 +782,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($value); + $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { if ($value == 0) { @@ -792,14 +796,14 @@ class Matrix $M->set($i, $j, $this->A[$i][$j] / $value); } } else { - $M->set($i, $j, \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAN()); + $M->set($i, $j, Functions::NAN()); } } } return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -822,14 +826,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -841,7 +845,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -864,14 +868,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -883,7 +887,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -906,14 +910,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -925,7 +929,7 @@ class Matrix return $M; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -947,7 +951,7 @@ class Matrix if ($args[0] instanceof self) { $B = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } if ($this->n == $B->m) { $C = new self($this->m, $B->n); @@ -967,7 +971,7 @@ class Matrix return $C; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); + throw new CalculationException(JAMAError(MatrixDimensionMismatch)); case 'array': $B = new self($args[0]); if ($this->n == $B->m) { @@ -984,7 +988,7 @@ class Matrix return $C; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); + throw new CalculationException(JAMAError(MatrixDimensionMismatch)); case 'integer': $C = new self($this->A); for ($i = 0; $i < $C->m; ++$i) { @@ -1013,10 +1017,10 @@ class Matrix return $C; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } } @@ -1039,14 +1043,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -1056,23 +1060,23 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertToNumberIfFraction($value); + $validValues &= StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] = pow($this->A[$i][$j], $value); } else { - $this->A[$i][$j] = \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAN(); + $this->A[$i][$j] = Functions::NAN(); } } } return $this; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** @@ -1094,14 +1098,14 @@ class Matrix if ($args[0] instanceof self) { $M = $args[0]; } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION); } break; case 'array': $M = new self($args[0]); break; default: - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); break; } $this->checkMatrixDimensions($M); @@ -1113,7 +1117,7 @@ class Matrix return $this; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); + throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION); } /** diff --git a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php index 21644dab..55beef8b 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\JAMA; +use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; + /** * For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n * orthogonal matrix Q and an n-by-n upper triangular matrix R so that @@ -95,7 +97,7 @@ class QRDecomposition $this->Rdiag[$k] = -$nrm; } } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(Matrix::ARGUMENT_TYPE_EXCEPTION); + throw new CalculationException(Matrix::ARGUMENT_TYPE_EXCEPTION); } } @@ -246,8 +248,8 @@ class QRDecomposition return $X->getMatrix(0, $this->n - 1, 0, $nx); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::MATRIX_RANK_EXCEPTION); + throw new CalculationException(self::MATRIX_RANK_EXCEPTION); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(Matrix::MATRIX_DIMENSION_EXCEPTION); + throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION); } } diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index a2763f72..4f293659 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -26,6 +26,9 @@ namespace PhpOffice\PhpSpreadsheet\Shared; * OLE_ChainedBlockStream::stream_open(). * @var array */ +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; +use PhpOffice\PhpSpreadsheet\Shared\OLE\ChainedBlockStream; + $GLOBALS['_OLE_INSTANCES'] = []; /** @@ -101,7 +104,7 @@ class OLE * * @param string $file * - * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception + * @throws ReaderException * * @return bool true on success, PEAR_Error on failure */ @@ -109,18 +112,18 @@ class OLE { $fh = fopen($file, 'r'); if (!$fh) { - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception("Can't open file $file"); + throw new ReaderException("Can't open file $file"); } $this->_file_handle = $fh; $signature = fread($fh, 8); if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) { - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception("File doesn't seem to be an OLE container."); + throw new ReaderException("File doesn't seem to be an OLE container."); } fseek($fh, 28); if (fread($fh, 2) != "\xFE\xFF") { // This shouldn't be a problem in practice - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('Only Little-Endian encoding is supported.'); + throw new ReaderException('Only Little-Endian encoding is supported.'); } // Size of blocks and short blocks in bytes $this->bigBlockSize = pow(2, self::_readInt2($fh)); @@ -212,7 +215,7 @@ class OLE { static $isRegistered = false; if (!$isRegistered) { - stream_wrapper_register('ole-chainedblockstream', \PhpOffice\PhpSpreadsheet\Shared\OLE\ChainedBlockStream::class); + stream_wrapper_register('ole-chainedblockstream', ChainedBlockStream::class); $isRegistered = true; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index fdc3a879..c5b91999 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -20,6 +20,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE; // | Based on OLE::Storage_Lite by Kawai, Takanori | // +----------------------------------------------------------------------+ // +use PhpOffice\PhpSpreadsheet\Shared\OLE; /** * Class for creating PPS's for OLE containers. @@ -188,8 +189,8 @@ class PPS . "\xc0\x00\x00\x00" // 92 . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root . "\x00\x00\x00\x00" // 100 - . \PhpOffice\PhpSpreadsheet\Shared\OLE::localDateToOLE($this->Time1st) // 108 - . \PhpOffice\PhpSpreadsheet\Shared\OLE::localDateToOLE($this->Time2nd) // 116 + . OLE::localDateToOLE($this->Time1st) // 108 + . OLE::localDateToOLE($this->Time2nd) // 116 . pack('V', isset($this->startBlock) ? $this->startBlock : 0) // 120 . pack('V', $this->Size) // 124 . pack('V', 0); // 128 diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php index 1df6c73f..ffaf7e0c 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -20,6 +20,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; // | Based on OLE::Storage_Lite by Kawai, Takanori | // +----------------------------------------------------------------------+ // +use PhpOffice\PhpSpreadsheet\Shared\OLE; +use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; /** * Class for creating File PPS's for OLE containers. @@ -28,7 +30,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; * * @category PhpSpreadsheet */ -class File extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS +class File extends PPS { /** * The constructor. @@ -39,7 +41,7 @@ class File extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS */ public function __construct($name) { - parent::__construct(null, $name, \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_FILE, null, null, null, null, null, '', []); + parent::__construct(null, $name, OLE::OLE_PPS_TYPE_FILE, null, null, null, null, null, '', []); } /** diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 00b5710e..7e411397 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -20,6 +20,9 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; // | Based on OLE::Storage_Lite by Kawai, Takanori | // +----------------------------------------------------------------------+ // +use PhpOffice\PhpSpreadsheet\Shared\OLE; +use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * Class for creating Root PPS's for OLE containers. @@ -28,7 +31,7 @@ namespace PhpOffice\PhpSpreadsheet\Shared\OLE\PPS; * * @category PhpSpreadsheet */ -class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS +class Root extends PPS { /** * Directory for temporary files. @@ -46,7 +49,7 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS { $this->_tempDir = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(); - parent::__construct(null, \PhpOffice\PhpSpreadsheet\Shared\OLE::ascToUcs('Root Entry'), \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild); + parent::__construct(null, OLE::ascToUcs('Root Entry'), OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild); } /** @@ -58,7 +61,7 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS * * @param string|resource $filename the name of the file or stream where to save the OLE container * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return bool true on success */ @@ -83,17 +86,17 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS $this->_tmp_filename = tempnam($this->tempDirectory, 'OLE_PPS_Root'); $this->_FILEH_ = fopen($this->_tmp_filename, 'w+b'); if ($this->_FILEH_ == false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Can't create temporary file."); + throw new WriterException("Can't create temporary file."); } } else { $this->_FILEH_ = fopen($filename, 'wb'); } if ($this->_FILEH_ == false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Can't open $filename. It may be in use or protected."); + throw new WriterException("Can't open $filename. It may be in use or protected."); } // Make an array of PPS's (for Save) $aList = []; - \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS::_savePpsSetPnt($aList, [$this]); + PPS::_savePpsSetPnt($aList, [$this]); // calculate values for header list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); // Save Header @@ -131,9 +134,9 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS $iSBcnt = 0; $iCount = count($raList); for ($i = 0; $i < $iCount; ++$i) { - if ($raList[$i]->Type == \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_FILE) { + if ($raList[$i]->Type == OLE::OLE_PPS_TYPE_FILE) { $raList[$i]->Size = $raList[$i]->getDataLen(); - if ($raList[$i]->Size < \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) { + if ($raList[$i]->Size < OLE::OLE_DATA_SIZE_SMALL) { $iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) ? 1 : 0); } else { @@ -143,12 +146,12 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS } } $iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE; - $iSlCnt = floor($this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE); + $iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE::OLE_LONG_INT_SIZE); $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt) ? 1 : 0); $iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) + (($iSmallLen % $this->_BIG_BLOCK_SIZE) ? 1 : 0)); $iCnt = count($raList); - $iBdCnt = $this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_SIZE; + $iBdCnt = $this->_BIG_BLOCK_SIZE / OLE::OLE_PPS_SIZE; $iPPScnt = (floor($iCnt / $iBdCnt) + (($iCnt % $iBdCnt) ? 1 : 0)); return [$iSBDcnt, $iBBcnt, $iPPScnt]; @@ -182,8 +185,8 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS $FILE = $this->_FILEH_; // Calculate Basic Setting - $iBlCnt = $this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE; - $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE; + $iBlCnt = $this->_BIG_BLOCK_SIZE / OLE::OLE_LONG_INT_SIZE; + $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE::OLE_LONG_INT_SIZE; $iBdExL = 0; $iAll = $iBBcnt + $iPPScnt + $iSBDcnt; @@ -263,9 +266,9 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS // cycle through PPS's $iCount = count($raList); for ($i = 0; $i < $iCount; ++$i) { - if ($raList[$i]->Type != \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_DIR) { + if ($raList[$i]->Type != OLE::OLE_PPS_TYPE_DIR) { $raList[$i]->Size = $raList[$i]->getDataLen(); - if (($raList[$i]->Size >= \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) || (($raList[$i]->Type == \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) { + if (($raList[$i]->Size >= OLE::OLE_DATA_SIZE_SMALL) || (($raList[$i]->Type == OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) { fwrite($FILE, $raList[$i]->_data); if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) { @@ -295,11 +298,11 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS $iCount = count($raList); for ($i = 0; $i < $iCount; ++$i) { // Make SBD, small data string - if ($raList[$i]->Type == \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_TYPE_FILE) { + if ($raList[$i]->Type == OLE::OLE_PPS_TYPE_FILE) { if ($raList[$i]->Size <= 0) { continue; } - if ($raList[$i]->Size < \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) { + if ($raList[$i]->Size < OLE::OLE_DATA_SIZE_SMALL) { $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) ? 1 : 0); // Add to SBD @@ -320,7 +323,7 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS } } } - $iSbCnt = floor($this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE); + $iSbCnt = floor($this->_BIG_BLOCK_SIZE / OLE::OLE_LONG_INT_SIZE); if ($iSmBlk % $iSbCnt) { $iB = $iSbCnt - ($iSmBlk % $iSbCnt); for ($i = 0; $i < $iB; ++$i) { @@ -345,9 +348,9 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS } // Adjust for Block $iCnt = count($raList); - $iBCnt = $this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_SIZE; + $iBCnt = $this->_BIG_BLOCK_SIZE / OLE::OLE_PPS_SIZE; if ($iCnt % $iBCnt) { - fwrite($this->_FILEH_, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_PPS_SIZE)); + fwrite($this->_FILEH_, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * OLE::OLE_PPS_SIZE)); } } @@ -362,8 +365,8 @@ class Root extends \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS { $FILE = $this->_FILEH_; // Calculate Basic Setting - $iBbCnt = $this->_BIG_BLOCK_SIZE / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE; - $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE; + $iBbCnt = $this->_BIG_BLOCK_SIZE / OLE::OLE_LONG_INT_SIZE; + $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE::OLE_LONG_INT_SIZE; $iBdExL = 0; $iAll = $iBsize + $iPpsCnt + $iSbdSize; diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index 515a1fa3..3c36561e 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -26,6 +26,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared; * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ +use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; + defined('IDENTIFIER_OLE') || define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); @@ -71,7 +73,7 @@ class OLERead * * @param $pFilename string Filename * - * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception + * @throws ReaderException */ public function read($pFilename) { @@ -83,7 +85,7 @@ class OLERead // Check OLE identifier if ($this->data != self::IDENTIFIER_OLE) { - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('The filename ' . $pFilename . ' is not recognised as an OLE file'); + throw new ReaderException('The filename ' . $pFilename . ' is not recognised as an OLE file'); } // Get the file data @@ -303,10 +305,10 @@ class OLERead { if (trim($data) == '') { // No data provided - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('Parameter data is empty.'); + throw new ReaderException('Parameter data is empty.'); } elseif ($pos < 0) { // Invalid position - throw new \PhpOffice\PhpSpreadsheet\Reader\Exception('Parameter pos=' . $pos . ' is invalid.'); + throw new ReaderException('Parameter pos=' . $pos . ' is invalid.'); } $len = strlen($data); diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index b1d51250..b7e8e568 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use PhpOffice\PhpSpreadsheet\Calculation; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -588,7 +590,7 @@ class StringHelper if (preg_match('/^' . self::STRING_REGEXP_FRACTION . '$/i', $operand, $match)) { $sign = ($match[1] == '-') ? '-' : '+'; $fractionFormula = '=' . $sign . $match[2] . $sign . $match[3]; - $operand = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_calculateFormulaValue($fractionFormula); + $operand = Calculation::getInstance()->_calculateFormulaValue($fractionFormula); return true; } @@ -621,7 +623,7 @@ class StringHelper } /** - * Set the decimal separator. Only used by \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString() + * Set the decimal separator. Only used by NumberFormat::toFormattedString() * to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf. * * @param string $pValue Character for decimal separator @@ -654,7 +656,7 @@ class StringHelper } /** - * Set the thousands separator. Only used by \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString() + * Set the thousands separator. Only used by NumberFormat::toFormattedString() * to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf. * * @param string $pValue Character for thousands separator @@ -692,7 +694,7 @@ class StringHelper } /** - * Set the currency code. Only used by \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString() + * Set the currency code. Only used by NumberFormat::toFormattedString() * to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf. * * @param string $pValue Character for currency code diff --git a/src/PhpSpreadsheet/Shared/TimeZone.php b/src/PhpSpreadsheet/Shared/TimeZone.php index 46348cae..ac49c282 100644 --- a/src/PhpSpreadsheet/Shared/TimeZone.php +++ b/src/PhpSpreadsheet/Shared/TimeZone.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use DateTimeZone; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -43,7 +46,7 @@ class TimeZone */ private static function validateTimeZone($timezone) { - if (in_array($timezone, \DateTimeZone::listIdentifiers())) { + if (in_array($timezone, DateTimeZone::listIdentifiers())) { return true; } @@ -85,7 +88,7 @@ class TimeZone * @param string $timezone The timezone for finding the adjustment to UST * @param int $timestamp PHP date/time value * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return int Number of seconds for timezone adjustment */ @@ -93,7 +96,7 @@ class TimeZone { if ($timezone !== null) { if (!self::validateTimezone($timezone)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid timezone ' . $timezone); + throw new PhpSpreadsheetException('Invalid timezone ' . $timezone); } } else { $timezone = self::$timezone; @@ -103,7 +106,7 @@ class TimeZone return 0; } - $objTimezone = new \DateTimeZone($timezone); + $objTimezone = new DateTimeZone($timezone); $transitions = $objTimezone->getTransitions($timestamp, $timestamp); return (count($transitions) > 0) ? $transitions[0]['offset'] : 0; diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 822a3e70..24d2bd8a 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Shared\Trend; +use PhpOffice\PhpSpreadsheet\Shared\JAMA\Matrix; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index de7c29e5..1c8797dc 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Shared; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -31,7 +34,7 @@ class Xls * x is the width in intrinsic Excel units (measuring width in number of normal characters) * This holds for Arial 10. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet The sheet + * @param Worksheet $sheet The sheet * @param string $col The column * * @return int The width in pixels @@ -48,15 +51,15 @@ class Xls // then we have column dimension with explicit width $columnDimension = $columnDimensions[$col]; $width = $columnDimension->getWidth(); - $pixelWidth = \PhpOffice\PhpSpreadsheet\Shared\Drawing::cellDimensionToPixels($width, $font); + $pixelWidth = Drawing::cellDimensionToPixels($width, $font); } elseif ($sheet->getDefaultColumnDimension()->getWidth() != -1) { // then we have default column dimension with explicit width $defaultColumnDimension = $sheet->getDefaultColumnDimension(); $width = $defaultColumnDimension->getWidth(); - $pixelWidth = \PhpOffice\PhpSpreadsheet\Shared\Drawing::cellDimensionToPixels($width, $font); + $pixelWidth = Drawing::cellDimensionToPixels($width, $font); } else { // we don't even have any default column dimension. Width depends on default font - $pixelWidth = \PhpOffice\PhpSpreadsheet\Shared\Font::getDefaultColumnWidthByFont($font, true); + $pixelWidth = Font::getDefaultColumnWidthByFont($font, true); } // now find the effective column width in pixels @@ -74,7 +77,7 @@ class Xls * the relationship is: y = 4/3x. If the height hasn't been set by the user we * use the default value. If the row is hidden we use a value of zero. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet The sheet + * @param Worksheet $sheet The sheet * @param int $row The row index (1-based) * * @return int The width in pixels @@ -96,11 +99,11 @@ class Xls // then we have a default row dimension with explicit height $defaultRowDimension = $sheet->getDefaultRowDimension(); $rowHeight = $defaultRowDimension->getRowHeight(); - $pixelRowHeight = \PhpOffice\PhpSpreadsheet\Shared\Drawing::pointsToPixels($rowHeight); + $pixelRowHeight = Drawing::pointsToPixels($rowHeight); } else { // we don't even have any default row dimension. Height depends on default font - $pointRowHeight = \PhpOffice\PhpSpreadsheet\Shared\Font::getDefaultRowHeightByFont($font); - $pixelRowHeight = \PhpOffice\PhpSpreadsheet\Shared\Font::fontSizeToPixels($pointRowHeight); + $pointRowHeight = Font::getDefaultRowHeightByFont($font); + $pixelRowHeight = Font::fontSizeToPixels($pointRowHeight); } // now find the effective row height in pixels @@ -117,7 +120,7 @@ class Xls * Get the horizontal distance in pixels between two anchors * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet + * @param Worksheet $sheet * @param string $startColumn * @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param string $endColumn @@ -125,15 +128,15 @@ class Xls * * @return int Horizontal measured in pixels */ - public static function getDistanceX(\PhpOffice\PhpSpreadsheet\Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) + public static function getDistanceX(Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) { $distanceX = 0; // add the widths of the spanning columns - $startColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startColumn) - 1; // 1-based - $endColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($endColumn) - 1; // 1-based + $startColumnIndex = Cell::columnIndexFromString($startColumn) - 1; // 1-based + $endColumnIndex = Cell::columnIndexFromString($endColumn) - 1; // 1-based for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) { - $distanceX += self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i)); + $distanceX += self::sizeCol($sheet, Cell::stringFromColumnIndex($i)); } // correct for offsetX in startcell @@ -149,7 +152,7 @@ class Xls * Get the vertical distance in pixels between two anchors * The distanceY is found as sum of all the spanning rows minus two offsets. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet + * @param Worksheet $sheet * @param int $startRow (1-based) * @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height * @param int $endRow (1-based) @@ -157,7 +160,7 @@ class Xls * * @return int Vertical distance measured in pixels */ - public static function getDistanceY(\PhpOffice\PhpSpreadsheet\Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) + public static function getDistanceY(Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) { $distanceY = 0; @@ -219,7 +222,7 @@ class Xls * W is the width of the cell * H is the height of the cell * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $sheet + * @param Worksheet $sheet * @param string $coordinates E.g. 'A1' * @param int $offsetX Horizontal offset in pixels * @param int $offsetY Vertical offset in pixels @@ -230,8 +233,8 @@ class Xls */ public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) { - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($coordinates); - $col_start = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + list($column, $row) = Cell::coordinateFromString($coordinates); + $col_start = Cell::columnIndexFromString($column) - 1; $row_start = $row - 1; $x1 = $offsetX; @@ -242,7 +245,7 @@ class Xls $row_end = $row_start; // Row containing bottom right corner of object // Zero the specified offset if greater than the cell dimensions - if ($x1 >= self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) { + if ($x1 >= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start))) { $x1 = 0; } if ($y1 >= self::sizeRow($sheet, $row_start + 1)) { @@ -253,8 +256,8 @@ class Xls $height = $height + $y1 - 1; // Subtract the underlying cell widths to find the end cell of the image - while ($width >= self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end))) { - $width -= self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)); + while ($width >= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end))) { + $width -= self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end)); ++$col_end; } @@ -266,10 +269,10 @@ class Xls // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // with zero height or width. - if (self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start)) == 0) { + if (self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start)) == 0) { return; } - if (self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)) == 0) { + if (self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end)) == 0) { return; } if (self::sizeRow($sheet, $row_start + 1) == 0) { @@ -280,13 +283,13 @@ class Xls } // Convert the pixel values to the percentage value expected by Excel - $x1 = $x1 / self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start)) * 1024; + $x1 = $x1 / self::sizeCol($sheet, Cell::stringFromColumnIndex($col_start)) * 1024; $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; - $x2 = ($width + 1) / self::sizeCol($sheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object + $x2 = ($width + 1) / self::sizeCol($sheet, Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object - $startCoordinates = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start) . ($row_start + 1); - $endCoordinates = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end) . ($row_end + 1); + $startCoordinates = Cell::stringFromColumnIndex($col_start) . ($row_start + 1); + $endCoordinates = Cell::stringFromColumnIndex($col_end) . ($row_end + 1); $twoAnchor = [ 'startCoordinates' => $startCoordinates, diff --git a/src/PhpSpreadsheet/Style.php b/src/PhpSpreadsheet/Style.php index 65902077..8f7f9407 100644 --- a/src/PhpSpreadsheet/Style.php +++ b/src/PhpSpreadsheet/Style.php @@ -184,13 +184,13 @@ class Style extends Style\Supervisor implements IComparable * ), * 'borders' => array( * 'bottom' => array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) * ), * 'top' => array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 6ee25160..6ea74462 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Alignment extends Supervisor implements IComparable { /* Horizontal alignment styles */ const HORIZONTAL_GENERAL = 'general'; @@ -144,7 +147,6 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( * array( @@ -154,11 +156,11 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * 'wrap' => TRUE * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Alignment */ @@ -287,7 +289,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @param int $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Alignment */ @@ -307,7 +309,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara $this->textRotation = $pValue; } } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Text rotation should be a value between -90 and 90.'); + throw new PhpSpreadsheetException('Text rotation should be a value between -90 and 90.'); } return $this; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 9c2d8891..38246d47 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Border extends Supervisor implements IComparable { /* Border style */ const BORDER_NONE = 'none'; @@ -107,7 +110,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ @@ -119,7 +122,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable case 'inside': case 'outline': case 'vertical': - throw new \PhpOffice\PhpSpreadsheet\Exception('Cannot get shared component for a pseudo-border.'); + throw new PhpSpreadsheetException('Cannot get shared component for a pseudo-border.'); break; case 'bottom': return $this->parent->getSharedComponent()->getBottom(); @@ -167,7 +170,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray( * array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -177,7 +180,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ @@ -252,7 +255,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @param Color $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 06268d8b..bc599235 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Borders extends Supervisor implements IComparable { /* Diagonal directions */ const DIAGONAL_NONE = 0; @@ -180,18 +183,17 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( * array( * 'bottom' => array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) * ), * 'top' => array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -203,18 +205,18 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( * array( * 'allborders' => array( - * 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT, + * 'style' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) * ) * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Borders */ @@ -305,14 +307,14 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Get AllBorders (pseudo-border). Only applies to supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ public function getAllBorders() { if (!$this->isSupervisor) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Can only get pseudo-border for supervisor.'); + throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); } return $this->allBorders; @@ -321,14 +323,14 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Get Outline (pseudo-border). Only applies to supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return bool */ public function getOutline() { if (!$this->isSupervisor) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Can only get pseudo-border for supervisor.'); + throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); } return $this->outline; @@ -337,14 +339,14 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Get Inside (pseudo-border). Only applies to supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return bool */ public function getInside() { if (!$this->isSupervisor) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Can only get pseudo-border for supervisor.'); + throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); } return $this->inside; @@ -353,14 +355,14 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Get Vertical (pseudo-border). Only applies to supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ public function getVertical() { if (!$this->isSupervisor) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Can only get pseudo-border for supervisor.'); + throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); } return $this->vertical; @@ -369,14 +371,14 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Get Horizontal (pseudo-border). Only applies to supervisor. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Border */ public function getHorizontal() { if (!$this->isSupervisor) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Can only get pseudo-border for supervisor.'); + throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); } return $this->horizontal; diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 3fdd6308..ec5e6ffb 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Color extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Color extends Supervisor implements IComparable { /* Colors */ const COLOR_BLACK = 'FF000000'; @@ -141,14 +144,13 @@ class Color extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Color */ diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index 84578411..7ce31c31 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; +use PhpOffice\PhpSpreadsheet\Style; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +28,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable +class Conditional implements IComparable { /* Condition types */ const CONDITION_NONE = 'none'; @@ -92,7 +96,7 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable $this->operatorType = self::OPERATOR_NONE; $this->text = null; $this->condition = []; - $this->style = new \PhpOffice\PhpSpreadsheet\Style(false, true); + $this->style = new Style(false, true); } /** @@ -221,13 +225,13 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Style. * - * @param \PhpOffice\PhpSpreadsheet\Style $pValue + * @param Style $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Conditional */ - public function setStyle(\PhpOffice\PhpSpreadsheet\Style $pValue = null) + public function setStyle(Style $pValue = null) { $this->style = $pValue; diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 9cbf6841..dca4ea8d 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Fill extends Supervisor implements IComparable { /* Fill types */ const FILL_NONE = 'none'; @@ -131,11 +134,10 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray( * array( - * 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR, + * 'type' => Fill::FILL_GRADIENT_LINEAR, * 'rotation' => 0, * 'startcolor' => array( * 'rgb' => '000000' @@ -145,11 +147,11 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * ) * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Fill */ @@ -260,7 +262,7 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @param Color $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Fill */ @@ -294,7 +296,7 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @param Color $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Fill */ diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 3436382a..c51a945c 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Font extends Supervisor implements IComparable { /* Underline types */ const UNDERLINE_NONE = 'none'; @@ -156,7 +159,6 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray( * array( @@ -170,11 +172,11 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * ) * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Font */ @@ -524,7 +526,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @param Color $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Font */ diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 779fb2f9..21aaf40e 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -2,6 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +30,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class NumberFormat extends Supervisor implements IComparable { /* Pre-defined formats */ const FORMAT_GENERAL = 'General'; @@ -140,18 +146,17 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray( * array( - * 'code' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE + * 'code' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return NumberFormat */ @@ -493,7 +498,7 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp // escape any quoted characters so that DateTime format() will render them correctly $format = preg_replace_callback('/"(.*)"/U', ['self', 'escapeQuotesCallback'], $format); - $dateObj = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value); + $dateObj = Date::excelToDateTimeObject($value); $value = $dateObj->format($format); } @@ -524,7 +529,7 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp $decimalLength = strlen($decimalPart); $decimalDivisor = pow(10, $decimalLength); - $GCD = \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::GCD($decimalPart, $decimalDivisor); + $GCD = MathTrig::GCD($decimalPart, $decimalDivisor); $adjustedDecimalPart = $decimalPart / $GCD; $adjustedDecimalDivisor = $decimalDivisor / $GCD; @@ -717,8 +722,8 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp $value = number_format( $value, strlen($right), - \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getDecimalSeparator(), - \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getThousandsSeparator() + StringHelper::getDecimalSeparator(), + StringHelper::getThousandsSeparator() ); $value = preg_replace($number_regex, $value, $format); } else { @@ -741,7 +746,7 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp $currencyCode = $m[1]; list($currencyCode) = explode('-', $currencyCode); if ($currencyCode == '') { - $currencyCode = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::getCurrencyCode(); + $currencyCode = StringHelper::getCurrencyCode(); } $value = preg_replace('/\[\$([^\]]*)\]/u', $currencyCode, $value); } diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 848ac1be..1ad71588 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Style; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable +class Protection extends Supervisor implements IComparable { /** Protection styles */ const PROTECTION_INHERIT = 'inherit'; @@ -92,7 +95,6 @@ class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompar /** * Apply styles from array. - * * * $spreadsheet->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( * array( @@ -100,11 +102,11 @@ class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompar * 'hidden' => FALSE * ) * ); - * + * . * * @param array $pStyles Array containing style information * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Protection */ diff --git a/src/PhpSpreadsheet/Style/Supervisor.php b/src/PhpSpreadsheet/Style/Supervisor.php index d3b07929..b8c51f65 100644 --- a/src/PhpSpreadsheet/Style/Supervisor.php +++ b/src/PhpSpreadsheet/Style/Supervisor.php @@ -56,7 +56,7 @@ abstract class Supervisor /** * Bind parent. Only used for supervisor. * - * @param \PhpOffice\PhpSpreadsheet\Style $parent + * @param Style $parent * @param null|mixed $parentPropertyName * * @return Supervisor diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 4a6799d3..b2278e7d 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -1657,7 +1657,7 @@ class Worksheet implements IComparable * * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell - * @param int $pBreak Break type (type of \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_*) + * @param int $pBreak Break type (type of Worksheet::BREAK_*) * * @return Worksheet */ diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index a9298433..88042565 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -2,6 +2,14 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation\DateTime; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,7 +37,7 @@ class AutoFilter /** * Autofilter Worksheet. * - * @var \PhpOffice\PhpSpreadsheet\Worksheet + * @var Worksheet */ private $workSheet; @@ -51,9 +59,9 @@ class AutoFilter * Create a new AutoFilter. * * @param string $pRange Cell range (i.e. A1:E10) - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param Worksheet $pSheet */ - public function __construct($pRange = '', \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + public function __construct($pRange = '', Worksheet $pSheet = null) { $this->range = $pRange; $this->workSheet = $pSheet; @@ -62,7 +70,7 @@ class AutoFilter /** * Get AutoFilter Parent Worksheet. * - * @return \PhpOffice\PhpSpreadsheet\Worksheet + * @return Worksheet */ public function getParent() { @@ -72,11 +80,11 @@ class AutoFilter /** * Set AutoFilter Parent Worksheet. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param Worksheet $pSheet * * @return AutoFilter */ - public function setParent(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + public function setParent(Worksheet $pSheet = null) { $this->workSheet = $pSheet; @@ -98,7 +106,7 @@ class AutoFilter * * @param string $pRange Cell range (i.e. A1:E10) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter */ @@ -115,7 +123,7 @@ class AutoFilter } elseif (empty($pRange)) { $this->range = ''; } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Autofilter must be set on a range of cells.'); + throw new PhpSpreadsheetException('Autofilter must be set on a range of cells.'); } if (empty($pRange)) { @@ -123,9 +131,9 @@ class AutoFilter $this->columns = []; } else { // Discard any column rules that are no longer valid within this range - list($rangeStart, $rangeEnd) = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->range); + list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range); foreach ($this->columns as $key => $value) { - $colIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($key); + $colIndex = Cell::columnIndexFromString($key); if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { unset($this->columns[$key]); } @@ -138,7 +146,7 @@ class AutoFilter /** * Get all AutoFilter Columns. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter\Column[] */ @@ -152,20 +160,20 @@ class AutoFilter * * @param string $column Column name (e.g. A) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return int The column offset within the autofilter range */ public function testColumnInRange($column) { if (empty($this->range)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('No autofilter range is defined.'); + throw new PhpSpreadsheetException('No autofilter range is defined.'); } - $columnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column); - list($rangeStart, $rangeEnd) = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->range); + $columnIndex = Cell::columnIndexFromString($column); + list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range); if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Column is outside of current autofilter range.'); + throw new PhpSpreadsheetException('Column is outside of current autofilter range.'); } return $columnIndex - $rangeStart[0]; @@ -176,7 +184,7 @@ class AutoFilter * * @param string $pColumn Column name (e.g. A) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return int The offset of the specified column within the autofilter range */ @@ -190,7 +198,7 @@ class AutoFilter * * @param string $pColumn Column name (e.g. A) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter\Column */ @@ -210,14 +218,14 @@ class AutoFilter * * @param int $pColumnOffset Column offset within range (starting from 0) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter\Column */ public function getColumnByOffset($pColumnOffset) { - list($rangeStart, $rangeEnd) = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->range); - $pColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); + list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range); + $pColumn = Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); return $this->getColumn($pColumn); } @@ -228,7 +236,7 @@ class AutoFilter * @param AutoFilter\Column|string $pColumn * A simple string containing a Column ID like 'A' is permitted * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter */ @@ -239,7 +247,7 @@ class AutoFilter } elseif (is_object($pColumn) && ($pColumn instanceof AutoFilter\Column)) { $column = $pColumn->getColumnIndex(); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Column is not within the autofilter range.'); + throw new PhpSpreadsheetException('Column is not within the autofilter range.'); } $this->testColumnInRange($column); @@ -259,7 +267,7 @@ class AutoFilter * * @param string $pColumn Column name (e.g. A) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter */ @@ -340,7 +348,7 @@ class AutoFilter } if (is_numeric($cellValue)) { - $dateValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($cellValue); + $dateValue = Date::excelToTimestamp($cellValue); if ($cellValue < 1) { // Just the time part $dtVal = date('His', $dateValue); @@ -460,7 +468,7 @@ class AutoFilter } if (is_numeric($cellValue)) { - $dateValue = date('m', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($cellValue)); + $dateValue = date('m', Date::excelToTimestamp($cellValue)); if (in_array($dateValue, $monthSet)) { return true; } @@ -487,12 +495,12 @@ class AutoFilter */ private function dynamicFilterDateRange($dynamicRuleType, &$filterColumn) { - $rDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(); - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType(\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC); + $rDateType = Functions::getReturnDateType(); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); $val = $maxVal = null; $ruleValues = []; - $baseDate = \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATENOW(); + $baseDate = DateTime::DATENOW(); // Calculate start/end dates for the required date range based on current date switch ($dynamicRuleType) { case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK: @@ -525,41 +533,41 @@ class AutoFilter case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW: - $maxVal = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPtoExcel(strtotime('+1 day', $baseDate)); - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($baseDate); + $maxVal = (int) Date::PHPtoExcel(strtotime('+1 day', $baseDate)); + $val = (int) Date::PHPToExcel($baseDate); break; case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE: - $maxVal = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPtoExcel(strtotime('+1 day', $baseDate)); - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate))); + $maxVal = (int) Date::PHPtoExcel(strtotime('+1 day', $baseDate)); + $val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate))); break; case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR: - $maxVal = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate))); + $maxVal = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate))); ++$maxVal; - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate))); + $val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate))); break; case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER: $thisMonth = date('m', $baseDate); $thisQuarter = floor(--$thisMonth / 3); - $maxVal = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1 + $thisQuarter) * 3, date('Y', $baseDate))); + $maxVal = (int) Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1 + $thisQuarter) * 3, date('Y', $baseDate))); ++$maxVal; - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1 + $thisQuarter * 3, date('Y', $baseDate))); + $val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1 + $thisQuarter * 3, date('Y', $baseDate))); break; case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH: - $maxVal = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate))); + $maxVal = (int) Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate))); ++$maxVal; - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate))); + $val = (int) Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate))); break; case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK: $dayOfWeek = date('w', $baseDate); - $val = (int) \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($baseDate) - $dayOfWeek; + $val = (int) Date::PHPToExcel($baseDate) - $dayOfWeek; $maxVal = $val + 7; break; } @@ -582,7 +590,7 @@ class AutoFilter // Set the rules for identifying rows for hide/show $ruleValues[] = ['operator' => AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL, 'value' => $val]; $ruleValues[] = ['operator' => AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN, 'value' => $maxVal]; - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType($rDateType); + Functions::setReturnDateType($rDateType); return ['method' => 'filterTestInCustomDataSet', 'arguments' => ['filterRules' => $ruleValues, 'join' => AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND]]; } @@ -590,7 +598,7 @@ class AutoFilter private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) { $range = $columnID . $startRow . ':' . $columnID . $endRow; - $dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($this->workSheet->rangeToArray($range, null, true, false)); + $dataValues = Functions::flattenArray($this->workSheet->rangeToArray($range, null, true, false)); $dataValues = array_filter($dataValues); if ($ruleType == AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) { @@ -605,13 +613,13 @@ class AutoFilter /** * Apply the AutoFilter rules to the AutoFilter Range. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return AutoFilter */ public function showHideRows() { - list($rangeStart, $rangeEnd) = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->range); + list($rangeStart, $rangeEnd) = Cell::rangeBoundaries($this->range); // The heading row should always be visible $this->workSheet->getRowDimension($rangeStart[1])->setVisible(true); @@ -721,7 +729,7 @@ class AutoFilter // Number (Average) based // Calculate the average $averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')'; - $average = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1')); + $average = Calculation::getInstance()->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1')); // Set above/below rule based on greaterThan or LessTan $operator = ($dynamicRuleType === AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) ? AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 305d70bf..11698ff8 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -68,7 +71,7 @@ class Column /** * Autofilter. * - * @var \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter + * @var AutoFilter */ private $parent; @@ -111,9 +114,9 @@ class Column * Create a new Column. * * @param string $pColumn Column (e.g. A) - * @param \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter $pParent Autofilter for this column + * @param AutoFilter $pParent Autofilter for this column */ - public function __construct($pColumn, \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter $pParent = null) + public function __construct($pColumn, AutoFilter $pParent = null) { $this->columnIndex = $pColumn; $this->parent = $pParent; @@ -134,7 +137,7 @@ class Column * * @param string $pColumn Column (e.g. A) * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column */ @@ -154,7 +157,7 @@ class Column /** * Get this Column's AutoFilter Parent. * - * @return \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter + * @return AutoFilter */ public function getParent() { @@ -168,7 +171,7 @@ class Column * * @return Column */ - public function setParent(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter $pParent = null) + public function setParent(AutoFilter $pParent = null) { $this->parent = $pParent; @@ -190,14 +193,14 @@ class Column * * @param string $pFilterType * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column */ public function setFilterType($pFilterType) { if (!in_array($pFilterType, self::$filterTypes)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid filter type for column AutoFilter.'); + throw new PhpSpreadsheetException('Invalid filter type for column AutoFilter.'); } $this->filterType = $pFilterType; @@ -220,7 +223,7 @@ class Column * * @param string $pJoin And/Or * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column */ @@ -229,7 +232,7 @@ class Column // Lowercase And/Or $pJoin = strtolower($pJoin); if (!in_array($pJoin, self::$ruleJoins)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid rule connection for column AutoFilter.'); + throw new PhpSpreadsheetException('Invalid rule connection for column AutoFilter.'); } $this->join = $pJoin; @@ -242,7 +245,7 @@ class Column * * @param string[] $attributes * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column */ @@ -259,7 +262,7 @@ class Column * @param string $pName Attribute Name * @param string $pValue Attribute Value * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column */ @@ -299,7 +302,7 @@ class Column /** * Get all AutoFilter Column Rules. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Column\Rule[] */ diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index bdf6fd52..37f52cbf 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -222,7 +225,7 @@ class Rule /** * Autofilter Column. * - * @var \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column + * @var Column */ private $parent = null; @@ -257,9 +260,9 @@ class Rule /** * Create a new Rule. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column $pParent + * @param Column $pParent */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column $pParent = null) + public function __construct(Column $pParent = null) { $this->parent = $pParent; } @@ -279,14 +282,14 @@ class Rule * * @param string $pRuleType see self::AUTOFILTER_RULETYPE_* * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Rule */ public function setRuleType($pRuleType) { if (!in_array($pRuleType, self::$ruleTypes)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid rule type for column AutoFilter Rule.'); + throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.'); } $this->ruleType = $pRuleType; @@ -309,7 +312,7 @@ class Rule * * @param string|string[] $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Rule */ @@ -328,7 +331,7 @@ class Rule } } if (count($pValue) == 0) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid rule value for column AutoFilter Rule.'); + throw new PhpSpreadsheetException('Invalid rule value for column AutoFilter Rule.'); } // Set the dateTime grouping that we've anticipated $this->setGrouping(self::$dateTimeGroups[$grouping]); @@ -353,7 +356,7 @@ class Rule * * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_* * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Rule */ @@ -364,7 +367,7 @@ class Rule } if ((!in_array($pOperator, self::$operators)) && (!in_array($pOperator, self::$topTenValue))) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid operator for column AutoFilter Rule.'); + throw new PhpSpreadsheetException('Invalid operator for column AutoFilter Rule.'); } $this->operator = $pOperator; @@ -386,7 +389,7 @@ class Rule * * @param string $pGrouping * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Rule */ @@ -396,7 +399,7 @@ class Rule (!in_array($pGrouping, self::$dateTimeGroups)) && (!in_array($pGrouping, self::$dynamicTypes)) && (!in_array($pGrouping, self::$topTenType))) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid rule type for column AutoFilter Rule.'); + throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.'); } $this->grouping = $pGrouping; @@ -410,7 +413,7 @@ class Rule * @param string|string[] $pValue * @param string $pGrouping * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Rule */ @@ -431,7 +434,7 @@ class Rule /** * Get this Rule's AutoFilter Column Parent. * - * @return \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column + * @return Column */ public function getParent() { @@ -445,7 +448,7 @@ class Rule * * @return Rule */ - public function setParent(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column $pParent = null) + public function setParent(Column $pParent = null) { $this->parent = $pParent; diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index 9f975309..9f9ad163 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +28,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable +class BaseDrawing implements IComparable { /** * Image counter. @@ -210,14 +214,14 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Worksheet. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pValue + * @param Worksheet $pValue * @param bool $pOverrideOld If a Worksheet has already been assigned, overwrite it and remove image from old Worksheet? * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return BaseDrawing */ - public function setWorksheet(\PhpOffice\PhpSpreadsheet\Worksheet $pValue = null, $pOverrideOld = false) + public function setWorksheet(Worksheet $pValue = null, $pOverrideOld = false) { if (is_null($this->worksheet)) { // Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet @@ -240,7 +244,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable // Set new \PhpOffice\PhpSpreadsheet\Worksheet $this->setWorksheet($pValue); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception("A \PhpOffice\PhpSpreadsheet\Worksheet has already been assigned. Drawings can only exist on one \PhpOffice\PhpSpreadsheet\Worksheet."); + throw new PhpSpreadsheetException("A Worksheet has already been assigned. Drawings can only exist on one \PhpOffice\PhpSpreadsheet\Worksheet."); } } @@ -479,7 +483,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @param Drawing\Shadow $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return BaseDrawing */ diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php index cc3b10ea..195307f0 100644 --- a/src/PhpSpreadsheet/Worksheet/CellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -27,7 +29,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; abstract class CellIterator { /** - * \PhpOffice\PhpSpreadsheet\Worksheet to iterate. + * Worksheet to iterate. * * @var \PhpOffice\PhpSpreadsheet\Worksheet */ @@ -68,7 +70,7 @@ abstract class CellIterator /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ abstract protected function adjustForExistingOnlyRange(); @@ -77,7 +79,7 @@ abstract class CellIterator * * @param bool $value * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function setIterateOnlyExistingCells($value) { diff --git a/src/PhpSpreadsheet/Worksheet/Column.php b/src/PhpSpreadsheet/Worksheet/Column.php index d1e40750..12aa2a40 100644 --- a/src/PhpSpreadsheet/Worksheet/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Column.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -43,10 +45,10 @@ class Column /** * Create a new column. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent + * @param Worksheet $parent * @param string $columnIndex */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $parent = null, $columnIndex = 'A') + public function __construct(Worksheet $parent = null, $columnIndex = 'A') { // Set parent and column index $this->parent = $parent; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 8fcef2fb..1538b825 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -50,16 +54,16 @@ class ColumnCellIterator extends CellIterator implements \Iterator /** * Create a new row iterator. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $subject The worksheet to iterate over + * @param Worksheet $subject The worksheet to iterate over * @param string $columnIndex The column that we want to iterate * @param int $startRow The row number at which to start iterating * @param int $endRow Optionally, the row number at which to stop iterating */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null) + public function __construct(Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null) { // Set subject $this->subject = $subject; - $this->columnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnIndex) - 1; + $this->columnIndex = Cell::columnIndexFromString($columnIndex) - 1; $this->resetEnd($endRow); $this->resetStart($startRow); } @@ -77,7 +81,7 @@ class ColumnCellIterator extends CellIterator implements \Iterator * * @param int $startRow The row number at which to start iterating * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return ColumnCellIterator */ @@ -95,7 +99,7 @@ class ColumnCellIterator extends CellIterator implements \Iterator * * @param int $endRow The row number at which to stop iterating * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return ColumnCellIterator */ @@ -112,16 +116,16 @@ class ColumnCellIterator extends CellIterator implements \Iterator * * @param int $row The row number to set the current pointer at * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return ColumnCellIterator */ public function seek($row = 1) { if (($row < $this->startRow) || ($row > $this->endRow)) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})"); + throw new PhpSpreadsheetException("Row $row is out of range ({$this->startRow} - {$this->endRow})"); } elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($this->columnIndex, $row))) { - throw new \PhpOffice\PhpSpreadsheet\Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); + throw new PhpSpreadsheetException('In "IterateOnlyExistingCells" mode and Cell does not exist'); } $this->position = $row; @@ -139,7 +143,7 @@ class ColumnCellIterator extends CellIterator implements \Iterator /** * Return the current cell in this worksheet column. * - * @return null|\PhpOffice\PhpSpreadsheet\Cell + * @return null|Cell */ public function current() { @@ -174,7 +178,7 @@ class ColumnCellIterator extends CellIterator implements \Iterator public function prev() { if ($this->position <= $this->startRow) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); + throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); } do { @@ -197,7 +201,7 @@ class ColumnCellIterator extends CellIterator implements \Iterator /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ protected function adjustForExistingOnlyRange() { @@ -207,14 +211,14 @@ class ColumnCellIterator extends CellIterator implements \Iterator ++$this->startRow; } if ($this->startRow > $this->endRow) { - throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range'); + throw new PhpSpreadsheetException('No cells exist within the specified range'); } while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) && ($this->endRow >= $this->startRow)) { --$this->endRow; } if ($this->endRow < $this->startRow) { - throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range'); + throw new PhpSpreadsheetException('No cells exist within the specified range'); } } } diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index 9dfc6db9..77e931cb 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -4,23 +4,22 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Exception; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. - * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * @category PhpSpreadsheet * @@ -30,7 +29,7 @@ use PhpOffice\PhpSpreadsheet\Exception; class ColumnIterator implements \Iterator { /** - * \PhpOffice\PhpSpreadsheet\Worksheet to iterate. + * Worksheet to iterate. * * @var \PhpOffice\PhpSpreadsheet\Worksheet */ @@ -60,11 +59,11 @@ class ColumnIterator implements \Iterator /** * Create a new column iterator. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $subject The worksheet to iterate over + * @param Worksheet $subject The worksheet to iterate over * @param string $startColumn The column address at which to start iterating * @param string $endColumn Optionally, the column address at which to stop iterating */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $subject, $startColumn = 'A', $endColumn = null) + public function __construct(Worksheet $subject, $startColumn = 'A', $endColumn = null) { // Set subject $this->subject = $subject; @@ -91,7 +90,7 @@ class ColumnIterator implements \Iterator */ public function resetStart($startColumn = 'A') { - $startColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startColumn) - 1; + $startColumnIndex = Cell::columnIndexFromString($startColumn) - 1; if ($startColumnIndex > Cell::columnIndexFromString($this->subject->getHighestColumn()) - 1) { throw new Exception("Start column ({$startColumn}) is beyond highest column ({$this->subject->getHighestColumn()})"); } @@ -115,7 +114,7 @@ class ColumnIterator implements \Iterator public function resetEnd($endColumn = null) { $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn(); - $this->endColumn = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($endColumn) - 1; + $this->endColumn = Cell::columnIndexFromString($endColumn) - 1; return $this; } @@ -125,15 +124,15 @@ class ColumnIterator implements \Iterator * * @param string $column The column address to set the current pointer at * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return ColumnIterator */ public function seek($column = 'A') { - $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + $column = Cell::columnIndexFromString($column) - 1; if (($column < $this->startColumn) || ($column > $this->endColumn)) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); + throw new PhpSpreadsheetException("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); } $this->position = $column; @@ -155,7 +154,7 @@ class ColumnIterator implements \Iterator */ public function current() { - return new Column($this->subject, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->position)); + return new Column($this->subject, Cell::stringFromColumnIndex($this->position)); } /** @@ -165,7 +164,7 @@ class ColumnIterator implements \Iterator */ public function key() { - return \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->position); + return Cell::stringFromColumnIndex($this->position); } /** @@ -179,18 +178,13 @@ class ColumnIterator implements \Iterator /** * Set the iterator to its previous value. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function prev() { if ($this->position <= $this->startColumn) { - throw new \PhpOffice\PhpSpreadsheet\Exception( - 'Column is already at the beginning of range (' . - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->endColumn) . ' - ' . - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->endColumn) . ')' - ); + throw new PhpSpreadsheetException('Column is already at the beginning of range (' . Cell::stringFromColumnIndex($this->endColumn) . ' - ' . Cell::stringFromColumnIndex($this->endColumn) . ')'); } - --$this->position; } diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index 2ff18512..0f172d36 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -101,19 +103,18 @@ abstract class Dimension /** * Set Outline Level. - * - * Value must be between 0 and 7 + * Value must be between 0 and 7. * * @param int $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Dimension */ public function setOutlineLevel($pValue) { if ($pValue < 0 || $pValue > 7) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Outline level must range between 0 and 7.'); + throw new PhpSpreadsheetException('Outline level must range between 0 and 7.'); } $this->outlineLevel = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 8154e501..3341ac9d 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Drawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable +class Drawing extends BaseDrawing implements IComparable { /** * Path. @@ -96,7 +99,7 @@ class Drawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparab * @param string $pValue File path * @param bool $pVerifyFile Verify file * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Drawing */ @@ -111,7 +114,7 @@ class Drawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparab list($this->width, $this->height) = getimagesize($pValue); } } else { - throw new \PhpOffice\PhpSpreadsheet\Exception("File $pValue not found!"); + throw new PhpSpreadsheetException("File $pValue not found!"); } } else { $this->path = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index 54f23a83..22a70289 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet\Drawing; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; +use PhpOffice\PhpSpreadsheet\Style\Color; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +28,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet\Drawing; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable +class Shadow implements IComparable { /* Shadow alignment */ const SHADOW_BOTTOM = 'b'; @@ -78,7 +82,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable /** * Color. * - * @var \PhpOffice\PhpSpreadsheet\Style\Color + * @var Color */ private $color; @@ -100,7 +104,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable $this->distance = 2; $this->direction = 0; $this->alignment = self::SHADOW_BOTTOM_RIGHT; - $this->color = new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK); + $this->color = new Color(Color::COLOR_BLACK); $this->alpha = 50; } @@ -227,7 +231,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable /** * Get Color. * - * @return \PhpOffice\PhpSpreadsheet\Style\Color + * @return Color */ public function getColor() { @@ -237,13 +241,13 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Color. * - * @param \PhpOffice\PhpSpreadsheet\Style\Color $pValue + * @param Color $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return Shadow */ - public function setColor(\PhpOffice\PhpSpreadsheet\Style\Color $pValue = null) + public function setColor(Color $pValue = null) { $this->color = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 92760132..4b58ac49 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -424,7 +426,7 @@ class HeaderFooter * @param HeaderFooterDrawing $image * @param string $location * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return HeaderFooter */ @@ -440,7 +442,7 @@ class HeaderFooter * * @param string $location * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return HeaderFooter */ @@ -458,7 +460,7 @@ class HeaderFooter * * @param HeaderFooterDrawing[] $images * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return HeaderFooter */ diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php index 6db76ff5..274339dd 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\IComparable +class HeaderFooterDrawing extends Drawing implements IComparable { /** * Path. @@ -318,7 +321,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * @param string $pValue File path * @param bool $pVerifyFile Verify file * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return HeaderFooterDrawing */ @@ -333,7 +336,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I list($this->width, $this->height) = getimagesize($pValue); } } else { - throw new \PhpOffice\PhpSpreadsheet\Exception("File $pValue not found!"); + throw new PhpSpreadsheetException("File $pValue not found!"); } } else { $this->path = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Iterator.php b/src/PhpSpreadsheet/Worksheet/Iterator.php index c7cdbc19..d7406aec 100644 --- a/src/PhpSpreadsheet/Worksheet/Iterator.php +++ b/src/PhpSpreadsheet/Worksheet/Iterator.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,7 +31,7 @@ class Iterator implements \Iterator /** * Spreadsheet to iterate. * - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $subject; @@ -43,9 +45,9 @@ class Iterator implements \Iterator /** * Create a new worksheet iterator. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $subject + * @param Spreadsheet $subject */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $subject = null) + public function __construct(Spreadsheet $subject = null) { // Set subject $this->subject = $subject; diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index b543b8d0..f085d0e1 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\IComparable; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -24,7 +26,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class MemoryDrawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable +class MemoryDrawing extends BaseDrawing implements IComparable { /* Rendering functions */ const RENDERING_DEFAULT = 'imagepng'; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 8e40ca1d..f001ecaf 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -335,14 +338,13 @@ class PageSetup /** * Set Scale. - * * Print scaling. Valid values range from 10 to 400 - * This setting is overridden when fitToWidth and/or fitToHeight are in use + * This setting is overridden when fitToWidth and/or fitToHeight are in use. * * @param int|null $pValue * @param bool $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return PageSetup */ @@ -356,7 +358,7 @@ class PageSetup $this->fitToPage = false; } } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Scale must not be negative'); + throw new PhpSpreadsheetException('Scale must not be negative'); } return $this; @@ -608,7 +610,7 @@ class PageSetup * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return string */ @@ -621,7 +623,7 @@ class PageSetup if (isset($printAreas[$index - 1])) { return $printAreas[$index - 1]; } - throw new \PhpOffice\PhpSpreadsheet\Exception('Requested Print Area does not exist'); + throw new PhpSpreadsheetException('Requested Print Area does not exist'); } /** @@ -687,18 +689,18 @@ class PageSetup * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return PageSetup */ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) { if (strpos($value, '!') !== false) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Cell coordinate must not specify a worksheet.'); + throw new PhpSpreadsheetException('Cell coordinate must not specify a worksheet.'); } elseif (strpos($value, ':') === false) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Cell coordinate must be a range of cells.'); + throw new PhpSpreadsheetException('Cell coordinate must be a range of cells.'); } elseif (strpos($value, '$') !== false) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Cell coordinate must not be absolute.'); + throw new PhpSpreadsheetException('Cell coordinate must not be absolute.'); } $value = strtoupper($value); @@ -711,7 +713,7 @@ class PageSetup $index = count($printAreas) - abs($index) + 1; } if (($index <= 0) || ($index > count($printAreas))) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid index for setting print range.'); + throw new PhpSpreadsheetException('Invalid index for setting print range.'); } $printAreas[$index - 1] = $value; $this->printArea = implode(',', $printAreas); @@ -725,13 +727,13 @@ class PageSetup $index = abs($index) - 1; } if ($index > count($printAreas)) { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid index for setting print range.'); + throw new PhpSpreadsheetException('Invalid index for setting print range.'); } $printAreas = array_merge(array_slice($printAreas, 0, $index), [$value], array_slice($printAreas, $index)); $this->printArea = implode(',', $printAreas); } } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid method for setting print range.'); + throw new PhpSpreadsheetException('Invalid method for setting print range.'); } return $this; @@ -748,7 +750,7 @@ class PageSetup * list. * Print areas are numbered from 1 * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return PageSetup */ @@ -778,14 +780,14 @@ class PageSetup * Default behaviour, or the "O" method, overwrites existing print area * The "I" method, inserts the new print area before any specified index, or at the end of the list * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return PageSetup */ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) { return $this->setPrintArea( - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column1) . $row1 . ':' . \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column2) . $row2, + Cell::stringFromColumnIndex($column1) . $row1 . ':' . Cell::stringFromColumnIndex($column2) . $row2, $index, $method ); @@ -805,14 +807,14 @@ class PageSetup * list. * Print areas are numbered from 1 * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return PageSetup */ public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) { return $this->setPrintArea( - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column1) . $row1 . ':' . \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column2) . $row2, + Cell::stringFromColumnIndex($column1) . $row1 . ':' . Cell::stringFromColumnIndex($column2) . $row2, $index, self::SETPRINTRANGE_INSERT ); diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index ddb2dac3..ef96ba58 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Shared\PasswordHasher; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -582,7 +584,7 @@ class Protection public function setPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { - $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); + $pValue = PasswordHasher::hashPassword($pValue); } $this->password = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index 5e565980..7a438e6f 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -43,10 +45,10 @@ class Row /** * Create a new row. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $parent + * @param Worksheet $parent * @param int $rowIndex */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet = null, $rowIndex = 1) + public function __construct(Worksheet $worksheet = null, $rowIndex = 1) { // Set parent and row index $this->worksheet = $worksheet; diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 8ae0eb63..de111d42 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -2,22 +2,23 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. - * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * @category PhpSpreadsheet * @@ -50,12 +51,12 @@ class RowCellIterator extends CellIterator implements \Iterator /** * Create a new column iterator. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $subject The worksheet to iterate over + * @param Worksheet $subject The worksheet to iterate over * @param int $rowIndex The row that we want to iterate * @param string $startColumn The column address at which to start iterating * @param string $endColumn Optionally, the column address at which to stop iterating */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) + public function __construct(Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) { // Set subject and row index $this->subject = $subject; @@ -77,16 +78,16 @@ class RowCellIterator extends CellIterator implements \Iterator * * @param int $startColumn The column address at which to start iterating * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return RowCellIterator */ public function resetStart($startColumn = 'A') { - $startColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($startColumn) - 1; + $startColumnIndex = Cell::columnIndexFromString($startColumn) - 1; $this->startColumn = $startColumnIndex; $this->adjustForExistingOnlyRange(); - $this->seek(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->startColumn)); + $this->seek(Cell::stringFromColumnIndex($this->startColumn)); return $this; } @@ -96,14 +97,14 @@ class RowCellIterator extends CellIterator implements \Iterator * * @param string $endColumn The column address at which to stop iterating * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return RowCellIterator */ public function resetEnd($endColumn = null) { $endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn(); - $this->endColumn = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($endColumn) - 1; + $this->endColumn = Cell::columnIndexFromString($endColumn) - 1; $this->adjustForExistingOnlyRange(); return $this; @@ -114,17 +115,17 @@ class RowCellIterator extends CellIterator implements \Iterator * * @param string $column The column address to set the current pointer at * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return RowCellIterator */ public function seek($column = 'A') { - $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + $column = Cell::columnIndexFromString($column) - 1; if (($column < $this->startColumn) || ($column > $this->endColumn)) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); + throw new PhpSpreadsheetException("Column $column is out of range ({$this->startColumn} - {$this->endColumn})"); } elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($column, $this->rowIndex))) { - throw new \PhpOffice\PhpSpreadsheet\Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); + throw new PhpSpreadsheetException('In "IterateOnlyExistingCells" mode and Cell does not exist'); } $this->position = $column; @@ -142,7 +143,7 @@ class RowCellIterator extends CellIterator implements \Iterator /** * Return the current cell in this worksheet row. * - * @return \PhpOffice\PhpSpreadsheet\Cell + * @return Cell */ public function current() { @@ -156,7 +157,7 @@ class RowCellIterator extends CellIterator implements \Iterator */ public function key() { - return \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->position); + return Cell::stringFromColumnIndex($this->position); } /** @@ -166,31 +167,22 @@ class RowCellIterator extends CellIterator implements \Iterator { do { ++$this->position; - } while (($this->onlyExistingCells) && - (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && - ($this->position <= $this->endColumn)); + } while (($this->onlyExistingCells) && (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && ($this->position <= $this->endColumn)); } /** * Set the iterator to its previous value. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function prev() { if ($this->position <= $this->startColumn) { - throw new \PhpOffice\PhpSpreadsheet\Exception( - 'Column is already at the beginning of range (' . - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->endColumn) . ' - ' . - \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($this->endColumn) . ')' - ); + throw new PhpSpreadsheetException('Column is already at the beginning of range (' . Cell::stringFromColumnIndex($this->endColumn) . ' - ' . Cell::stringFromColumnIndex($this->endColumn) . ')'); } - do { --$this->position; - } while (($this->onlyExistingCells) && - (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && - ($this->position >= $this->startColumn)); + } while (($this->onlyExistingCells) && (!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) && ($this->position >= $this->startColumn)); } /** @@ -206,24 +198,22 @@ class RowCellIterator extends CellIterator implements \Iterator /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ protected function adjustForExistingOnlyRange() { if ($this->onlyExistingCells) { - while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) && - ($this->startColumn <= $this->endColumn)) { + while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) && ($this->startColumn <= $this->endColumn)) { ++$this->startColumn; } if ($this->startColumn > $this->endColumn) { - throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range'); + throw new PhpSpreadsheetException('No cells exist within the specified range'); } - while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) && - ($this->endColumn >= $this->startColumn)) { + while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) && ($this->endColumn >= $this->startColumn)) { --$this->endColumn; } if ($this->endColumn < $this->startColumn) { - throw new \PhpOffice\PhpSpreadsheet\Exception('No cells exist within the specified range'); + throw new PhpSpreadsheetException('No cells exist within the specified range'); } } } diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index b92f8c9e..2aa63329 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -27,7 +30,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; class RowIterator implements \Iterator { /** - * \PhpOffice\PhpSpreadsheet\Worksheet to iterate. + * Worksheet to iterate. * * @var \PhpOffice\PhpSpreadsheet\Worksheet */ @@ -57,11 +60,11 @@ class RowIterator implements \Iterator /** * Create a new row iterator. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $subject The worksheet to iterate over + * @param Worksheet $subject The worksheet to iterate over * @param int $startRow The row number at which to start iterating * @param int $endRow Optionally, the row number at which to stop iterating */ - public function __construct(\PhpOffice\PhpSpreadsheet\Worksheet $subject, $startRow = 1, $endRow = null) + public function __construct(Worksheet $subject, $startRow = 1, $endRow = null) { // Set subject $this->subject = $subject; @@ -82,14 +85,14 @@ class RowIterator implements \Iterator * * @param int $startRow The row number at which to start iterating * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return RowIterator */ public function resetStart($startRow = 1) { if ($startRow > $this->subject->getHighestRow()) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Start row ({$startRow}) is beyond highest row ({$this->subject->getHighestRow()})"); + throw new PhpSpreadsheetException("Start row ({$startRow}) is beyond highest row ({$this->subject->getHighestRow()})"); } $this->startRow = $startRow; @@ -120,14 +123,14 @@ class RowIterator implements \Iterator * * @param int $row The row number to set the current pointer at * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return RowIterator */ public function seek($row = 1) { if (($row < $this->startRow) || ($row > $this->endRow)) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})"); + throw new PhpSpreadsheetException("Row $row is out of range ({$this->startRow} - {$this->endRow})"); } $this->position = $row; @@ -173,12 +176,12 @@ class RowIterator implements \Iterator /** * Set the iterator to its previous value. * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function prev() { if ($this->position <= $this->startRow) { - throw new \PhpOffice\PhpSpreadsheet\Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); + throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); } --$this->position; diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 7ce233ce..0966cbc3 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -83,12 +85,11 @@ class SheetView /** * Set ZoomScale. - * * Valid values range from 10 to 400. * * @param int $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return SheetView */ @@ -99,7 +100,7 @@ class SheetView if (($pValue >= 1) || is_null($pValue)) { $this->zoomScale = $pValue; } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Scale must be greater than or equal to 1.'); + throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); } return $this; @@ -117,12 +118,11 @@ class SheetView /** * Set ZoomScale. - * * Valid values range from 10 to 400. * * @param int $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return SheetView */ @@ -131,7 +131,7 @@ class SheetView if (($pValue >= 1) || is_null($pValue)) { $this->zoomScaleNormal = $pValue; } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Scale must be greater than or equal to 1.'); + throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.'); } return $this; @@ -157,7 +157,7 @@ class SheetView * * @param string $pValue * - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException * * @return SheetView */ @@ -170,7 +170,7 @@ class SheetView if (in_array($pValue, self::$sheetViewTypes)) { $this->sheetviewType = $pValue; } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid sheetview layout type.'); + throw new PhpSpreadsheetException('Invalid sheetview layout type.'); } return $this; diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 4ed6f89d..4dfb498a 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -86,9 +89,9 @@ class Csv extends BaseWriter implements IWriter /** * Create a new CSV. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Spreadsheet object + * @param Spreadsheet $spreadsheet Spreadsheet object */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function __construct(Spreadsheet $spreadsheet) { $this->spreadsheet = $spreadsheet; } @@ -105,10 +108,10 @@ class Csv extends BaseWriter implements IWriter // Fetch sheet $sheet = $this->spreadsheet->getSheet($this->sheetIndex); - $saveDebugLog = \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog(); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false); - $saveArrayReturnType = \PhpOffice\PhpSpreadsheet\Calculation::getArrayReturnType(); - \PhpOffice\PhpSpreadsheet\Calculation::setArrayReturnType(\PhpOffice\PhpSpreadsheet\Calculation::RETURN_ARRAY_AS_VALUE); + $saveDebugLog = Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog(); + Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false); + $saveArrayReturnType = Calculation::getArrayReturnType(); + Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'wb+'); @@ -147,8 +150,8 @@ class Csv extends BaseWriter implements IWriter // Close file fclose($fileHandle); - \PhpOffice\PhpSpreadsheet\Calculation::setArrayReturnType($saveArrayReturnType); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); + Calculation::setArrayReturnType($saveArrayReturnType); + Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** diff --git a/src/PhpSpreadsheet/Writer/Exception.php b/src/PhpSpreadsheet/Writer/Exception.php index b0f4d618..5c0a8023 100644 --- a/src/PhpSpreadsheet/Writer/Exception.php +++ b/src/PhpSpreadsheet/Writer/Exception.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -24,7 +26,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class Exception extends \PhpOffice\PhpSpreadsheet\Exception +class Exception extends PhpSpreadsheetException { /** * Error handler callback. diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index f87812c7..0a08bc0b 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -3,9 +3,25 @@ namespace PhpOffice\PhpSpreadsheet\Writer; use PhpOffice\PhpSpreadsheet\Calculation; -use PhpOffice\PhpSpreadsheet\Shared\Font; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Chart; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\Drawing as SharedDrawing; +use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Shared\Font as SharedFont; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Borders; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * Copyright (c) 2006 - 2015 Spreadsheet. @@ -83,7 +99,7 @@ class Html extends BaseWriter implements IWriter /** * Default font. * - * @var \PhpOffice\PhpSpreadsheet\Style\Font + * @var Font */ private $defaultFont; @@ -132,7 +148,7 @@ class Html extends BaseWriter implements IWriter /** * Create a new HTML. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet */ public function __construct(Spreadsheet $spreadsheet) { @@ -145,7 +161,7 @@ class Html extends BaseWriter implements IWriter * * @param string $pFilename * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ public function save($pFilename) { @@ -163,7 +179,7 @@ class Html extends BaseWriter implements IWriter // Open file $fileHandle = fopen($pFilename, 'wb+'); if ($fileHandle === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not open file $pFilename for writing."); + throw new WriterException("Could not open file $pFilename for writing."); } // Write headers @@ -197,12 +213,12 @@ class Html extends BaseWriter implements IWriter private function mapVAlign($vAlign) { switch ($vAlign) { - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM: + case Alignment::VERTICAL_BOTTOM: return 'bottom'; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP: + case Alignment::VERTICAL_TOP: return 'top'; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER: - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY: + case Alignment::VERTICAL_CENTER: + case Alignment::VERTICAL_JUSTIFY: return 'middle'; default: return 'baseline'; @@ -219,16 +235,16 @@ class Html extends BaseWriter implements IWriter private function mapHAlign($hAlign) { switch ($hAlign) { - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL: + case Alignment::HORIZONTAL_GENERAL: return false; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT: + case Alignment::HORIZONTAL_LEFT: return 'left'; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT: + case Alignment::HORIZONTAL_RIGHT: return 'right'; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER: - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS: + case Alignment::HORIZONTAL_CENTER: + case Alignment::HORIZONTAL_CENTER_CONTINUOUS: return 'center'; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY: + case Alignment::HORIZONTAL_JUSTIFY: return 'justify'; default: return false; @@ -245,33 +261,33 @@ class Html extends BaseWriter implements IWriter private function mapBorderStyle($borderStyle) { switch ($borderStyle) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: return 'none'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: return '1px dashed'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: return '1px dotted'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: return '1px dashed'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: return '1px dotted'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: return '3px double'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: return '1px solid'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: return '2px solid'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: return '2px dashed'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: return '2px dotted'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: return '2px dashed'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: return '2px dashed'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: return '3px solid'; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: return '1px solid'; default: // map others to thin @@ -342,7 +358,7 @@ class Html extends BaseWriter implements IWriter * * @param bool $pIncludeStyles Include styles? * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ @@ -350,7 +366,7 @@ class Html extends BaseWriter implements IWriter { // Spreadsheet object known? if (is_null($this->spreadsheet)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Internal Spreadsheet object not set to an instance of an object.'); + throw new WriterException('Internal Spreadsheet object not set to an instance of an object.'); } // Construct HTML @@ -402,7 +418,7 @@ class Html extends BaseWriter implements IWriter /** * Generate sheet data. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ @@ -410,7 +426,7 @@ class Html extends BaseWriter implements IWriter { // Spreadsheet object known? if (is_null($this->spreadsheet)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Internal Spreadsheet object not set to an instance of an object.'); + throw new WriterException('Internal Spreadsheet object not set to an instance of an object.'); } // Ensure that Spans have been calculated? @@ -437,10 +453,10 @@ class Html extends BaseWriter implements IWriter // Get worksheet dimension $dimension = explode(':', $sheet->calculateWorksheetDimension()); - $dimension[0] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($dimension[0]); - $dimension[0][0] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($dimension[0][0]) - 1; - $dimension[1] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($dimension[1]); - $dimension[1][0] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($dimension[1][0]) - 1; + $dimension[0] = Cell::coordinateFromString($dimension[0]); + $dimension[0][0] = Cell::columnIndexFromString($dimension[0][0]) - 1; + $dimension[1] = Cell::coordinateFromString($dimension[1]); + $dimension[1][0] = Cell::columnIndexFromString($dimension[1][0]) - 1; // row min,max $rowMin = $dimension[0][1]; @@ -484,7 +500,7 @@ class Html extends BaseWriter implements IWriter while ($column++ < $dimension[1][0]) { // Cell exists? if ($sheet->cellExistsByColumnAndRow($column, $row)) { - $rowData[$column] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column) . $row; + $rowData[$column] = Cell::stringFromColumnIndex($column) . $row; } else { $rowData[$column] = ''; } @@ -522,7 +538,7 @@ class Html extends BaseWriter implements IWriter /** * Generate sheet tabs. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ @@ -530,7 +546,7 @@ class Html extends BaseWriter implements IWriter { // Spreadsheet object known? if (is_null($this->spreadsheet)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Internal Spreadsheet object not set to an instance of an object.'); + throw new WriterException('Internal Spreadsheet object not set to an instance of an object.'); } // Fetch sheets @@ -562,19 +578,19 @@ class Html extends BaseWriter implements IWriter return $html; } - private function extendRowsForChartsAndImages(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $row) + private function extendRowsForChartsAndImages(Worksheet $pSheet, $row) { $rowMax = $row; $colMax = 'A'; if ($this->includeCharts) { foreach ($pSheet->getChartCollection() as $chart) { - if ($chart instanceof \PhpOffice\PhpSpreadsheet\Chart) { + if ($chart instanceof Chart) { $chartCoordinates = $chart->getTopLeftPosition(); - $chartTL = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($chartCoordinates['cell']); - $chartCol = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($chartTL[0]); + $chartTL = Cell::coordinateFromString($chartCoordinates['cell']); + $chartCol = Cell::columnIndexFromString($chartTL[0]); if ($chartTL[1] > $rowMax) { $rowMax = $chartTL[1]; - if ($chartCol > \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colMax)) { + if ($chartCol > Cell::columnIndexFromString($colMax)) { $colMax = $chartTL[0]; } } @@ -583,12 +599,12 @@ class Html extends BaseWriter implements IWriter } foreach ($pSheet->getDrawingCollection() as $drawing) { - if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { - $imageTL = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($drawing->getCoordinates()); - $imageCol = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($imageTL[0]); + if ($drawing instanceof Drawing) { + $imageTL = Cell::coordinateFromString($drawing->getCoordinates()); + $imageCol = Cell::columnIndexFromString($imageTL[0]); if ($imageTL[1] > $rowMax) { $rowMax = $imageTL[1]; - if ($imageCol > \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colMax)) { + if ($imageCol > Cell::columnIndexFromString($colMax)) { $colMax = $imageTL[0]; } } @@ -623,21 +639,21 @@ class Html extends BaseWriter implements IWriter /** * Generate image tag in cell. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet + * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet * @param string $coordinates Cell coordinates * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ - private function writeImageInCell(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $coordinates) + private function writeImageInCell(Worksheet $pSheet, $coordinates) { // Construct HTML $html = ''; // Write images foreach ($pSheet->getDrawingCollection() as $drawing) { - if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { + if ($drawing instanceof Drawing) { if ($drawing->getCoordinates() == $coordinates) { $filename = $drawing->getPath(); @@ -681,7 +697,7 @@ class Html extends BaseWriter implements IWriter $imageData . '" border="0" />'; $html .= ''; } - } elseif ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { + } elseif ($drawing instanceof MemoryDrawing) { if ($drawing->getCoordinates() != $coordinates) { continue; } @@ -706,24 +722,24 @@ class Html extends BaseWriter implements IWriter /** * Generate chart tag in cell. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet + * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet * @param string $coordinates Cell coordinates * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ - private function writeChartInCell(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $coordinates) + private function writeChartInCell(Worksheet $pSheet, $coordinates) { // Construct HTML $html = ''; // Write charts foreach ($pSheet->getChartCollection() as $chart) { - if ($chart instanceof \PhpOffice\PhpSpreadsheet\Chart) { + if ($chart instanceof Chart) { $chartCoordinates = $chart->getTopLeftPosition(); if ($chartCoordinates['cell'] == $coordinates) { - $chartFileName = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir() . '/' . uniqid() . '.png'; + $chartFileName = File::sysGetTempDir() . '/' . uniqid() . '.png'; if (!$chart->render($chartFileName)) { return; } @@ -757,7 +773,7 @@ class Html extends BaseWriter implements IWriter * * @param bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ @@ -765,7 +781,7 @@ class Html extends BaseWriter implements IWriter { // Spreadsheet object known? if (is_null($this->spreadsheet)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Internal Spreadsheet object not set to an instance of an object.'); + throw new WriterException('Internal Spreadsheet object not set to an instance of an object.'); } // Build CSS @@ -801,7 +817,7 @@ class Html extends BaseWriter implements IWriter * * @param bool $generateSurroundingHTML Generate surrounding HTML style? (html { }) * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return array */ @@ -809,7 +825,7 @@ class Html extends BaseWriter implements IWriter { // Spreadsheet object known? if (is_null($this->spreadsheet)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Internal Spreadsheet object not set to an instance of an object.'); + throw new WriterException('Internal Spreadsheet object not set to an instance of an object.'); } // Cached? @@ -885,7 +901,7 @@ class Html extends BaseWriter implements IWriter $sheet->calculateColumnWidths(); // col elements, initialize - $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($sheet->getHighestColumn()) - 1; + $highestColumnIndex = Cell::columnIndexFromString($sheet->getHighestColumn()) - 1; $column = -1; while ($column++ < $highestColumnIndex) { $this->columnWidths[$sheetIndex][$column] = 42; // approximation @@ -894,9 +910,9 @@ class Html extends BaseWriter implements IWriter // col elements, loop through columnDimensions and set width foreach ($sheet->getColumnDimensions() as $columnDimension) { - if (($width = \PhpOffice\PhpSpreadsheet\Shared\Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->defaultFont)) >= 0) { - $width = \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToPoints($width); - $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1; + if (($width = SharedDrawing::cellDimensionToPixels($columnDimension->getWidth(), $this->defaultFont)) >= 0) { + $width = SharedDrawing::pixelsToPoints($width); + $column = Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1; $this->columnWidths[$sheetIndex][$column] = $width; $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt'; @@ -914,7 +930,7 @@ class Html extends BaseWriter implements IWriter $css['table.sheet' . $sheetIndex . ' tr'] = []; if ($rowDimension->getRowHeight() == -1) { - $pt_height = Font::getDefaultRowHeightByFont($this->spreadsheet->getDefaultStyle()->getFont()); + $pt_height = SharedFont::getDefaultRowHeightByFont($this->spreadsheet->getDefaultStyle()->getFont()); } else { $pt_height = $rowDimension->getRowHeight(); } @@ -932,7 +948,7 @@ class Html extends BaseWriter implements IWriter $css['table.sheet' . $sheetIndex . ' tr.row' . $row] = []; if ($rowDimension->getRowHeight() == -1) { - $pt_height = Font::getDefaultRowHeightByFont($this->spreadsheet->getDefaultStyle()->getFont()); + $pt_height = SharedFont::getDefaultRowHeightByFont($this->spreadsheet->getDefaultStyle()->getFont()); } else { $pt_height = $rowDimension->getRowHeight(); } @@ -956,11 +972,11 @@ class Html extends BaseWriter implements IWriter /** * Create CSS style. * - * @param \PhpOffice\PhpSpreadsheet\Style $pStyle + * @param Style $pStyle * * @return array */ - private function createCSSStyle(\PhpOffice\PhpSpreadsheet\Style $pStyle) + private function createCSSStyle(Style $pStyle) { // Construct CSS $css = ''; @@ -980,11 +996,11 @@ class Html extends BaseWriter implements IWriter /** * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Alignment). * - * @param \PhpOffice\PhpSpreadsheet\Style\Alignment $pStyle \PhpOffice\PhpSpreadsheet\Style\Alignment + * @param Alignment $pStyle \PhpOffice\PhpSpreadsheet\Style\Alignment * * @return array */ - private function createCSSStyleAlignment(\PhpOffice\PhpSpreadsheet\Style\Alignment $pStyle) + private function createCSSStyleAlignment(Alignment $pStyle) { // Construct CSS $css = []; @@ -1004,11 +1020,11 @@ class Html extends BaseWriter implements IWriter /** * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font). * - * @param \PhpOffice\PhpSpreadsheet\Style\Font $pStyle \PhpOffice\PhpSpreadsheet\Style\Font + * @param Font $pStyle * * @return array */ - private function createCSSStyleFont(\PhpOffice\PhpSpreadsheet\Style\Font $pStyle) + private function createCSSStyleFont(Font $pStyle) { // Construct CSS $css = []; @@ -1017,9 +1033,9 @@ class Html extends BaseWriter implements IWriter if ($pStyle->getBold()) { $css['font-weight'] = 'bold'; } - if ($pStyle->getUnderline() != \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) { + if ($pStyle->getUnderline() != Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) { $css['text-decoration'] = 'underline line-through'; - } elseif ($pStyle->getUnderline() != \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE) { + } elseif ($pStyle->getUnderline() != Font::UNDERLINE_NONE) { $css['text-decoration'] = 'underline'; } elseif ($pStyle->getStrikethrough()) { $css['text-decoration'] = 'line-through'; @@ -1036,13 +1052,13 @@ class Html extends BaseWriter implements IWriter } /** - * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Borders). + * Create CSS style (Borders). * - * @param \PhpOffice\PhpSpreadsheet\Style\Borders $pStyle \PhpOffice\PhpSpreadsheet\Style\Borders + * @param Borders $pStyle Borders * * @return array */ - private function createCSSStyleBorders(\PhpOffice\PhpSpreadsheet\Style\Borders $pStyle) + private function createCSSStyleBorders(Borders $pStyle) { // Construct CSS $css = []; @@ -1057,13 +1073,13 @@ class Html extends BaseWriter implements IWriter } /** - * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Border). + * Create CSS style (Border). * - * @param \PhpOffice\PhpSpreadsheet\Style\Border $pStyle \PhpOffice\PhpSpreadsheet\Style\Border + * @param Border $pStyle Border * * @return string */ - private function createCSSStyleBorder(\PhpOffice\PhpSpreadsheet\Style\Border $pStyle) + private function createCSSStyleBorder(Border $pStyle) { // Create CSS - add !important to non-none border styles for merged cells $borderStyle = $this->mapBorderStyle($pStyle->getBorderStyle()); @@ -1073,19 +1089,19 @@ class Html extends BaseWriter implements IWriter } /** - * Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Fill). + * Create CSS style (Fill). * - * @param \PhpOffice\PhpSpreadsheet\Style\Fill $pStyle \PhpOffice\PhpSpreadsheet\Style\Fill + * @param Fill $pStyle Fill * * @return array */ - private function createCSSStyleFill(\PhpOffice\PhpSpreadsheet\Style\Fill $pStyle) + private function createCSSStyleFill(Fill $pStyle) { // Construct HTML $css = []; // Create CSS - $value = $pStyle->getFillType() == \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE ? + $value = $pStyle->getFillType() == Fill::FILL_NONE ? 'white' : '#' . $pStyle->getStartColor()->getRGB(); $css['background-color'] = $value; @@ -1108,9 +1124,9 @@ class Html extends BaseWriter implements IWriter /** * Generate table header. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet The worksheet for the table we are writing + * @param Worksheet $pSheet The worksheet for the table we are writing * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ @@ -1137,7 +1153,7 @@ class Html extends BaseWriter implements IWriter } // Write
elements - $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; + $highestColumnIndex = Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; $i = -1; while ($i++ < $highestColumnIndex) { if (!$this->isPdf) { @@ -1157,7 +1173,7 @@ class Html extends BaseWriter implements IWriter /** * Generate table footer. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function generateTableFooter() { @@ -1169,16 +1185,16 @@ class Html extends BaseWriter implements IWriter /** * Generate row. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet + * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet * @param array $pValues Array containing cells in a row * @param int $pRow Row number (0-based) * @param mixed $cellType eg: 'td' * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string */ - private function generateRow(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet, array $pValues, $pRow, $cellType) + private function generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType) { // Construct HTML $html = ''; @@ -1217,7 +1233,7 @@ class Html extends BaseWriter implements IWriter $colNum = 0; foreach ($pValues as $cellAddress) { $cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : ''; - $coordinate = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($colNum) . ($pRow + 1); + $coordinate = Cell::stringFromColumnIndex($colNum) . ($pRow + 1); if (!$this->useInlineCss) { $cssClass = ''; $cssClass = 'column' . $colNum; @@ -1239,19 +1255,19 @@ class Html extends BaseWriter implements IWriter // initialize $cellData = ' '; - // \PhpOffice\PhpSpreadsheet\Cell - if ($cell instanceof \PhpOffice\PhpSpreadsheet\Cell) { + // Cell + if ($cell instanceof Cell) { $cellData = ''; if (is_null($cell->getParent())) { $cell->attach($pSheet); } // Value - if ($cell->getValue() instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($cell->getValue() instanceof RichText) { // Loop through rich text elements $elements = $cell->getValue()->getRichTextElements(); foreach ($elements as $element) { // Rich text start? - if ($element instanceof \PhpOffice\PhpSpreadsheet\RichText\Run) { + if ($element instanceof RichText\Run) { $cellData .= ''; if ($element->getFont()->getSuperScript()) { @@ -1265,7 +1281,7 @@ class Html extends BaseWriter implements IWriter $cellText = $element->getText(); $cellData .= htmlspecialchars($cellText); - if ($element instanceof \PhpOffice\PhpSpreadsheet\RichText\Run) { + if ($element instanceof RichText\Run) { if ($element->getFont()->getSuperScript()) { $cellData .= ''; } elseif ($element->getFont()->getSubScript()) { @@ -1277,13 +1293,13 @@ class Html extends BaseWriter implements IWriter } } else { if ($this->preCalculateFormulas) { - $cellData = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString( + $cellData = NumberFormat::toFormattedString( $cell->getCalculatedValue(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(), [$this, 'formatColor'] ); } else { - $cellData = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::toFormattedString( + $cellData = NumberFormat::toFormattedString( $cell->getValue(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(), [$this, 'formatColor'] @@ -1321,7 +1337,7 @@ class Html extends BaseWriter implements IWriter // General horizontal alignment: Actual horizontal alignment depends on dataType $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex()); - if ($sharedStyle->getAlignment()->getHorizontal() == \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL + if ($sharedStyle->getAlignment()->getHorizontal() == Alignment::HORIZONTAL_GENERAL && isset($this->cssStyles['.' . $cell->getDataType()]['text-align']) ) { $cssClass['text-align'] = $this->cssStyles['.' . $cell->getDataType()]['text-align']; @@ -1348,7 +1364,7 @@ class Html extends BaseWriter implements IWriter // Also apply style from last cell in merge to fix borders - // relies on !important for non-none border declarations in createCSSStyleBorder - $endCellCoord = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan); + $endCellCoord = Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan); if (!$this->useInlineCss) { $cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex(); } @@ -1559,15 +1575,15 @@ class Html extends BaseWriter implements IWriter // loop through all Excel merged cells foreach ($sheet->getMergeCells() as $cells) { - list($cells) = \PhpOffice\PhpSpreadsheet\Cell::splitRange($cells); + list($cells) = Cell::splitRange($cells); $first = $cells[0]; $last = $cells[1]; - list($fc, $fr) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($first); - $fc = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($fc) - 1; + list($fc, $fr) = Cell::coordinateFromString($first); + $fc = Cell::columnIndexFromString($fc) - 1; - list($lc, $lr) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($last); - $lc = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($lc) - 1; + list($lc, $lr) = Cell::coordinateFromString($last); + $lc = Cell::columnIndexFromString($lc) - 1; // loop through the individual cells in the individual merge $r = $fr - 1; @@ -1597,7 +1613,7 @@ class Html extends BaseWriter implements IWriter // Identify which rows should be omitted in HTML. These are the rows where all the cells // participate in a merge and the where base cells are somewhere above. - $countColumns = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($sheet->getHighestColumn()); + $countColumns = Cell::columnIndexFromString($sheet->getHighestColumn()); foreach ($candidateSpannedRow as $rowIndex) { if (isset($this->isSpannedCell[$sheetIndex][$rowIndex])) { if (count($this->isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) { @@ -1631,7 +1647,7 @@ class Html extends BaseWriter implements IWriter $this->spansAreCalculated = true; } - private function setMargins(\PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function setMargins(Worksheet $pSheet) { $htmlPage = '@page { '; $htmlBody = 'body { '; diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index f82d4a73..e56bdd52 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -2,7 +2,16 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Content; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Meta; +use PhpOffice\PhpSpreadsheet\Writer\Ods\MetaInf; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Mimetype; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Settings; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Styles; +use PhpOffice\PhpSpreadsheet\Writer\Ods\Thumbnails; use ZipArchive; /** @@ -46,20 +55,20 @@ class Ods extends BaseWriter implements IWriter /** * Create a new Ods. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet */ - public function __construct(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function __construct(Spreadsheet $spreadsheet) { $this->setSpreadsheet($spreadsheet); $writerPartsArray = [ - 'content' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Content::class, - 'meta' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Meta::class, - 'meta_inf' => \PhpOffice\PhpSpreadsheet\Writer\Ods\MetaInf::class, - 'mimetype' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Mimetype::class, - 'settings' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Settings::class, - 'styles' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Styles::class, - 'thumbnails' => \PhpOffice\PhpSpreadsheet\Writer\Ods\Thumbnails::class, + 'content' => Content::class, + 'meta' => Meta::class, + 'meta_inf' => MetaInf::class, + 'mimetype' => Mimetype::class, + 'settings' => Settings::class, + 'styles' => Styles::class, + 'thumbnails' => Thumbnails::class, ]; foreach ($writerPartsArray as $writer => $class) { @@ -88,12 +97,12 @@ class Ods extends BaseWriter implements IWriter * * @param string $pFilename * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ public function save($pFilename) { if (!$this->spreadSheet) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('PhpSpreadsheet object unassigned.'); + throw new WriterException('PhpSpreadsheet object unassigned.'); } // garbage collect @@ -102,7 +111,7 @@ class Ods extends BaseWriter implements IWriter // If $pFilename is php://output or php://stdout, make it a temporary file... $originalFilename = $pFilename; if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { - $pFilename = @tempnam(\PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(), 'phpxltmp'); + $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); if ($pFilename == '') { $pFilename = $originalFilename; } @@ -120,13 +129,13 @@ class Ods extends BaseWriter implements IWriter // Close file if ($zip->close() === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not close zip file $pFilename."); + throw new WriterException("Could not close zip file $pFilename."); } // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } @@ -137,7 +146,7 @@ class Ods extends BaseWriter implements IWriter * * @param string $pFilename * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return ZipArchive */ @@ -152,7 +161,7 @@ class Ods extends BaseWriter implements IWriter // Try opening the ZIP file if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) { if ($zip->open($pFilename, ZipArchive::CREATE) !== true) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not open $pFilename for writing."); + throw new WriterException("Could not open $pFilename for writing."); } } @@ -162,7 +171,7 @@ class Ods extends BaseWriter implements IWriter /** * Get Spreadsheet object. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return Spreadsheet */ @@ -171,19 +180,19 @@ class Ods extends BaseWriter implements IWriter if ($this->spreadSheet !== null) { return $this->spreadSheet; } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('No PhpSpreadsheet assigned.'); + throw new WriterException('No PhpSpreadsheet assigned.'); } /** * Set Spreadsheet object. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet PhpSpreadsheet object + * @param Spreadsheet $spreadsheet PhpSpreadsheet object * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return self */ - public function setSpreadsheet(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function setSpreadsheet(Spreadsheet $spreadsheet) { $this->spreadSheet = $spreadsheet; diff --git a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php index 0ccf5618..f38a3c06 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods\Cell; -/** +/* * PhpSpreadsheet. * * Copyright (c) 2006 - 2015 PhpSpreadsheet @@ -26,6 +26,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods\Cell; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; /** * @category PhpSpreadsheet @@ -35,7 +37,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods\Cell; */ class Comment { - public static function write(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Cell $cell) + public static function write(XMLWriter $objWriter, Cell $cell) { $comments = $cell->getWorksheet()->getComments(); if (!isset($comments[$cell->getCoordinate()])) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Meta.php b/src/PhpSpreadsheet/Writer/Ods/Meta.php index 4a57ac69..d00c479b 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Meta.php +++ b/src/PhpSpreadsheet/Writer/Ods/Meta.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,13 +32,13 @@ class Meta extends WriterPart /** * Write meta.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function write(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function write(Spreadsheet $spreadsheet = null) { if (!$spreadsheet) { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); @@ -43,9 +46,9 @@ class Meta extends WriterPart $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php index c712e7cd..9cd0dc6c 100644 --- a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php +++ b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,13 +32,13 @@ class MetaInf extends WriterPart /** * Write META-INF/manifest.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeManifest(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeManifest(Spreadsheet $spreadsheet = null) { if (!$spreadsheet) { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); @@ -43,9 +46,9 @@ class MetaInf extends WriterPart $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Ods/Mimetype.php b/src/PhpSpreadsheet/Writer/Ods/Mimetype.php index f3bf03b5..7733f4d8 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Mimetype.php +++ b/src/PhpSpreadsheet/Writer/Ods/Mimetype.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,13 +29,13 @@ class Mimetype extends WriterPart /** * Write mimetype to plain text format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function write(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function write(Spreadsheet $spreadsheet = null) { return 'application/vnd.oasis.opendocument.spreadsheet'; } diff --git a/src/PhpSpreadsheet/Writer/Ods/Settings.php b/src/PhpSpreadsheet/Writer/Ods/Settings.php index dd77ae54..cea7c725 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Settings.php +++ b/src/PhpSpreadsheet/Writer/Ods/Settings.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,13 +32,13 @@ class Settings extends WriterPart /** * Write settings.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function write(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function write(Spreadsheet $spreadsheet = null) { if (!$spreadsheet) { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); @@ -43,9 +46,9 @@ class Settings extends WriterPart $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Ods/Styles.php b/src/PhpSpreadsheet/Writer/Ods/Styles.php index 5219f106..a9ea8e86 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Styles.php +++ b/src/PhpSpreadsheet/Writer/Ods/Styles.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,13 +32,13 @@ class Styles extends WriterPart /** * Write styles.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function write(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function write(Spreadsheet $spreadsheet = null) { if (!$spreadsheet) { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); @@ -43,9 +46,9 @@ class Styles extends WriterPart $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php b/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php index df5642fb..b2e38ea5 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php +++ b/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,13 +31,13 @@ class Thumbnails extends WriterPart /** * Write Thumbnails/thumbnail.png to PNG format. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeThumbnail(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeThumbnail(Spreadsheet $spreadsheet = null) { return ''; } diff --git a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php index b07b38cb..04fd0fdb 100644 --- a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; +use PhpOffice\PhpSpreadsheet\Writer\Ods; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,7 +31,7 @@ abstract class WriterPart /** * Parent Ods object. * - * @var \PhpOffice\PhpSpreadsheet\Writer\Ods + * @var Ods */ private $parentWriter; @@ -38,7 +40,7 @@ abstract class WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Writer\Ods + * @return Ods */ public function getParentWriter() { @@ -48,9 +50,9 @@ abstract class WriterPart /** * Set parent Ods writer. * - * @param \PhpOffice\PhpSpreadsheet\Writer\Ods $writer + * @param Ods $writer */ - public function __construct(\PhpOffice\PhpSpreadsheet\Writer\Ods $writer) + public function __construct(Ods $writer) { $this->parentWriter = $writer; } diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index eeec2334..48e585b2 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Spreadsheet; /** @@ -38,13 +39,13 @@ class Pdf implements IWriter /** * Instantiate a new renderer of the configured type within this container class. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet PhpSpreadsheet object + * @param Spreadsheet $spreadsheet PhpSpreadsheet object * * @throws Exception when PDF library is not configured */ public function __construct(Spreadsheet $spreadsheet) { - $pdfLibraryName = \PhpOffice\PhpSpreadsheet\Settings::getPdfRendererName(); + $pdfLibraryName = Settings::getPdfRendererName(); if (is_null($pdfLibraryName)) { throw new Exception('PDF Rendering library has not been defined.'); } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Core.php b/src/PhpSpreadsheet/Writer/Pdf/Core.php index 084b514c..d8eeb00a 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Core.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Core.php @@ -2,6 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; +use PhpOffice\PhpSpreadsheet\Writer\Html; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -24,7 +31,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html +abstract class Core extends Html { /** * Temporary storage directory. @@ -67,84 +74,84 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * @var array */ protected static $paperSizes = [ - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER => 'LETTER', // (8.5 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID => [792.00, 1224.00], // (11 in. by 17 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEDGER => [1224.00, 792.00], // (17 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL => 'LEGAL', // (8.5 in. by 14 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STATEMENT => [396.00, 612.00], // (5.5 in. by 8.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE', // (7.25 in. by 10.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3 => 'A3', // (297 mm by 420 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4 => 'A4', // (210 mm by 297 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_SMALL => 'A4', // (210 mm by 297 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5 => 'A5', // (148 mm by 210 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4 => 'B4', // (250 mm by 353 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5 => 'B5', // (176 mm by 250 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_FOLIO => 'FOLIO', // (8.5 in. by 13 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_QUARTO => [609.45, 779.53], // (215 mm by 275 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_1 => [720.00, 1008.00], // (10 in. by 14 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_2 => [792.00, 1224.00], // (11 in. by 17 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NOTE => 'LETTER', // (8.5 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO9_ENVELOPE => [279.00, 639.00], // (3.875 in. by 8.875 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO10_ENVELOPE => [297.00, 684.00], // (4.125 in. by 9.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO11_ENVELOPE => [324.00, 747.00], // (4.5 in. by 10.375 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO12_ENVELOPE => [342.00, 792.00], // (4.75 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO14_ENVELOPE => [360.00, 828.00], // (5 in. by 11.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C => [1224.00, 1584.00], // (17 in. by 22 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_D => [1584.00, 2448.00], // (22 in. by 34 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_E => [2448.00, 3168.00], // (34 in. by 44 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62], // (110 mm by 220 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5', // (162 mm by 229 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3', // (324 mm by 458 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4', // (229 mm by 324 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6', // (114 mm by 162 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13], // (114 mm by 229 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4', // (250 mm by 353 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5', // (176 mm by 250 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B6_ENVELOPE => [498.90, 354.33], // (176 mm by 125 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97], // (110 mm by 230 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.00, 540.00], // (3.875 in. by 7.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.00, 468.00], // (3.625 in. by 6.5 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.00, 792.00], // (14.875 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.00, 864.00], // (8.5 in. by 12 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO', // (8.5 in. by 13 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B4 => 'B4', // (250 mm by 353 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.93, 419.53], // (200 mm by 148 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.00, 792.00], // (9 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.00, 792.00], // (10 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.00, 792.00], // (15 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62], // (220 mm by 220 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.80, 1080.00], // (9.275 in. by 15 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.68, 1296.00], // (11.69 in. by 18 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76], // (236 mm by 322 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.80, 792.00], // (8.275 in. by 11 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4', // (210 mm by 297 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13], // (227 mm by 356 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.57, 1380.47], // (305 mm by 487 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.00, 913.68], // (8.5 in. by 12.69 in.) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.43], // (210 mm by 330 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5', // (148 mm by 210 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.50], // (182 mm by 257 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14], // (174 mm by 235 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36], // (201 mm by 276 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A2_PAPER => 'A2', // (420 mm by 594 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3', // (297 mm by 420 mm) - \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) + PageSetup::PAPERSIZE_LETTER => 'LETTER', // (8.5 in. by 11 in.) + PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.) + PageSetup::PAPERSIZE_TABLOID => [792.00, 1224.00], // (11 in. by 17 in.) + PageSetup::PAPERSIZE_LEDGER => [1224.00, 792.00], // (17 in. by 11 in.) + PageSetup::PAPERSIZE_LEGAL => 'LEGAL', // (8.5 in. by 14 in.) + PageSetup::PAPERSIZE_STATEMENT => [396.00, 612.00], // (5.5 in. by 8.5 in.) + PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE', // (7.25 in. by 10.5 in.) + PageSetup::PAPERSIZE_A3 => 'A3', // (297 mm by 420 mm) + PageSetup::PAPERSIZE_A4 => 'A4', // (210 mm by 297 mm) + PageSetup::PAPERSIZE_A4_SMALL => 'A4', // (210 mm by 297 mm) + PageSetup::PAPERSIZE_A5 => 'A5', // (148 mm by 210 mm) + PageSetup::PAPERSIZE_B4 => 'B4', // (250 mm by 353 mm) + PageSetup::PAPERSIZE_B5 => 'B5', // (176 mm by 250 mm) + PageSetup::PAPERSIZE_FOLIO => 'FOLIO', // (8.5 in. by 13 in.) + PageSetup::PAPERSIZE_QUARTO => [609.45, 779.53], // (215 mm by 275 mm) + PageSetup::PAPERSIZE_STANDARD_1 => [720.00, 1008.00], // (10 in. by 14 in.) + PageSetup::PAPERSIZE_STANDARD_2 => [792.00, 1224.00], // (11 in. by 17 in.) + PageSetup::PAPERSIZE_NOTE => 'LETTER', // (8.5 in. by 11 in.) + PageSetup::PAPERSIZE_NO9_ENVELOPE => [279.00, 639.00], // (3.875 in. by 8.875 in.) + PageSetup::PAPERSIZE_NO10_ENVELOPE => [297.00, 684.00], // (4.125 in. by 9.5 in.) + PageSetup::PAPERSIZE_NO11_ENVELOPE => [324.00, 747.00], // (4.5 in. by 10.375 in.) + PageSetup::PAPERSIZE_NO12_ENVELOPE => [342.00, 792.00], // (4.75 in. by 11 in.) + PageSetup::PAPERSIZE_NO14_ENVELOPE => [360.00, 828.00], // (5 in. by 11.5 in.) + PageSetup::PAPERSIZE_C => [1224.00, 1584.00], // (17 in. by 22 in.) + PageSetup::PAPERSIZE_D => [1584.00, 2448.00], // (22 in. by 34 in.) + PageSetup::PAPERSIZE_E => [2448.00, 3168.00], // (34 in. by 44 in.) + PageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62], // (110 mm by 220 mm) + PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5', // (162 mm by 229 mm) + PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3', // (324 mm by 458 mm) + PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4', // (229 mm by 324 mm) + PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6', // (114 mm by 162 mm) + PageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13], // (114 mm by 229 mm) + PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4', // (250 mm by 353 mm) + PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5', // (176 mm by 250 mm) + PageSetup::PAPERSIZE_B6_ENVELOPE => [498.90, 354.33], // (176 mm by 125 mm) + PageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97], // (110 mm by 230 mm) + PageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.00, 540.00], // (3.875 in. by 7.5 in.) + PageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.00, 468.00], // (3.625 in. by 6.5 in.) + PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.00, 792.00], // (14.875 in. by 11 in.) + PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.00, 864.00], // (8.5 in. by 12 in.) + PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO', // (8.5 in. by 13 in.) + PageSetup::PAPERSIZE_ISO_B4 => 'B4', // (250 mm by 353 mm) + PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.93, 419.53], // (200 mm by 148 mm) + PageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.00, 792.00], // (9 in. by 11 in.) + PageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.00, 792.00], // (10 in. by 11 in.) + PageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.00, 792.00], // (15 in. by 11 in.) + PageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62], // (220 mm by 220 mm) + PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) + PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.80, 1080.00], // (9.275 in. by 15 in.) + PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.68, 1296.00], // (11.69 in. by 18 in.) + PageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76], // (236 mm by 322 mm) + PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.80, 792.00], // (8.275 in. by 11 in.) + PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4', // (210 mm by 297 mm) + PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) + PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13], // (227 mm by 356 mm) + PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.57, 1380.47], // (305 mm by 487 mm) + PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.00, 913.68], // (8.5 in. by 12.69 in.) + PageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.43], // (210 mm by 330 mm) + PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5', // (148 mm by 210 mm) + PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.50], // (182 mm by 257 mm) + PageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) + PageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14], // (174 mm by 235 mm) + PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36], // (201 mm by 276 mm) + PageSetup::PAPERSIZE_A2_PAPER => 'A2', // (420 mm by 594 mm) + PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3', // (297 mm by 420 mm) + PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) ]; /** * Create a new PDF Writer instance. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Spreadsheet object + * @param Spreadsheet $spreadsheet Spreadsheet object */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function __construct(Spreadsheet $spreadsheet) { parent::__construct($spreadsheet); $this->setUseInlineCss(true); - $this->tempDir = \PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(); + $this->tempDir = File::sysGetTempDir(); } /** @@ -186,7 +193,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html /** * Set Paper Size. * - * @param string $pValue Paper size see \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_* + * @param string $pValue Paper size see PageSetup::PAPERSIZE_* * * @return self */ @@ -210,7 +217,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html /** * Set Orientation. * - * @param string $pValue Page orientation see \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_* + * @param string $pValue Page orientation see PageSetup::ORIENTATION_* * * @return self */ @@ -236,7 +243,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * * @param string $pValue Temporary storage directory * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception when directory does not exist + * @throws WriterException when directory does not exist * * @return self */ @@ -245,7 +252,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html if (is_dir($pValue)) { $this->tempDir = $pValue; } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Directory does not exist: $pValue"); + throw new WriterException("Directory does not exist: $pValue"); } return $this; @@ -256,20 +263,20 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * * @param string $pFilename Name of the file to save as * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ protected function prepareForSave($pFilename) { // garbage collect $this->spreadsheet->garbageCollect(); - $this->saveArrayReturnType = \PhpOffice\PhpSpreadsheet\Calculation::getArrayReturnType(); - \PhpOffice\PhpSpreadsheet\Calculation::setArrayReturnType(\PhpOffice\PhpSpreadsheet\Calculation::RETURN_ARRAY_AS_VALUE); + $this->saveArrayReturnType = Calculation::getArrayReturnType(); + Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not open file $pFilename for writing."); + throw new WriterException("Could not open file $pFilename for writing."); } // Set PDF @@ -285,13 +292,13 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * * @param resource $fileHandle * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ protected function restoreStateAfterSave($fileHandle) { // Close file fclose($fileHandle); - \PhpOffice\PhpSpreadsheet\Calculation::setArrayReturnType($this->saveArrayReturnType); + Calculation::setArrayReturnType($this->saveArrayReturnType); } } diff --git a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php index 2ddba79e..75456b8b 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Writer\IWriter; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class DomPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter +class DomPDF extends Core implements IWriter { /** * Save Spreadsheet to file. @@ -43,12 +46,12 @@ class DomPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet(0)->getPageMargins(); } else { $orientation = ($this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageMargins(); } @@ -57,8 +60,8 @@ class DomPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter // Override Page Orientation if (!is_null($this->getOrientation())) { - $orientation = ($this->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_DEFAULT) - ? \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT + $orientation = ($this->getOrientation() == PageSetup::ORIENTATION_DEFAULT) + ? PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); } // Override Paper Size diff --git a/src/PhpSpreadsheet/Writer/Pdf/MPDF.php b/src/PhpSpreadsheet/Writer/Pdf/MPDF.php index 06cb83e1..425b132e 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/MPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/MPDF.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Writer\IWriter; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -24,7 +28,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter +class MPDF extends Core implements IWriter { /** * Save Spreadsheet to file. @@ -32,7 +36,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter * @param string $pFilename Name of the file to save as * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception - * @throws \PhpOffice\PhpSpreadsheet\Exception + * @throws PhpSpreadsheetException */ public function save($pFilename) { @@ -44,12 +48,12 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter // Check for paper size and page orientation if (null === $this->getSheetIndex()) { $orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet(0)->getPageMargins(); } else { $orientation = ($this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageMargins(); } @@ -57,8 +61,8 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter // Override Page Orientation if (null !== $this->getOrientation()) { - $orientation = ($this->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_DEFAULT) - ? \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT + $orientation = ($this->getOrientation() == PageSetup::ORIENTATION_DEFAULT) + ? PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation(); } $orientation = strtoupper($orientation); diff --git a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php index 858ff27e..33fc48a0 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Writer\IWriter; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -24,7 +27,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Pdf; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -class TcPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter +class TcPDF extends Core implements IWriter { /** * Save Spreadsheet to file. @@ -43,19 +46,19 @@ class TcPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet(0)->getPageMargins(); } else { $orientation = ($this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() - == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; + == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; $printPaperSize = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->spreadsheet->getSheet($this->getSheetIndex())->getPageMargins(); } // Override Page Orientation if (!is_null($this->getOrientation())) { - $orientation = ($this->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) + $orientation = ($this->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; } diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 30698647..8f08ba48 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -2,6 +2,28 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\Drawing as SharedDrawing; +use PhpOffice\PhpSpreadsheet\Shared\Escher; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip; +use PhpOffice\PhpSpreadsheet\Shared\OLE; +use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File; +use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use RuntimeException; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,7 +51,7 @@ class Xls extends BaseWriter implements IWriter /** * PhpSpreadsheet object. * - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadsheet; @@ -92,9 +114,9 @@ class Xls extends BaseWriter implements IWriter /** * Create a new Xls Writer. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet PhpSpreadsheet object + * @param Spreadsheet $spreadsheet PhpSpreadsheet object */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function __construct(Spreadsheet $spreadsheet) { $this->spreadsheet = $spreadsheet; @@ -113,10 +135,10 @@ class Xls extends BaseWriter implements IWriter // garbage collect $this->spreadsheet->garbageCollect(); - $saveDebugLog = \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog(); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false); - $saveDateReturnType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(); - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType(\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL); + $saveDebugLog = Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog(); + Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false); + $saveDateReturnType = Functions::getReturnDateType(); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // initialize colors array $this->colors = []; @@ -151,10 +173,10 @@ class Xls extends BaseWriter implements IWriter foreach ($this->writerWorksheets[$i]->phpSheet->getCoordinates() as $coordinate) { $cell = $this->writerWorksheets[$i]->phpSheet->getCell($coordinate); $cVal = $cell->getValue(); - if ($cVal instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($cVal instanceof RichText) { $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { - if ($element instanceof \PhpOffice\PhpSpreadsheet\RichText\Run) { + if ($element instanceof RichText\Run) { $font = $element->getFont(); $this->writerWorksheets[$i]->fontHashIndex[$font->getHashCode()] = $this->writerWorkbook->addFont($font); } @@ -165,7 +187,7 @@ class Xls extends BaseWriter implements IWriter // initialize OLE file $workbookStreamName = 'Workbook'; - $OLE = new \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File(\PhpOffice\PhpSpreadsheet\Shared\OLE::ascToUcs($workbookStreamName)); + $OLE = new File(OLE::ascToUcs($workbookStreamName)); // Write the worksheet streams before the global workbook stream, // because the byte sizes of these are needed in the global workbook stream @@ -186,14 +208,14 @@ class Xls extends BaseWriter implements IWriter $this->documentSummaryInformation = $this->writeDocumentSummaryInformation(); // initialize OLE Document Summary Information if (isset($this->documentSummaryInformation) && !empty($this->documentSummaryInformation)) { - $OLE_DocumentSummaryInformation = new \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File(\PhpOffice\PhpSpreadsheet\Shared\OLE::ascToUcs(chr(5) . 'DocumentSummaryInformation')); + $OLE_DocumentSummaryInformation = new File(OLE::ascToUcs(chr(5) . 'DocumentSummaryInformation')); $OLE_DocumentSummaryInformation->append($this->documentSummaryInformation); } $this->summaryInformation = $this->writeSummaryInformation(); // initialize OLE Summary Information if (isset($this->summaryInformation) && !empty($this->summaryInformation)) { - $OLE_SummaryInformation = new \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File(\PhpOffice\PhpSpreadsheet\Shared\OLE::ascToUcs(chr(5) . 'SummaryInformation')); + $OLE_SummaryInformation = new File(OLE::ascToUcs(chr(5) . 'SummaryInformation')); $OLE_SummaryInformation->append($this->summaryInformation); } @@ -208,12 +230,12 @@ class Xls extends BaseWriter implements IWriter $arrRootData[] = $OLE_DocumentSummaryInformation; } - $root = new \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root(time(), time(), $arrRootData); + $root = new Root(time(), time(), $arrRootData); // save the OLE file $res = $root->save($pFilename); - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType($saveDateReturnType); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); + Functions::setReturnDateType($saveDateReturnType); + Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -239,10 +261,10 @@ class Xls extends BaseWriter implements IWriter } // create intermediate Escher object - $escher = new \PhpOffice\PhpSpreadsheet\Shared\Escher(); + $escher = new Escher(); // dgContainer - $dgContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer(); + $dgContainer = new DgContainer(); // set the drawing index (we use sheet index + 1) $dgId = $sheet->getParent()->getIndex($sheet) + 1; @@ -250,11 +272,11 @@ class Xls extends BaseWriter implements IWriter $escher->setDgContainer($dgContainer); // spgrContainer - $spgrContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer(); + $spgrContainer = new SpgrContainer(); $dgContainer->setSpgrContainer($spgrContainer); // add one shape which is the group shape - $spContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); + $spContainer = new SpContainer(); $spContainer->setSpgr(true); $spContainer->setSpType(0); $spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10); @@ -270,7 +292,7 @@ class Xls extends BaseWriter implements IWriter ++$countShapes[$sheetIndex]; // add the shape - $spContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); + $spContainer = new SpContainer(); // set the shape type $spContainer->setSpType(0x004B); @@ -312,7 +334,7 @@ class Xls extends BaseWriter implements IWriter // AutoFilters if (!empty($filterRange)) { - $rangeBounds = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($filterRange); + $rangeBounds = Cell::rangeBoundaries($filterRange); $iNumColStart = $rangeBounds[0][0]; $iNumColEnd = $rangeBounds[1][0]; @@ -321,14 +343,14 @@ class Xls extends BaseWriter implements IWriter ++$countShapes[$sheetIndex]; // create an Drawing Object for the dropdown - $oDrawing = new \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing(); + $oDrawing = new BaseDrawing(); // get the coordinates of drawing - $cDrawing = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1]; + $cDrawing = Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1]; $oDrawing->setCoordinates($cDrawing); $oDrawing->setWorksheet($sheet); // add the shape - $spContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); + $spContainer = new SpContainer(); // set the shape type $spContainer->setSpType(0x00C9); // set the shape flag @@ -352,7 +374,7 @@ class Xls extends BaseWriter implements IWriter $spContainer->setOPT(0x03BF, 0x000A0000); // Group Shape -> fPrint // set coordinates and offsets, client anchor - $endCoordinates = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($iInc - 1); + $endCoordinates = Cell::stringFromColumnIndex($iInc - 1); $endCoordinates .= $rangeBounds[0][1] + 1; $spContainer->setStartCoordinates($cDrawing); @@ -400,10 +422,10 @@ class Xls extends BaseWriter implements IWriter } // if we reach here, then there are drawings in the workbook - $escher = new \PhpOffice\PhpSpreadsheet\Shared\Escher(); + $escher = new Escher(); // dggContainer - $dggContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer(); + $dggContainer = new DggContainer(); $escher->setDggContainer($dggContainer); // set IDCLs (identifier clusters) @@ -435,40 +457,40 @@ class Xls extends BaseWriter implements IWriter $dggContainer->setCSpSaved($totalCountShapes + $countDrawings); // total number of shapes incl. one group shapes per drawing // bstoreContainer - $bstoreContainer = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer(); + $bstoreContainer = new BstoreContainer(); $dggContainer->setBstoreContainer($bstoreContainer); // the BSE's (all the images) foreach ($this->spreadsheet->getAllsheets() as $sheet) { foreach ($sheet->getDrawingCollection() as $drawing) { if (!extension_loaded('gd')) { - throw new \RuntimeException('Saving images in xls requires gd extension'); + throw new RuntimeException('Saving images in xls requires gd extension'); } - if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { + if ($drawing instanceof Drawing) { $filename = $drawing->getPath(); list($imagesx, $imagesy, $imageFormat) = getimagesize($filename); switch ($imageFormat) { case 1: // GIF, not supported by BIFF8, we convert to PNG - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; + $blipType = BSE::BLIPTYPE_PNG; ob_start(); imagepng(imagecreatefromgif($filename)); $blipData = ob_get_contents(); ob_end_clean(); break; case 2: // JPEG - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG; + $blipType = BSE::BLIPTYPE_JPEG; $blipData = file_get_contents($filename); break; case 3: // PNG - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; + $blipType = BSE::BLIPTYPE_PNG; $blipData = file_get_contents($filename); break; case 6: // Windows DIB (BMP), we convert to PNG - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; + $blipType = BSE::BLIPTYPE_PNG; ob_start(); - imagepng(\PhpOffice\PhpSpreadsheet\Shared\Drawing::imagecreatefrombmp($filename)); + imagepng(SharedDrawing::imagecreatefrombmp($filename)); $blipData = ob_get_contents(); ob_end_clean(); break; @@ -476,24 +498,24 @@ class Xls extends BaseWriter implements IWriter continue 2; } - $blip = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); + $blip = new Blip(); $blip->setData($blipData); - $BSE = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE(); + $BSE = new BSE(); $BSE->setBlipType($blipType); $BSE->setBlip($blip); $bstoreContainer->addBSE($BSE); - } elseif ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { + } elseif ($drawing instanceof MemoryDrawing) { switch ($drawing->getRenderingFunction()) { - case \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG: - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG; + case MemoryDrawing::RENDERING_JPEG: + $blipType = BSE::BLIPTYPE_JPEG; $renderingFunction = 'imagejpeg'; break; - case \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_GIF: - case \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_PNG: - case \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_DEFAULT: - $blipType = \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; + case MemoryDrawing::RENDERING_GIF: + case MemoryDrawing::RENDERING_PNG: + case MemoryDrawing::RENDERING_DEFAULT: + $blipType = BSE::BLIPTYPE_PNG; $renderingFunction = 'imagepng'; break; } @@ -503,10 +525,10 @@ class Xls extends BaseWriter implements IWriter $blipData = ob_get_contents(); ob_end_clean(); - $blip = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); + $blip = new Blip(); $blip->setData($blipData); - $BSE = new \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE(); + $BSE = new BSE(); $BSE->setBlipType($blipType); $BSE->setBlip($blip); @@ -847,7 +869,7 @@ class Xls extends BaseWriter implements IWriter 'summary' => ['pack' => 'V', 'data' => 0x0C], 'offset' => ['pack' => 'V'], 'type' => ['pack' => 'V', 'data' => 0x40], // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => ['data' => \PhpOffice\PhpSpreadsheet\Shared\OLE::localDateToOLE($dataProp)], + 'data' => ['data' => OLE::localDateToOLE($dataProp)], ]; ++$dataSection_NumProps; } @@ -858,7 +880,7 @@ class Xls extends BaseWriter implements IWriter 'summary' => ['pack' => 'V', 'data' => 0x0D], 'offset' => ['pack' => 'V'], 'type' => ['pack' => 'V', 'data' => 0x40], // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => ['data' => \PhpOffice\PhpSpreadsheet\Shared\OLE::localDateToOLE($dataProp)], + 'data' => ['data' => OLE::localDateToOLE($dataProp)], ]; ++$dataSection_NumProps; } diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index a45ba07b..e250254c 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -117,7 +119,7 @@ class BIFFwriter $byte_order = 1; // Big Endian } else { // Give up. I'll fix this in a later version. - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Required floating point format not supported on this platform.'); + throw new WriterException('Required floating point format not supported on this platform.'); } self::$byteOrder = $byte_order; } diff --git a/src/PhpSpreadsheet/Writer/Xls/Escher.php b/src/PhpSpreadsheet/Writer/Xls/Escher.php index 8926b192..adff2ae9 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Escher.php +++ b/src/PhpSpreadsheet/Writer/Xls/Escher.php @@ -2,6 +2,15 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -83,7 +92,7 @@ class Escher $this->spTypes = $writer->getSpTypes(); } break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer::class: + case DggContainer::class: // this is a container record // initialize @@ -136,7 +145,7 @@ class Escher $this->data = $header . $innerData; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer::class: + case BstoreContainer::class: // this is a container record // initialize @@ -163,7 +172,7 @@ class Escher $this->data = $header . $innerData; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::class: + case BSE::class: // this is a semi-container record // initialize @@ -212,12 +221,12 @@ class Escher $this->data .= $data; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip::class: + case Blip::class: // this is an atom record // write the record switch ($this->object->getParent()->getBlipType()) { - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG: + case BSE::BLIPTYPE_JPEG: // initialize $innerData = ''; @@ -243,7 +252,7 @@ class Escher $this->data .= $innerData; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG: + case BSE::BLIPTYPE_PNG: // initialize $innerData = ''; @@ -271,7 +280,7 @@ class Escher break; } break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer::class: + case DgContainer::class: // this is a container record // initialize @@ -323,7 +332,7 @@ class Escher $this->data = $header . $innerData; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer::class: + case SpgrContainer::class: // this is a container record // initialize @@ -362,7 +371,7 @@ class Escher $this->spOffsets = $spOffsets; $this->spTypes = $spTypes; break; - case \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer\SpContainer::class: + case SpContainer::class: // initialize $data = ''; @@ -425,8 +434,8 @@ class Escher $recType = 0xF010; // start coordinates - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($this->object->getStartCoordinates()); - $c1 = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + list($column, $row) = Cell::coordinateFromString($this->object->getStartCoordinates()); + $c1 = Cell::columnIndexFromString($column) - 1; $r1 = $row - 1; // start offsetX @@ -436,8 +445,8 @@ class Escher $startOffsetY = $this->object->getStartOffsetY(); // end coordinates - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($this->object->getEndCoordinates()); - $c2 = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + list($column, $row) = Cell::coordinateFromString($this->object->getEndCoordinates()); + $c2 = Cell::columnIndexFromString($column) - 1; $r2 = $row - 1; // end offsetX diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index ba5c51bd..84b21981 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -114,7 +116,7 @@ class Font $bCharSet, $reserved ); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($this->font->getName()); + $data .= StringHelper::UTF8toBIFF8UnicodeShort($this->font->getName()); $length = strlen($data); $header = pack('vv', $record, $length); diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index dfa8bec5..f8243991 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -548,7 +551,7 @@ class Parser } // TODO: use real error codes - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown token $token"); + throw new WriterException("Unknown token $token"); } /** @@ -583,10 +586,10 @@ class Parser // chop away beggining and ending quotes $string = substr($string, 1, strlen($string) - 2); if (strlen($string) > 255) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('String is too long'); + throw new WriterException('String is too long'); } - return pack('C', $this->ptg['ptgStr']) . \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($string); + return pack('C', $this->ptg['ptgStr']) . StringHelper::UTF8toBIFF8UnicodeShort($string); } /** @@ -626,7 +629,7 @@ class Parser list($cell1, $cell2) = explode(':', $range); } else { // TODO: use real error codes - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Unknown range separator'); + throw new WriterException('Unknown range separator'); } // Convert the cell references @@ -642,7 +645,7 @@ class Parser $ptgArea = pack('C', $this->ptg['ptgAreaA']); } else { // TODO: use real error codes - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown class $class"); + throw new WriterException("Unknown class $class"); } return $ptgArea . $row1 . $row2 . $col1 . $col2; @@ -773,11 +776,11 @@ class Parser $sheet1 = $this->getSheetIndex($sheet_name1); if ($sheet1 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $sheet_name1 in formula"); + throw new WriterException("Unknown sheet name $sheet_name1 in formula"); } $sheet2 = $this->getSheetIndex($sheet_name2); if ($sheet2 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $sheet_name2 in formula"); + throw new WriterException("Unknown sheet name $sheet_name2 in formula"); } // Reverse max and min sheet numbers if necessary @@ -787,7 +790,7 @@ class Parser } else { // Single sheet name only. $sheet1 = $this->getSheetIndex($ext_ref); if ($sheet1 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $ext_ref in formula"); + throw new WriterException("Unknown sheet name $ext_ref in formula"); } $sheet2 = $sheet1; } @@ -819,11 +822,11 @@ class Parser $sheet1 = $this->getSheetIndex($sheet_name1); if ($sheet1 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $sheet_name1 in formula"); + throw new WriterException("Unknown sheet name $sheet_name1 in formula"); } $sheet2 = $this->getSheetIndex($sheet_name2); if ($sheet2 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $sheet_name2 in formula"); + throw new WriterException("Unknown sheet name $sheet_name2 in formula"); } // Reverse max and min sheet numbers if necessary @@ -833,7 +836,7 @@ class Parser } else { // Single sheet name only. $sheet1 = $this->getSheetIndex($ext_ref); if ($sheet1 == -1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Unknown sheet name $ext_ref in formula"); + throw new WriterException("Unknown sheet name $ext_ref in formula"); } $sheet2 = $sheet1; } @@ -903,10 +906,10 @@ class Parser $cell = strtoupper($cell); list($row, $col, $row_rel, $col_rel) = $this->cellToRowcol($cell); if ($col >= 256) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Column in: $cell greater than 255"); + throw new WriterException("Column in: $cell greater than 255"); } if ($row >= 65536) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Row in: $cell greater than 65536 "); + throw new WriterException("Row in: $cell greater than 65536 "); } // Set the high bits to indicate if row or col are relative. @@ -944,7 +947,7 @@ class Parser // FIXME: this changes for BIFF8 if (($row1 >= 65536) or ($row2 >= 65536)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Row in: $range greater than 65536 "); + throw new WriterException("Row in: $range greater than 65536 "); } // Set the high bits to indicate if rows are relative. @@ -1307,7 +1310,7 @@ class Parser $this->advance(); // eat the "(" $result = $this->parenthesizedExpression(); if ($this->currentToken != ')') { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("')' token expected."); + throw new WriterException("')' token expected."); } $this->advance(); // eat the ")" return $result; @@ -1369,7 +1372,7 @@ class Parser return $result; } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Syntax error: ' . $this->currentToken . ', lookahead: ' . $this->lookAhead . ', current char: ' . $this->currentCharacter); + throw new WriterException('Syntax error: ' . $this->currentToken . ', lookahead: ' . $this->lookAhead . ', current char: ' . $this->currentCharacter); } /** @@ -1390,7 +1393,7 @@ class Parser if ($this->currentToken == ',' || $this->currentToken == ';') { $this->advance(); // eat the "," or ";" } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Syntax error: comma expected in function $function, arg #{$num_args}"); + throw new WriterException("Syntax error: comma expected in function $function, arg #{$num_args}"); } $result2 = $this->condition(); $result = $this->createTree('arg', $result, $result2); @@ -1401,12 +1404,12 @@ class Parser ++$num_args; } if (!isset($this->functions[$function])) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Function $function() doesn't exist"); + throw new WriterException("Function $function() doesn't exist"); } $args = $this->functions[$function][1]; // If fixed number of args eg. TIME($i, $j, $k). Check that the number of args is valid. if (($args >= 0) and ($args != $num_args)) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Incorrect number of arguments in function $function() "); + throw new WriterException("Incorrect number of arguments in function $function() "); } $result = $this->createTree($function, $result, $num_args); diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 2f2056e1..a493a8bf 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -2,6 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -108,14 +114,14 @@ class Workbook extends BIFFwriter /** * Workbook. * - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadsheet; /** * Fonts writers. * - * @var \PhpOffice\PhpSpreadsheet\Writer\Xls\Font[] + * @var Font[] */ private $fontWriters = []; @@ -190,14 +196,14 @@ class Workbook extends BIFFwriter /** * Class constructor. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet The Workbook + * @param Spreadsheet $spreadsheet The Workbook * @param int $str_total Total number of strings * @param int $str_unique Total number of unique strings * @param array $str_table String Table * @param array $colors Colour Table * @param Parser $parser The formula parser created for the Workbook */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet, &$str_total, &$str_unique, &$str_table, &$colors, Parser $parser) + public function __construct(Spreadsheet $spreadsheet, &$str_total, &$str_unique, &$str_table, &$colors, Parser $parser) { // It needs to call its parent's constructor explicitly parent::__construct(); @@ -306,7 +312,7 @@ class Workbook extends BIFFwriter $countFonts = count($this->fontWriters); $fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1; - $fontWriter = new \PhpOffice\PhpSpreadsheet\Writer\Xls\Font($font); + $fontWriter = new Font($font); $fontWriter->setColorIndex($this->addColor($font->getColor()->getRGB())); $this->fontWriters[] = $fontWriter; @@ -484,7 +490,7 @@ class Workbook extends BIFFwriter // add size of Workbook globals part 2, the length of the SHEET records $total_worksheets = count($this->spreadsheet->getAllSheets()); foreach ($this->spreadsheet->getWorksheetIterator() as $sheet) { - $offset += $boundsheet_length + strlen(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheet->getTitle())); + $offset += $boundsheet_length + strlen(StringHelper::UTF8toBIFF8UnicodeShort($sheet->getTitle())); } // add the sizes of each of the Sheet substreams, respectively @@ -563,15 +569,15 @@ class Workbook extends BIFFwriter // Write a Name record if the print area has been defined if ($sheetSetup->isPrintAreaSet()) { // Print area - $printArea = \PhpOffice\PhpSpreadsheet\Cell::splitRange($sheetSetup->getPrintArea()); + $printArea = Cell::splitRange($sheetSetup->getPrintArea()); $printArea = $printArea[0]; - $printArea[0] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($printArea[0]); - $printArea[1] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($printArea[1]); + $printArea[0] = Cell::coordinateFromString($printArea[0]); + $printArea[1] = Cell::coordinateFromString($printArea[1]); $print_rowmin = $printArea[0][1] - 1; $print_rowmax = $printArea[1][1] - 1; - $print_colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($printArea[0][0]) - 1; - $print_colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($printArea[1][0]) - 1; + $print_colmin = Cell::columnIndexFromString($printArea[0][0]) - 1; + $print_colmax = Cell::columnIndexFromString($printArea[1][0]) - 1; $this->writeNameShort( $i, // sheet index @@ -591,8 +597,8 @@ class Workbook extends BIFFwriter // simultaneous repeatColumns repeatRows if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = Cell::columnIndexFromString($repeat[1]) - 1; $repeat = $sheetSetup->getRowsToRepeatAtTop(); $rowmin = $repeat[0] - 1; @@ -612,8 +618,8 @@ class Workbook extends BIFFwriter // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = Cell::columnIndexFromString($repeat[1]) - 1; } else { $colmin = 0; $colmax = 255; @@ -655,14 +661,14 @@ class Workbook extends BIFFwriter $namedRanges = $this->spreadsheet->getNamedRanges(); foreach ($namedRanges as $namedRange) { // Create absolute coordinate - $range = \PhpOffice\PhpSpreadsheet\Cell::splitRange($namedRange->getRange()); + $range = Cell::splitRange($namedRange->getRange()); for ($i = 0; $i < count($range); ++$i) { - $range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . \PhpOffice\PhpSpreadsheet\Cell::absoluteCoordinate($range[$i][0]); + $range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . Cell::absoluteCoordinate($range[$i][0]); if (isset($range[$i][1])) { - $range[$i][1] = \PhpOffice\PhpSpreadsheet\Cell::absoluteCoordinate($range[$i][1]); + $range[$i][1] = Cell::absoluteCoordinate($range[$i][1]); } } - $range = \PhpOffice\PhpSpreadsheet\Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2 + $range = Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2 // parse formula try { @@ -682,7 +688,7 @@ class Workbook extends BIFFwriter $scope = 0; } $chunk .= $this->writeData($this->writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false)); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { // do nothing } } @@ -697,8 +703,8 @@ class Workbook extends BIFFwriter // simultaneous repeatColumns repeatRows if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = Cell::columnIndexFromString($repeat[1]) - 1; $repeat = $sheetSetup->getRowsToRepeatAtTop(); $rowmin = $repeat[0] - 1; @@ -718,8 +724,8 @@ class Workbook extends BIFFwriter // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = Cell::columnIndexFromString($repeat[1]) - 1; } else { $colmin = 0; $colmax = 255; @@ -747,19 +753,19 @@ class Workbook extends BIFFwriter $sheetSetup = $this->spreadsheet->getSheet($i)->getPageSetup(); if ($sheetSetup->isPrintAreaSet()) { // Print area, e.g. A3:J6,H1:X20 - $printArea = \PhpOffice\PhpSpreadsheet\Cell::splitRange($sheetSetup->getPrintArea()); + $printArea = Cell::splitRange($sheetSetup->getPrintArea()); $countPrintArea = count($printArea); $formulaData = ''; for ($j = 0; $j < $countPrintArea; ++$j) { $printAreaRect = $printArea[$j]; // e.g. A3:J6 - $printAreaRect[0] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($printAreaRect[0]); - $printAreaRect[1] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($printAreaRect[1]); + $printAreaRect[0] = Cell::coordinateFromString($printAreaRect[0]); + $printAreaRect[1] = Cell::coordinateFromString($printAreaRect[1]); $print_rowmin = $printAreaRect[0][1] - 1; $print_rowmax = $printAreaRect[1][1] - 1; - $print_colmin = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($printAreaRect[0][0]) - 1; - $print_colmax = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($printAreaRect[1][0]) - 1; + $print_colmin = Cell::columnIndexFromString($printAreaRect[0][0]) - 1; + $print_colmax = Cell::columnIndexFromString($printAreaRect[1][0]) - 1; // construct formula data manually because parser does not recognize absolute 3d cell references $formulaData .= pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax); @@ -779,7 +785,7 @@ class Workbook extends BIFFwriter $sheetAutoFilter = $this->spreadsheet->getSheet($i)->getAutoFilter(); $autoFilterRange = $sheetAutoFilter->getRange(); if (!empty($autoFilterRange)) { - $rangeBounds = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($autoFilterRange); + $rangeBounds = Cell::rangeBoundaries($autoFilterRange); //Autofilter built in name $name = pack('C', 0x0D); @@ -809,10 +815,10 @@ class Workbook extends BIFFwriter $options = $isBuiltIn ? 0x20 : 0x00; // length of the name, character count - $nlen = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($name); + $nlen = StringHelper::countCharacters($name); // name with stripped length field - $name = substr(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($name), 2); + $name = substr(StringHelper::UTF8toBIFF8UnicodeLong($name), 2); // size of the formula (in bytes) $sz = strlen($formulaData); @@ -944,7 +950,7 @@ class Workbook extends BIFFwriter $grbit = 0x0000; // Visibility and sheet type $data = pack('VCC', $offset, $ss, $st); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheetname); + $data .= StringHelper::UTF8toBIFF8UnicodeShort($sheetname); $length = strlen($data); $header = pack('vv', $record, $length); @@ -1012,7 +1018,7 @@ class Workbook extends BIFFwriter { $record = 0x041E; // Record identifier - $numberFormatString = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($format); + $numberFormatString = StringHelper::UTF8toBIFF8UnicodeLong($format); $length = 2 + strlen($numberFormatString); // Number of bytes to follow $header = pack('vv', $record, $length); @@ -1028,7 +1034,7 @@ class Workbook extends BIFFwriter $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = (\PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar() == \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904) + $f1904 = (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) ? 1 : 0; // Flag for 1904 date system @@ -1416,7 +1422,7 @@ class Workbook extends BIFFwriter { // write the Escher stream if necessary if (isset($this->escher)) { - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls\Escher($this->escher); + $writer = new Escher($this->escher); $data = $writer->close(); $record = 0x00EB; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 464df8c3..3e02af33 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2,6 +2,22 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Cell\DataValidation; +use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Shared\Xls; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Color; +use PhpOffice\PhpSpreadsheet\Style\Conditional; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Protection; +use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; +use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -266,8 +282,8 @@ class Worksheet extends BIFFwriter // Determine lowest and highest column and row $this->lastRowIndex = ($maxR > 65535) ? 65535 : $maxR; - $this->firstColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($minC); - $this->lastColumnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($maxC); + $this->firstColumnIndex = Cell::columnIndexFromString($minC); + $this->lastColumnIndex = Cell::columnIndexFromString($maxC); // if ($this->firstColumnIndex > 255) $this->firstColumnIndex = 255; if ($this->lastColumnIndex > 255) { @@ -316,7 +332,7 @@ class Worksheet extends BIFFwriter $width = $defaultWidth; - $columnLetter = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($i); + $columnLetter = Cell::stringFromColumnIndex($i); if (isset($columnDimensions[$columnLetter])) { $columnDimension = $columnDimensions[$columnLetter]; if ($columnDimension->getWidth() >= 0) { @@ -401,56 +417,56 @@ class Worksheet extends BIFFwriter foreach ($phpSheet->getCoordinates() as $coordinate) { $cell = $phpSheet->getCell($coordinate); $row = $cell->getRow() - 1; - $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($cell->getColumn()) - 1; + $column = Cell::columnIndexFromString($cell->getColumn()) - 1; // Don't break Excel break the code! if ($row > 65535 || $column > 255) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Rows or columns overflow! Excel5 has limit to 65535 rows and 255 columns. Use XLSX instead.'); + throw new WriterException('Rows or columns overflow! Excel5 has limit to 65535 rows and 255 columns. Use XLSX instead.'); } // Write cell value $xfIndex = $cell->getXfIndex() + 15; // there are 15 cell style Xfs $cVal = $cell->getValue(); - if ($cVal instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if ($cVal instanceof RichText) { $arrcRun = []; - $str_len = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($cVal->getPlainText(), 'UTF-8'); + $str_len = StringHelper::countCharacters($cVal->getPlainText(), 'UTF-8'); $str_pos = 0; $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { // FONT Index - if ($element instanceof \PhpOffice\PhpSpreadsheet\RichText\Run) { + if ($element instanceof RichText\Run) { $str_fontidx = $this->fontHashIndex[$element->getFont()->getHashCode()]; } else { $str_fontidx = 0; } $arrcRun[] = ['strlen' => $str_pos, 'fontidx' => $str_fontidx]; // Position FROM - $str_pos += \PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($element->getText(), 'UTF-8'); + $str_pos += StringHelper::countCharacters($element->getText(), 'UTF-8'); } $this->writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun); } else { switch ($cell->getDatatype()) { - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING: - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL: + case Cell\DataType::TYPE_STRING: + case Cell\DataType::TYPE_NULL: if ($cVal === '' || $cVal === null) { $this->writeBlank($row, $column, $xfIndex); } else { $this->writeString($row, $column, $cVal, $xfIndex); } break; - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC: + case Cell\DataType::TYPE_NUMERIC: $this->writeNumber($row, $column, $cVal, $xfIndex); break; - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA: + case Cell\DataType::TYPE_FORMULA: $calculatedValue = $this->preCalculateFormulas ? $cell->getCalculatedValue() : null; $this->writeFormula($row, $column, $cVal, $xfIndex, $calculatedValue); break; - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL: + case Cell\DataType::TYPE_BOOL: $this->writeBoolErr($row, $column, $cVal, 0, $xfIndex); break; - case \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR: + case Cell\DataType::TYPE_ERROR: $this->writeBoolErr($row, $column, self::mapErrorCode($cVal), 1, $xfIndex); break; } @@ -480,7 +496,7 @@ class Worksheet extends BIFFwriter // Hyperlinks foreach ($phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) { - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($coordinate); + list($column, $row) = Cell::coordinateFromString($coordinate); $url = $hyperlink->getUrl(); @@ -494,7 +510,7 @@ class Worksheet extends BIFFwriter $url = 'external:' . $url; } - $this->writeUrl($row - 1, \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1, $url); + $this->writeUrl($row - 1, Cell::columnIndexFromString($column) - 1, $url); } $this->writeDataValidity(); @@ -513,8 +529,8 @@ class Worksheet extends BIFFwriter // Write ConditionalFormattingTable records foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) { foreach ($conditionalStyles as $conditional) { - if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION - || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) { + if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { if (!isset($arrConditional[$conditional->getHashCode()])) { // This hash code has been handled $arrConditional[$conditional->getHashCode()] = true; @@ -553,10 +569,10 @@ class Worksheet extends BIFFwriter $lastCell = $explodes[1]; } - $firstCellCoordinates = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($firstCell); // e.g. array(0, 1) - $lastCellCoordinates = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($lastCell); // e.g. array(1, 6) + $firstCellCoordinates = Cell::coordinateFromString($firstCell); // e.g. array(0, 1) + $lastCellCoordinates = Cell::coordinateFromString($lastCell); // e.g. array(1, 6) - return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($lastCellCoordinates[0]) - 1); + return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, Cell::columnIndexFromString($lastCellCoordinates[0]) - 1); } /** @@ -671,7 +687,7 @@ class Worksheet extends BIFFwriter { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun); + $str = StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -741,7 +757,7 @@ class Worksheet extends BIFFwriter $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($str); + $str = StringHelper::UTF8toBIFF8UnicodeLong($str); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -869,7 +885,7 @@ class Worksheet extends BIFFwriter // Numeric value $num = pack('d', $calculatedValue); } elseif (is_string($calculatedValue)) { - $errorCodes = \PhpOffice\PhpSpreadsheet\Cell\DataType::getErrorCodes(); + $errorCodes = Cell\DataType::getErrorCodes(); if (isset($errorCodes[$calculatedValue])) { // Error value $num = pack('CCCvCv', 0x02, 0x00, self::mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF); @@ -923,7 +939,7 @@ class Worksheet extends BIFFwriter } return 0; - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { // do nothing } } @@ -936,7 +952,7 @@ class Worksheet extends BIFFwriter private function writeStringRecord($stringValue) { $record = 0x0207; // Record identifier - $data = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($stringValue); + $data = StringHelper::UTF8toBIFF8UnicodeLong($stringValue); $length = strlen($data); $header = pack('vv', $record, $length); @@ -1078,10 +1094,10 @@ class Worksheet extends BIFFwriter $url .= "\0"; // character count - $url_len = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::countCharacters($url); + $url_len = StringHelper::countCharacters($url); $url_len = pack('V', $url_len); - $url = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::convertEncoding($url, 'UTF-16LE', 'UTF-8'); + $url = StringHelper::convertEncoding($url, 'UTF-16LE', 'UTF-8'); // Calculate the data length $length = 0x24 + strlen($url); @@ -1293,7 +1309,7 @@ class Worksheet extends BIFFwriter // no support in PhpSpreadsheet for selected sheet, therefore sheet is only selected if it is the active sheet $fSelected = ($this->phpSheet === $this->phpSheet->getParent()->getActiveSheet()) ? 1 : 0; $fPaged = 1; // 2 - $fPageBreakPreview = $this->phpSheet->getSheetView()->getView() === \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW; + $fPageBreakPreview = $this->phpSheet->getSheetView()->getView() === SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW; $grbit = $fDspFmla; $grbit |= $fDspGrid << 1; @@ -1423,7 +1439,7 @@ class Worksheet extends BIFFwriter { // look up the selected cell range $selectedCells = $this->phpSheet->getSelectedCells(); - $selectedCells = \PhpOffice\PhpSpreadsheet\Cell::splitRange($this->phpSheet->getSelectedCells()); + $selectedCells = Cell::splitRange($this->phpSheet->getSelectedCells()); $selectedCells = $selectedCells[0]; if (count($selectedCells) == 2) { list($first, $last) = $selectedCells; @@ -1432,12 +1448,12 @@ class Worksheet extends BIFFwriter $last = $selectedCells[0]; } - list($colFirst, $rwFirst) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($first); - $colFirst = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colFirst) - 1; // base 0 column index + list($colFirst, $rwFirst) = Cell::coordinateFromString($first); + $colFirst = Cell::columnIndexFromString($colFirst) - 1; // base 0 column index --$rwFirst; // base 0 row index - list($colLast, $rwLast) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($last); - $colLast = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colLast) - 1; // base 0 column index + list($colLast, $rwLast) = Cell::coordinateFromString($last); + $colLast = Cell::columnIndexFromString($colLast) - 1; // base 0 column index --$rwLast; // base 0 row index // make sure we are not out of bounds @@ -1510,12 +1526,12 @@ class Worksheet extends BIFFwriter ++$j; // extract the row and column indexes - $range = \PhpOffice\PhpSpreadsheet\Cell::splitRange($mergeCell); + $range = Cell::splitRange($mergeCell); list($first, $last) = $range[0]; - list($firstColumn, $firstRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($first); - list($lastColumn, $lastRow) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($last); + list($firstColumn, $firstRow) = Cell::coordinateFromString($first); + list($lastColumn, $lastRow) = Cell::coordinateFromString($last); - $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($firstColumn) - 1, \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($lastColumn) - 1); + $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, Cell::columnIndexFromString($firstColumn) - 1, Cell::columnIndexFromString($lastColumn) - 1); // flush record if we have reached limit for number of merged cells, or reached final merged cell if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) { @@ -1640,7 +1656,7 @@ class Worksheet extends BIFFwriter hexdec($password) ); - $recordData .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); + $recordData .= StringHelper::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); $length = strlen($recordData); @@ -1713,9 +1729,9 @@ class Worksheet extends BIFFwriter { $panes = []; if ($freezePane = $this->phpSheet->getFreezePane()) { - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($freezePane); + list($column, $row) = Cell::coordinateFromString($freezePane); $panes[0] = $row - 1; - $panes[1] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column) - 1; + $panes[1] = Cell::columnIndexFromString($column) - 1; } else { // thaw panes return; @@ -1813,7 +1829,7 @@ class Worksheet extends BIFFwriter $fLeftToRight = 0x0; // Print over then down // Page orientation - $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? + $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) ? 0x0 : 0x1; $fNoPls = 0x0; // Setup not read from printer @@ -1862,7 +1878,7 @@ class Worksheet extends BIFFwriter } */ - $recordData = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); + $recordData = StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); $length = strlen($recordData); $header = pack('vv', $record, $length); @@ -1886,7 +1902,7 @@ class Worksheet extends BIFFwriter } */ - $recordData = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); + $recordData = StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); $length = strlen($recordData); $header = pack('vv', $record, $length); @@ -2056,7 +2072,7 @@ class Worksheet extends BIFFwriter $record = 0x009D; // Record identifier $length = 0x0002; // Bytes to follow - $rangeBounds = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange()); + $rangeBounds = Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange()); $iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0]; $header = pack('vv', $record, $length); @@ -2158,13 +2174,13 @@ class Worksheet extends BIFFwriter foreach ($this->phpSheet->getBreaks() as $cell => $breakType) { // Fetch coordinates - $coordinates = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($cell); + $coordinates = Cell::coordinateFromString($cell); // Decide what to do by the type of break switch ($breakType) { case \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_COLUMN: // Add to list of vertical breaks - $vbreaks[] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($coordinates[0]) - 1; + $vbreaks[] = Cell::columnIndexFromString($coordinates[0]) - 1; break; case \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW: // Add to list of horizontal breaks @@ -2409,10 +2425,10 @@ class Worksheet extends BIFFwriter $row_end = $row_start; // Row containing bottom right corner of object // Zero the specified offset if greater than the cell dimensions - if ($x1 >= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) { + if ($x1 >= Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_start))) { $x1 = 0; } - if ($y1 >= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_start + 1)) { + if ($y1 >= Xls::sizeRow($this->phpSheet, $row_start + 1)) { $y1 = 0; } @@ -2420,38 +2436,38 @@ class Worksheet extends BIFFwriter $height = $height + $y1 - 1; // Subtract the underlying cell widths to find the end cell of the image - while ($width >= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end))) { - $width -= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)); + while ($width >= Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_end))) { + $width -= Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_end)); ++$col_end; } // Subtract the underlying cell heights to find the end cell of the image - while ($height >= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_end + 1)) { - $height -= \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_end + 1); + while ($height >= Xls::sizeRow($this->phpSheet, $row_end + 1)) { + $height -= Xls::sizeRow($this->phpSheet, $row_end + 1); ++$row_end; } // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // with zero eight or width. // - if (\PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start)) == 0) { + if (Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_start)) == 0) { return; } - if (\PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)) == 0) { + if (Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_end)) == 0) { return; } - if (\PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_start + 1) == 0) { + if (Xls::sizeRow($this->phpSheet, $row_start + 1) == 0) { return; } - if (\PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_end + 1) == 0) { + if (Xls::sizeRow($this->phpSheet, $row_end + 1) == 0) { return; } // Convert the pixel values to the percentage value expected by Excel - $x1 = $x1 / \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_start)) * 1024; - $y1 = $y1 / \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_start + 1) * 256; - $x2 = $width / \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeCol($this->phpSheet, \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object - $y2 = $height / \PhpOffice\PhpSpreadsheet\Shared\Xls::sizeRow($this->phpSheet, $row_end + 1) * 256; // Distance to bottom of object + $x1 = $x1 / Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_start)) * 1024; + $y1 = $y1 / Xls::sizeRow($this->phpSheet, $row_start + 1) * 256; + $x2 = $width / Xls::sizeCol($this->phpSheet, Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object + $y2 = $height / Xls::sizeRow($this->phpSheet, $row_end + 1) * 256; // Distance to bottom of object $this->writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2); } @@ -2577,7 +2593,7 @@ class Worksheet extends BIFFwriter // Open file. $bmp_fd = @fopen($bitmap, 'rb'); if (!$bmp_fd) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Couldn't import $bitmap"); + throw new WriterException("Couldn't import $bitmap"); } // Slurp the file into a string. @@ -2585,13 +2601,13 @@ class Worksheet extends BIFFwriter // Check that the file is big enough to be a bitmap. if (strlen($data) <= 0x36) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap doesn't contain enough data.\n"); + throw new WriterException("$bitmap doesn't contain enough data.\n"); } // The first 2 bytes are used to identify the bitmap. $identity = unpack('A2ident', $data); if ($identity['ident'] != 'BM') { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap doesn't appear to be a valid bitmap image.\n"); + throw new WriterException("$bitmap doesn't appear to be a valid bitmap image.\n"); } // Remove bitmap data: ID. @@ -2615,20 +2631,20 @@ class Worksheet extends BIFFwriter $height = $width_and_height[2]; $data = substr($data, 8); if ($width > 0xFFFF) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap: largest image width supported is 65k.\n"); + throw new WriterException("$bitmap: largest image width supported is 65k.\n"); } if ($height > 0xFFFF) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap: largest image height supported is 65k.\n"); + throw new WriterException("$bitmap: largest image height supported is 65k.\n"); } // Read and remove the bitmap planes and bpp data. Verify them. $planes_and_bitcount = unpack('v2', substr($data, 0, 4)); $data = substr($data, 4); if ($planes_and_bitcount[2] != 24) { // Bitcount - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap isn't a 24bit true color bitmap.\n"); + throw new WriterException("$bitmap isn't a 24bit true color bitmap.\n"); } if ($planes_and_bitcount[1] != 1) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap: only 1 plane supported in bitmap image.\n"); + throw new WriterException("$bitmap: only 1 plane supported in bitmap image.\n"); } // Read and remove the bitmap compression. Verify compression. @@ -2636,7 +2652,7 @@ class Worksheet extends BIFFwriter $data = substr($data, 4); if ($compression['comp'] != 0) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("$bitmap: compression not supported in bitmap image.\n"); + throw new WriterException("$bitmap: compression not supported in bitmap image.\n"); } // Remove bitmap data: data size, hres, vres, colours, imp. colours. @@ -2695,7 +2711,7 @@ class Worksheet extends BIFFwriter { // write the Escher stream if necessary if (isset($this->escher)) { - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xls\Escher($this->escher); + $writer = new Escher($this->escher); $data = $writer->close(); $spOffsets = $writer->getSpOffsets(); $spTypes = $writer->getSpTypes(); @@ -2809,28 +2825,28 @@ class Worksheet extends BIFFwriter // data type $type = $dataValidation->getType(); switch ($type) { - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE: + case DataValidation::TYPE_NONE: $type = 0x00; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE: + case DataValidation::TYPE_WHOLE: $type = 0x01; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL: + case DataValidation::TYPE_DECIMAL: $type = 0x02; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST: + case DataValidation::TYPE_LIST: $type = 0x03; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE: + case DataValidation::TYPE_DATE: $type = 0x04; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME: + case DataValidation::TYPE_TIME: $type = 0x05; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH: + case DataValidation::TYPE_TEXTLENGTH: $type = 0x06; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM: + case DataValidation::TYPE_CUSTOM: $type = 0x07; break; } @@ -2840,13 +2856,13 @@ class Worksheet extends BIFFwriter // error style $errorStyle = $dataValidation->getErrorStyle(); switch ($errorStyle) { - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP: + case DataValidation::STYLE_STOP: $errorStyle = 0x00; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_WARNING: + case DataValidation::STYLE_WARNING: $errorStyle = 0x01; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION: + case DataValidation::STYLE_INFORMATION: $errorStyle = 0x02; break; } @@ -2873,28 +2889,28 @@ class Worksheet extends BIFFwriter // condition operator $operator = $dataValidation->getOperator(); switch ($operator) { - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN: + case DataValidation::OPERATOR_BETWEEN: $operator = 0x00; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN: + case DataValidation::OPERATOR_NOTBETWEEN: $operator = 0x01; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL: + case DataValidation::OPERATOR_EQUAL: $operator = 0x02; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL: + case DataValidation::OPERATOR_NOTEQUAL: $operator = 0x03; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN: + case DataValidation::OPERATOR_GREATERTHAN: $operator = 0x04; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN: + case DataValidation::OPERATOR_LESSTHAN: $operator = 0x05; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL: + case DataValidation::OPERATOR_GREATERTHANOREQUAL: $operator = 0x06; break; - case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL: + case DataValidation::OPERATOR_LESSTHANOREQUAL: $operator = 0x07; break; } @@ -2906,22 +2922,22 @@ class Worksheet extends BIFFwriter // prompt title $promptTitle = $dataValidation->getPromptTitle() !== '' ? $dataValidation->getPromptTitle() : chr(0); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($promptTitle); + $data .= StringHelper::UTF8toBIFF8UnicodeLong($promptTitle); // error title $errorTitle = $dataValidation->getErrorTitle() !== '' ? $dataValidation->getErrorTitle() : chr(0); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($errorTitle); + $data .= StringHelper::UTF8toBIFF8UnicodeLong($errorTitle); // prompt text $prompt = $dataValidation->getPrompt() !== '' ? $dataValidation->getPrompt() : chr(0); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($prompt); + $data .= StringHelper::UTF8toBIFF8UnicodeLong($prompt); // error text $error = $dataValidation->getError() !== '' ? $dataValidation->getError() : chr(0); - $data .= \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($error); + $data .= StringHelper::UTF8toBIFF8UnicodeLong($error); // formula 1 try { @@ -2932,7 +2948,7 @@ class Worksheet extends BIFFwriter $this->parser->parse($formula1); $formula1 = $this->parser->toReversePolish(); $sz1 = strlen($formula1); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { $sz1 = 0; $formula1 = ''; } @@ -2943,12 +2959,12 @@ class Worksheet extends BIFFwriter try { $formula2 = $dataValidation->getFormula2(); if ($formula2 === '') { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('No formula2'); + throw new WriterException('No formula2'); } $this->parser->parse($formula2); $formula2 = $this->parser->toReversePolish(); $sz2 = strlen($formula2); - } catch (\PhpOffice\PhpSpreadsheet\Exception $e) { + } catch (PhpSpreadsheetException $e) { $sz2 = 0; $formula2 = ''; } @@ -3010,7 +3026,7 @@ class Worksheet extends BIFFwriter $wScalvePLV = $this->phpSheet->getSheetView()->getZoomScale(); // 2 // The options flags that comprise $grbit - if ($this->phpSheet->getSheetView()->getView() == \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT) { + if ($this->phpSheet->getSheetView()->getView() == SheetView::SHEETVIEW_PAGE_LAYOUT) { $fPageLayoutView = 1; } else { $fPageLayoutView = 0; @@ -3030,43 +3046,43 @@ class Worksheet extends BIFFwriter /** * Write CFRule Record. * - * @param \PhpOffice\PhpSpreadsheet\Style\Conditional $conditional + * @param Conditional $conditional */ - private function writeCFRule(\PhpOffice\PhpSpreadsheet\Style\Conditional $conditional) + private function writeCFRule(Conditional $conditional) { $record = 0x01B1; // Record identifier // $type : Type of the CF // $operatorType : Comparison operator - if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION) { + if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { $type = 0x02; $operatorType = 0x00; - } elseif ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) { + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CELLIS) { $type = 0x01; switch ($conditional->getOperatorType()) { - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_NONE: + case Conditional::OPERATOR_NONE: $operatorType = 0x00; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_EQUAL: + case Conditional::OPERATOR_EQUAL: $operatorType = 0x03; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHAN: + case Conditional::OPERATOR_GREATERTHAN: $operatorType = 0x05; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL: + case Conditional::OPERATOR_GREATERTHANOREQUAL: $operatorType = 0x07; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN: + case Conditional::OPERATOR_LESSTHAN: $operatorType = 0x06; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHANOREQUAL: + case Conditional::OPERATOR_LESSTHANOREQUAL: $operatorType = 0x08; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_NOTEQUAL: + case Conditional::OPERATOR_NOTEQUAL: $operatorType = 0x04; break; - case \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_BETWEEN: + case Conditional::OPERATOR_BETWEEN: $operatorType = 0x01; break; // not OPERATOR_NOTBETWEEN 0x02 @@ -3082,7 +3098,7 @@ class Worksheet extends BIFFwriter $szValue2 = 0x0000; $operand1 = pack('Cv', 0x1E, $arrConditions[0]); $operand2 = null; - } elseif ($numConditions == 2 && ($conditional->getOperatorType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_BETWEEN)) { + } elseif ($numConditions == 2 && ($conditional->getOperatorType() == Conditional::OPERATOR_BETWEEN)) { $szValue1 = ($arrConditions[0] <= 65535 ? 3 : 0x0000); $szValue2 = ($arrConditions[1] <= 65535 ? 3 : 0x0000); $operand1 = pack('Cv', 0x1E, $arrConditions[0]); @@ -3116,14 +3132,14 @@ class Worksheet extends BIFFwriter $bFormatProt = 0; } // Border - $bBorderLeft = ($conditional->getStyle()->getBorders()->getLeft()->getColor()->getARGB() == \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE ? 1 : 0); - $bBorderRight = ($conditional->getStyle()->getBorders()->getRight()->getColor()->getARGB() == \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE ? 1 : 0); - $bBorderTop = ($conditional->getStyle()->getBorders()->getTop()->getColor()->getARGB() == \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE ? 1 : 0); - $bBorderBottom = ($conditional->getStyle()->getBorders()->getBottom()->getColor()->getARGB() == \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_BLACK - && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE ? 1 : 0); + $bBorderLeft = ($conditional->getStyle()->getBorders()->getLeft()->getColor()->getARGB() == Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + $bBorderRight = ($conditional->getStyle()->getBorders()->getRight()->getColor()->getARGB() == Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + $bBorderTop = ($conditional->getStyle()->getBorders()->getTop()->getColor()->getARGB() == Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); + $bBorderBottom = ($conditional->getStyle()->getBorders()->getBottom()->getColor()->getARGB() == Color::COLOR_BLACK + && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == Border::BORDER_NONE ? 1 : 0); if ($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0) { $bFormatBorder = 1; } else { @@ -3199,7 +3215,7 @@ class Worksheet extends BIFFwriter $dataBlockFont = pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); $dataBlockFont .= pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); } else { - $dataBlockFont = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); + $dataBlockFont = StringHelper::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); } // Font Size if ($conditional->getStyle()->getFont()->getSize() == null) { @@ -3458,22 +3474,22 @@ class Worksheet extends BIFFwriter $blockAlign = 0; // Alignment and text break switch ($conditional->getStyle()->getAlignment()->getHorizontal()) { - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL: + case Alignment::HORIZONTAL_GENERAL: $blockAlign = 0; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT: + case Alignment::HORIZONTAL_LEFT: $blockAlign = 1; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT: + case Alignment::HORIZONTAL_RIGHT: $blockAlign = 3; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER: + case Alignment::HORIZONTAL_CENTER: $blockAlign = 2; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS: + case Alignment::HORIZONTAL_CENTER_CONTINUOUS: $blockAlign = 6; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY: + case Alignment::HORIZONTAL_JUSTIFY: $blockAlign = 5; break; } @@ -3483,16 +3499,16 @@ class Worksheet extends BIFFwriter $blockAlign |= 0 << 3; } switch ($conditional->getStyle()->getAlignment()->getVertical()) { - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM: + case Alignment::VERTICAL_BOTTOM: $blockAlign = 2 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP: + case Alignment::VERTICAL_TOP: $blockAlign = 0 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER: + case Alignment::VERTICAL_CENTER: $blockAlign = 1 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY: + case Alignment::VERTICAL_JUSTIFY: $blockAlign = 3 << 4; break; } @@ -3518,178 +3534,178 @@ class Worksheet extends BIFFwriter if ($bFormatBorder == 1) { $blockLineStyle = 0; switch ($conditional->getStyle()->getBorders()->getLeft()->getBorderStyle()) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: $blockLineStyle |= 0x00; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: $blockLineStyle |= 0x01; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: $blockLineStyle |= 0x02; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: $blockLineStyle |= 0x03; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: $blockLineStyle |= 0x04; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: $blockLineStyle |= 0x05; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: $blockLineStyle |= 0x06; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: $blockLineStyle |= 0x07; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: $blockLineStyle |= 0x08; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: $blockLineStyle |= 0x09; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: $blockLineStyle |= 0x0A; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: $blockLineStyle |= 0x0B; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: $blockLineStyle |= 0x0C; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: $blockLineStyle |= 0x0D; break; } switch ($conditional->getStyle()->getBorders()->getRight()->getBorderStyle()) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: $blockLineStyle |= 0x00 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: $blockLineStyle |= 0x01 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: $blockLineStyle |= 0x02 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: $blockLineStyle |= 0x03 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: $blockLineStyle |= 0x04 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: $blockLineStyle |= 0x05 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: $blockLineStyle |= 0x06 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: $blockLineStyle |= 0x07 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: $blockLineStyle |= 0x08 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: $blockLineStyle |= 0x09 << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: $blockLineStyle |= 0x0A << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: $blockLineStyle |= 0x0B << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: $blockLineStyle |= 0x0C << 4; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: $blockLineStyle |= 0x0D << 4; break; } switch ($conditional->getStyle()->getBorders()->getTop()->getBorderStyle()) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: $blockLineStyle |= 0x00 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: $blockLineStyle |= 0x01 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: $blockLineStyle |= 0x02 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: $blockLineStyle |= 0x03 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: $blockLineStyle |= 0x04 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: $blockLineStyle |= 0x05 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: $blockLineStyle |= 0x06 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: $blockLineStyle |= 0x07 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: $blockLineStyle |= 0x08 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: $blockLineStyle |= 0x09 << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: $blockLineStyle |= 0x0A << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: $blockLineStyle |= 0x0B << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: $blockLineStyle |= 0x0C << 8; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: $blockLineStyle |= 0x0D << 8; break; } switch ($conditional->getStyle()->getBorders()->getBottom()->getBorderStyle()) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: $blockLineStyle |= 0x00 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: $blockLineStyle |= 0x01 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: $blockLineStyle |= 0x02 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: $blockLineStyle |= 0x03 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: $blockLineStyle |= 0x04 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: $blockLineStyle |= 0x05 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: $blockLineStyle |= 0x06 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: $blockLineStyle |= 0x07 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: $blockLineStyle |= 0x08 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: $blockLineStyle |= 0x09 << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: $blockLineStyle |= 0x0A << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: $blockLineStyle |= 0x0B << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: $blockLineStyle |= 0x0C << 12; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: $blockLineStyle |= 0x0D << 12; break; } @@ -3702,46 +3718,46 @@ class Worksheet extends BIFFwriter //@todo writeCFRule() => $blockColor => Index Color for bottom line //@todo writeCFRule() => $blockColor => Index Color for diagonal line switch ($conditional->getStyle()->getBorders()->getDiagonal()->getBorderStyle()) { - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE: + case Border::BORDER_NONE: $blockColor |= 0x00 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN: + case Border::BORDER_THIN: $blockColor |= 0x01 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM: + case Border::BORDER_MEDIUM: $blockColor |= 0x02 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED: + case Border::BORDER_DASHED: $blockColor |= 0x03 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED: + case Border::BORDER_DOTTED: $blockColor |= 0x04 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK: + case Border::BORDER_THICK: $blockColor |= 0x05 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE: + case Border::BORDER_DOUBLE: $blockColor |= 0x06 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR: + case Border::BORDER_HAIR: $blockColor |= 0x07 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED: + case Border::BORDER_MEDIUMDASHED: $blockColor |= 0x08 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT: + case Border::BORDER_DASHDOT: $blockColor |= 0x09 << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT: + case Border::BORDER_MEDIUMDASHDOT: $blockColor |= 0x0A << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT: + case Border::BORDER_DASHDOTDOT: $blockColor |= 0x0B << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT: + case Border::BORDER_MEDIUMDASHDOTDOT: $blockColor |= 0x0C << 21; break; - case \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT: + case Border::BORDER_SLANTDASHDOT: $blockColor |= 0x0D << 21; break; } @@ -3751,67 +3767,67 @@ class Worksheet extends BIFFwriter // Fill Patern Style $blockFillPatternStyle = 0; switch ($conditional->getStyle()->getFill()->getFillType()) { - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE: + case Fill::FILL_NONE: $blockFillPatternStyle = 0x00; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID: + case Fill::FILL_SOLID: $blockFillPatternStyle = 0x01; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY: + case Fill::FILL_PATTERN_MEDIUMGRAY: $blockFillPatternStyle = 0x02; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY: + case Fill::FILL_PATTERN_DARKGRAY: $blockFillPatternStyle = 0x03; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY: + case Fill::FILL_PATTERN_LIGHTGRAY: $blockFillPatternStyle = 0x04; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL: + case Fill::FILL_PATTERN_DARKHORIZONTAL: $blockFillPatternStyle = 0x05; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL: + case Fill::FILL_PATTERN_DARKVERTICAL: $blockFillPatternStyle = 0x06; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN: + case Fill::FILL_PATTERN_DARKDOWN: $blockFillPatternStyle = 0x07; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP: + case Fill::FILL_PATTERN_DARKUP: $blockFillPatternStyle = 0x08; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID: + case Fill::FILL_PATTERN_DARKGRID: $blockFillPatternStyle = 0x09; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS: + case Fill::FILL_PATTERN_DARKTRELLIS: $blockFillPatternStyle = 0x0A; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL: + case Fill::FILL_PATTERN_LIGHTHORIZONTAL: $blockFillPatternStyle = 0x0B; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL: + case Fill::FILL_PATTERN_LIGHTVERTICAL: $blockFillPatternStyle = 0x0C; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN: + case Fill::FILL_PATTERN_LIGHTDOWN: $blockFillPatternStyle = 0x0D; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP: + case Fill::FILL_PATTERN_LIGHTUP: $blockFillPatternStyle = 0x0E; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID: + case Fill::FILL_PATTERN_LIGHTGRID: $blockFillPatternStyle = 0x0F; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS: + case Fill::FILL_PATTERN_LIGHTTRELLIS: $blockFillPatternStyle = 0x10; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125: + case Fill::FILL_PATTERN_GRAY125: $blockFillPatternStyle = 0x11; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625: + case Fill::FILL_PATTERN_GRAY0625: $blockFillPatternStyle = 0x12; break; - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR: + case Fill::FILL_GRADIENT_LINEAR: $blockFillPatternStyle = 0x00; break; // does not exist in BIFF8 - case \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH: + case Fill::FILL_GRADIENT_PATH: $blockFillPatternStyle = 0x00; break; // does not exist in BIFF8 default: @@ -4171,10 +4187,10 @@ class Worksheet extends BIFFwriter } if ($bFormatProt == 1) { $dataBlockProtection = 0; - if ($conditional->getStyle()->getProtection()->getLocked() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED) { + if ($conditional->getStyle()->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED) { $dataBlockProtection = 1; } - if ($conditional->getStyle()->getProtection()->getHidden() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED) { + if ($conditional->getStyle()->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED) { $dataBlockProtection = 1 << 1; } } @@ -4220,15 +4236,15 @@ class Worksheet extends BIFFwriter $arrConditional = []; foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($conditionalStyles as $conditional) { - if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION - || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) { + if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { if (!in_array($conditional->getHashCode(), $arrConditional)) { $arrConditional[] = $conditional->getHashCode(); } // Cells - $arrCoord = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($cellCoordinate); + $arrCoord = Cell::coordinateFromString($cellCoordinate); if (!is_numeric($arrCoord[0])) { - $arrCoord[0] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($arrCoord[0]); + $arrCoord[0] = Cell::columnIndexFromString($arrCoord[0]); } if (is_null($numColumnMin) || ($numColumnMin > $arrCoord[0])) { $numColumnMin = $arrCoord[0]; diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index 23f76f6a..8b911cb7 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -2,6 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xls; +use PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Borders; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Protection; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -134,9 +141,9 @@ class Xf /** * Constructor. * - * @param \PhpOffice\PhpSpreadsheet\Style The XF format + * @param Style The XF format */ - public function __construct(\PhpOffice\PhpSpreadsheet\Style $style) + public function __construct(Style $style) { $this->isStyleXf = false; $this->fontIndex = 0; @@ -233,10 +240,10 @@ class Xf $border1 |= $this->rightBorderColor << 23; $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection(); - $diag_tl_to_rb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH - || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN; - $diag_tr_to_lb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH - || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP; + $diag_tl_to_rb = $diagonalDirection == Borders::DIAGONAL_BOTH + || $diagonalDirection == Borders::DIAGONAL_DOWN; + $diag_tr_to_lb = $diagonalDirection == Borders::DIAGONAL_BOTH + || $diagonalDirection == Borders::DIAGONAL_UP; $border1 |= $diag_tl_to_rb << 30; $border1 |= $diag_tr_to_lb << 31; @@ -366,20 +373,20 @@ class Xf * @static array of int */ private static $mapBorderStyles = [ - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE => 0x00, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN => 0x01, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM => 0x02, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED => 0x03, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED => 0x04, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK => 0x05, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE => 0x06, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR => 0x07, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED => 0x08, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT => 0x09, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT => 0x0A, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT => 0x0B, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT => 0x0C, - \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT => 0x0D, + Border::BORDER_NONE => 0x00, + Border::BORDER_THIN => 0x01, + Border::BORDER_MEDIUM => 0x02, + Border::BORDER_DASHED => 0x03, + Border::BORDER_DOTTED => 0x04, + Border::BORDER_THICK => 0x05, + Border::BORDER_DOUBLE => 0x06, + Border::BORDER_HAIR => 0x07, + Border::BORDER_MEDIUMDASHED => 0x08, + Border::BORDER_DASHDOT => 0x09, + Border::BORDER_MEDIUMDASHDOT => 0x0A, + Border::BORDER_DASHDOTDOT => 0x0B, + Border::BORDER_MEDIUMDASHDOTDOT => 0x0C, + Border::BORDER_SLANTDASHDOT => 0x0D, ]; /** @@ -404,27 +411,27 @@ class Xf * @static array of int */ private static $mapFillTypes = [ - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE => 0x00, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID => 0x01, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY => 0x02, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY => 0x03, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY => 0x04, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL => 0x06, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN => 0x07, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP => 0x08, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID => 0x09, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS => 0x0A, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN => 0x0D, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP => 0x0E, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID => 0x0F, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125 => 0x11, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625 => 0x12, - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8 - \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8 + Fill::FILL_NONE => 0x00, + Fill::FILL_SOLID => 0x01, + Fill::FILL_PATTERN_MEDIUMGRAY => 0x02, + Fill::FILL_PATTERN_DARKGRAY => 0x03, + Fill::FILL_PATTERN_LIGHTGRAY => 0x04, + Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05, + Fill::FILL_PATTERN_DARKVERTICAL => 0x06, + Fill::FILL_PATTERN_DARKDOWN => 0x07, + Fill::FILL_PATTERN_DARKUP => 0x08, + Fill::FILL_PATTERN_DARKGRID => 0x09, + Fill::FILL_PATTERN_DARKTRELLIS => 0x0A, + Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B, + Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C, + Fill::FILL_PATTERN_LIGHTDOWN => 0x0D, + Fill::FILL_PATTERN_LIGHTUP => 0x0E, + Fill::FILL_PATTERN_LIGHTGRID => 0x0F, + Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10, + Fill::FILL_PATTERN_GRAY125 => 0x11, + Fill::FILL_PATTERN_GRAY0625 => 0x12, + Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8 + Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8 ]; /** @@ -449,13 +456,13 @@ class Xf * @static array of int */ private static $mapHAlignments = [ - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL => 0, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT => 1, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER => 2, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT => 3, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_FILL => 4, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY => 5, - \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6, + Alignment::HORIZONTAL_GENERAL => 0, + Alignment::HORIZONTAL_LEFT => 1, + Alignment::HORIZONTAL_CENTER => 2, + Alignment::HORIZONTAL_RIGHT => 3, + Alignment::HORIZONTAL_FILL => 4, + Alignment::HORIZONTAL_JUSTIFY => 5, + Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6, ]; /** @@ -480,10 +487,10 @@ class Xf * @static array of int */ private static $mapVAlignments = [ - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP => 0, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER => 1, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM => 2, - \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY => 3, + Alignment::VERTICAL_TOP => 0, + Alignment::VERTICAL_CENTER => 1, + Alignment::VERTICAL_BOTTOM => 2, + Alignment::VERTICAL_JUSTIFY => 3, ]; /** @@ -531,11 +538,11 @@ class Xf private static function mapLocked($locked) { switch ($locked) { - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT: + case Protection::PROTECTION_INHERIT: return 1; - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED: + case Protection::PROTECTION_PROTECTED: return 1; - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED: + case Protection::PROTECTION_UNPROTECTED: return 0; default: return 1; @@ -553,11 +560,11 @@ class Xf private static function mapHidden($hidden) { switch ($hidden) { - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT: + case Protection::PROTECTION_INHERIT: return 0; - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED: + case Protection::PROTECTION_PROTECTED: return 1; - case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED: + case Protection::PROTECTION_UNPROTECTED: return 0; default: return 0; diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 56f1c508..93ea21db 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -2,7 +2,27 @@ namespace PhpOffice\PhpSpreadsheet\Writer; +use PhpOffice\PhpSpreadsheet\Calculation; +use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheet\HashTable; +use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing as WorksheetDrawing; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Chart; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Comments; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet; use ZipArchive; /** @@ -46,7 +66,7 @@ class Xlsx extends BaseWriter implements IWriter /** * Private Spreadsheet. * - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadSheet; @@ -58,78 +78,78 @@ class Xlsx extends BaseWriter implements IWriter private $stringTable = []; /** - * Private unique \PhpOffice\PhpSpreadsheet\Style\Conditional HashTable. + * Private unique Conditional HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $stylesConditionalHashTable; /** - * Private unique \PhpOffice\PhpSpreadsheet\Style HashTable. + * Private unique Style HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $styleHashTable; /** - * Private unique \PhpOffice\PhpSpreadsheet\Style\Fill HashTable. + * Private unique Fill HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $fillHashTable; /** * Private unique \PhpOffice\PhpSpreadsheet\Style\Font HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $fontHashTable; /** - * Private unique \PhpOffice\PhpSpreadsheet\Style\Borders HashTable. + * Private unique Borders HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $bordersHashTable; /** - * Private unique \PhpOffice\PhpSpreadsheet\Style\NumberFormat HashTable. + * Private unique NumberFormat HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $numFmtHashTable; /** * Private unique \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing HashTable. * - * @var \PhpOffice\PhpSpreadsheet\HashTable + * @var HashTable */ private $drawingHashTable; /** * Create a new Xlsx Writer. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) + public function __construct(Spreadsheet $spreadsheet) { // Assign PhpSpreadsheet $this->setSpreadsheet($spreadsheet); $writerPartsArray = [ - 'stringtable' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable::class, - 'contenttypes' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes::class, - 'docprops' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps::class, - 'rels' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels::class, - 'theme' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme::class, - 'style' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style::class, - 'workbook' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook::class, - 'worksheet' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::class, - 'drawing' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing::class, - 'comments' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Comments::class, - 'chart' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\Chart::class, - 'relsvba' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA::class, - 'relsribbonobjects' => \PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon::class, + 'stringtable' => StringTable::class, + 'contenttypes' => ContentTypes::class, + 'docprops' => DocProps::class, + 'rels' => Rels::class, + 'theme' => Theme::class, + 'style' => Style::class, + 'workbook' => Workbook::class, + 'worksheet' => Worksheet::class, + 'drawing' => Drawing::class, + 'comments' => Comments::class, + 'chart' => Chart::class, + 'relsvba' => RelsVBA::class, + 'relsribbonobjects' => RelsRibbon::class, ]; // Initialise writer parts @@ -145,7 +165,7 @@ class Xlsx extends BaseWriter implements IWriter // Set HashTable variables foreach ($hashTablesArray as $tableName) { - $this->$tableName = new \PhpOffice\PhpSpreadsheet\HashTable(); + $this->$tableName = new HashTable(); } } @@ -170,7 +190,7 @@ class Xlsx extends BaseWriter implements IWriter * * @param string $pFilename * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ public function save($pFilename) { @@ -181,16 +201,16 @@ class Xlsx extends BaseWriter implements IWriter // If $pFilename is php://output or php://stdout, make it a temporary file... $originalFilename = $pFilename; if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { - $pFilename = @tempnam(\PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(), 'phpxltmp'); + $pFilename = @tempnam(File::sysGetTempDir(), 'phpxltmp'); if ($pFilename == '') { $pFilename = $originalFilename; } } - $saveDebugLog = \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); - $saveDateReturnType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(); - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType(\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL); + $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); + Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); + $saveDateReturnType = Functions::getReturnDateType(); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Create string lookup table $this->stringTable = []; @@ -217,7 +237,7 @@ class Xlsx extends BaseWriter implements IWriter // Try opening the ZIP file if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) { if ($zip->open($pFilename, ZipArchive::CREATE) !== true) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Could not open ' . $pFilename . ' for writing.'); + throw new WriterException('Could not open ' . $pFilename . ' for writing.'); } } @@ -339,7 +359,7 @@ class Xlsx extends BaseWriter implements IWriter // Add media for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { - if ($this->getDrawingHashTable()->getByIndex($i) instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { + if ($this->getDrawingHashTable()->getByIndex($i) instanceof WorksheetDrawing) { $imageContents = null; $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath(); if (strpos($imagePath, 'zip://') !== false) { @@ -356,7 +376,7 @@ class Xlsx extends BaseWriter implements IWriter } $zip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { + } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) { ob_start(); call_user_func( $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(), @@ -369,30 +389,30 @@ class Xlsx extends BaseWriter implements IWriter } } - \PhpOffice\PhpSpreadsheet\Calculation\Functions::setReturnDateType($saveDateReturnType); - \PhpOffice\PhpSpreadsheet\Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); + Functions::setReturnDateType($saveDateReturnType); + Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); // Close file if ($zip->close() === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not close zip file $pFilename."); + throw new WriterException("Could not close zip file $pFilename."); } // If a temporary file was used, copy it to the correct file stream if ($originalFilename != $pFilename) { if (copy($pFilename, $originalFilename) === false) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + throw new WriterException("Could not copy temporary zip file $pFilename to $originalFilename."); } @unlink($pFilename); } } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('PhpSpreadsheet object unassigned.'); + throw new WriterException('PhpSpreadsheet object unassigned.'); } } /** * Get Spreadsheet object. * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return Spreadsheet */ @@ -401,13 +421,13 @@ class Xlsx extends BaseWriter implements IWriter if ($this->spreadSheet !== null) { return $this->spreadSheet; } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('No Spreadsheet object assigned.'); + throw new WriterException('No Spreadsheet object assigned.'); } /** * Set Spreadsheet object. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet PhpSpreadsheet object + * @param Spreadsheet $spreadsheet PhpSpreadsheet object * * @return Xlsx */ @@ -429,9 +449,9 @@ class Xlsx extends BaseWriter implements IWriter } /** - * Get \PhpOffice\PhpSpreadsheet\Style HashTable. + * Get Style HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getStyleHashTable() { @@ -439,9 +459,9 @@ class Xlsx extends BaseWriter implements IWriter } /** - * Get \PhpOffice\PhpSpreadsheet\Style\Conditional HashTable. + * Get Conditional HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getStylesConditionalHashTable() { @@ -449,9 +469,9 @@ class Xlsx extends BaseWriter implements IWriter } /** - * Get \PhpOffice\PhpSpreadsheet\Style\Fill HashTable. + * Get Fill HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getFillHashTable() { @@ -461,7 +481,7 @@ class Xlsx extends BaseWriter implements IWriter /** * Get \PhpOffice\PhpSpreadsheet\Style\Font HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getFontHashTable() { @@ -469,9 +489,9 @@ class Xlsx extends BaseWriter implements IWriter } /** - * Get \PhpOffice\PhpSpreadsheet\Style\Borders HashTable. + * Get Borders HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getBordersHashTable() { @@ -479,9 +499,9 @@ class Xlsx extends BaseWriter implements IWriter } /** - * Get \PhpOffice\PhpSpreadsheet\Style\NumberFormat HashTable. + * Get NumberFormat HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getNumFmtHashTable() { @@ -491,7 +511,7 @@ class Xlsx extends BaseWriter implements IWriter /** * Get \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing HashTable. * - * @return \PhpOffice\PhpSpreadsheet\HashTable + * @return HashTable */ public function getDrawingHashTable() { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 418688f7..a86b1a88 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -10,6 +10,9 @@ use PhpOffice\PhpSpreadsheet\Chart\Layout; use PhpOffice\PhpSpreadsheet\Chart\Legend; use PhpOffice\PhpSpreadsheet\Chart\PlotArea; use PhpOffice\PhpSpreadsheet\Chart\Title; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -43,7 +46,7 @@ class Chart extends WriterPart * @param \PhpOffice\PhpSpreadsheet\Chart $pChart * @param mixed $calculateCellValues * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -54,9 +57,9 @@ class Chart extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // Ensure that data series values are up-to-date before we save if ($this->calculateCellValues) { @@ -121,12 +124,12 @@ class Chart extends WriterPart /** * Write Chart Title. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param Title $title * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeTitle(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, Title $title = null) + private function writeTitle(XMLWriter $objWriter, Title $title = null) { if (is_null($title)) { return; @@ -166,12 +169,12 @@ class Chart extends WriterPart /** * Write Chart Legend. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param Legend $legend * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeLegend(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, Legend $legend = null) + private function writeLegend(XMLWriter $objWriter, Legend $legend = null) { if (is_null($legend)) { return; @@ -217,7 +220,7 @@ class Chart extends WriterPart /** * Write Chart Plot Area. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet * @param PlotArea $plotArea * @param Title $xAxisLabel @@ -225,9 +228,9 @@ class Chart extends WriterPart * @param Axis $xAxis * @param Axis $yAxis * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writePlotArea(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) + private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, PlotArea $plotArea, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) { if (is_null($plotArea)) { return; @@ -353,12 +356,12 @@ class Chart extends WriterPart /** * Write Data Labels. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Chart\Layout $chartLayout Chart layout * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDataLabels(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, Layout $chartLayout = null) + private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = null) { $objWriter->startElement('c:dLbls'); @@ -403,7 +406,7 @@ class Chart extends WriterPart /** * Write Category Axis. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param PlotArea $plotArea * @param Title $xAxisLabel * @param string $groupType Chart type @@ -413,7 +416,7 @@ class Chart extends WriterPart * @param mixed $xAxis * @param mixed $yAxis * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writeCategoryAxis($objWriter, PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) { @@ -458,7 +461,7 @@ class Chart extends WriterPart $caption = $caption[0]; } $objWriter->startElement('a:t'); - $objWriter->writeRawData(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($caption)); + $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($caption)); $objWriter->endElement(); $objWriter->endElement(); @@ -526,7 +529,7 @@ class Chart extends WriterPart /** * Write Value Axis. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param PlotArea $plotArea * @param Title $yAxisLabel * @param string $groupType Chart type @@ -538,7 +541,7 @@ class Chart extends WriterPart * @param mixed $majorGridlines * @param mixed $minorGridlines * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writeValueAxis($objWriter, PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) { @@ -811,7 +814,7 @@ class Chart extends WriterPart } $objWriter->startElement('a:t'); - $objWriter->writeRawData(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($caption)); + $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($caption)); $objWriter->endElement(); $objWriter->endElement(); @@ -1018,7 +1021,7 @@ class Chart extends WriterPart * * @param PlotArea $plotArea * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string|array */ @@ -1035,7 +1038,7 @@ class Chart extends WriterPart } $chartType = array_unique($chartTypes); if (count($chartTypes) == 0) { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Chart is not yet implemented'); + throw new WriterException('Chart is not yet implemented'); } } @@ -1047,13 +1050,13 @@ class Chart extends WriterPart * * @param DataSeries $plotGroup * @param string $groupType Type of plot for dataseries - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param bool &$catIsMultiLevelSeries Is category a multi-series category * @param bool &$valIsMultiLevelSeries Is value set a multi-series set * @param string &$plotGroupingType Type of grouping for multi-series values * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { @@ -1225,9 +1228,9 @@ class Chart extends WriterPart * Write Plot Series Label. * * @param DataSeriesValues $plotSeriesLabel - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writePlotSeriesLabel($plotSeriesLabel, $objWriter) { @@ -1260,13 +1263,13 @@ class Chart extends WriterPart * Write Plot Series Values. * * @param DataSeriesValues $plotSeriesValues - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $groupType Type of plot for dataseries * @param string $dataType Datatype of series values * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writePlotSeriesValues($plotSeriesValues, \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $groupType, $dataType = 'str') + private function writePlotSeriesValues($plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str') { if (is_null($plotSeriesValues)) { return; @@ -1354,9 +1357,9 @@ class Chart extends WriterPart * Write Bubble Chart Details. * * @param DataSeriesValues $plotSeriesValues - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writeBubbles($plotSeriesValues, $objWriter) { @@ -1400,12 +1403,12 @@ class Chart extends WriterPart /** * Write Layout. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param Layout $layout * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeLayout(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, Layout $layout = null) + private function writeLayout(XMLWriter $objWriter, Layout $layout = null) { $objWriter->startElement('c:layout'); @@ -1470,9 +1473,9 @@ class Chart extends WriterPart /** * Write Alternate Content block. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writeAlternateContent($objWriter) { @@ -1500,9 +1503,9 @@ class Chart extends WriterPart /** * Write Printer Settings. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ private function writePrintSettings($objWriter) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index e630b797..d08f3aec 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -2,6 +2,10 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Comment; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -40,9 +44,9 @@ class Comments extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -87,14 +91,14 @@ class Comments extends WriterPart /** * Write comment to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pCellReference Cell reference - * @param \PhpOffice\PhpSpreadsheet\Comment $pComment Comment + * @param Comment $pComment Comment * @param array $pAuthors Array of authors * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pCellReference, \PhpOffice\PhpSpreadsheet\Comment $pComment, array $pAuthors) + private function writeComment(XMLWriter $objWriter, $pCellReference, Comment $pComment, array $pAuthors) { // comment $objWriter->startElement('comment'); @@ -123,9 +127,9 @@ class Comments extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -186,17 +190,17 @@ class Comments extends WriterPart /** * Write VML comment to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pCellReference Cell reference, eg: 'A1' - * @param \PhpOffice\PhpSpreadsheet\Comment $pComment Comment + * @param Comment $pComment Comment * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeVMLComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pCellReference, \PhpOffice\PhpSpreadsheet\Comment $pComment) + private function writeVMLComment(XMLWriter $objWriter, $pCellReference, Comment $pComment) { // Metadata - list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($pCellReference); - $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($column); + list($column, $row) = Cell::coordinateFromString($pCellReference); + $column = Cell::columnIndexFromString($column); $id = 1024 + $column + $row; $id = substr($id, 0, 4); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index bf01e978..64a14602 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -2,6 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\File; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,21 +35,21 @@ class ContentTypes extends WriterPart /** * Write content types to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ - public function writeContentTypes(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet, $includeCharts = false) + public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -140,7 +146,7 @@ class ContentTypes extends WriterPart if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); $mimeType = $this->getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); - } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { + } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) { $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); $extension = explode('/', $extension); $extension = $extension[1]; @@ -187,30 +193,30 @@ class ContentTypes extends WriterPart * * @param string $pFile Filename * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string Mime Type */ private function getImageMimeType($pFile) { - if (\PhpOffice\PhpSpreadsheet\Shared\File::fileExists($pFile)) { + if (File::fileExists($pFile)) { $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("File $pFile does not exist"); + throw new WriterException("File $pFile does not exist"); } /** * Write Default content type. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefaultContentType(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pPartname, $pContentType) + private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType) { if ($pPartname != '' && $pContentType != '') { // Write content type @@ -219,20 +225,20 @@ class ContentTypes extends WriterPart $objWriter->writeAttribute('ContentType', $pContentType); $objWriter->endElement(); } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid parameters passed.'); + throw new WriterException('Invalid parameters passed.'); } } /** * Write Override content type. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeOverrideContentType(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pPartname, $pContentType) + private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType) { if ($pPartname != '' && $pContentType != '') { // Write content type @@ -241,7 +247,7 @@ class ContentTypes extends WriterPart $objWriter->writeAttribute('ContentType', $pContentType); $objWriter->endElement(); } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid parameters passed.'); + throw new WriterException('Invalid parameters passed.'); } } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php index 7eb9a06e..3de9b5a8 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +32,20 @@ class DocProps extends WriterPart /** * Write docProps/app.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeDocPropsApp(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeDocPropsApp(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -128,20 +131,20 @@ class DocProps extends WriterPart /** * Write docProps/core.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeDocPropsCore(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeDocPropsCore(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -197,13 +200,13 @@ class DocProps extends WriterPart /** * Write docProps/custom.xml to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeDocPropsCustom(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeDocPropsCustom(Spreadsheet $spreadsheet) { $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); if (empty($customPropertyList)) { @@ -213,9 +216,9 @@ class DocProps extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index afd27f30..41092f55 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -2,6 +2,13 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing; +use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -33,7 +40,7 @@ class Drawing extends WriterPart * @param int &$chartRef Chart ID * @param bool $includeCharts Flag indicating if we should include drawing details for charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -42,9 +49,9 @@ class Drawing extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -84,29 +91,29 @@ class Drawing extends WriterPart /** * Write drawings to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Chart $pChart * @param int $pRelationId * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - public function writeChart(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart $pChart, $pRelationId = -1) + public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart $pChart, $pRelationId = -1) { $tl = $pChart->getTopLeftPosition(); - $tl['colRow'] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($tl['cell']); + $tl['colRow'] = Cell::coordinateFromString($tl['cell']); $br = $pChart->getBottomRightPosition(); - $br['colRow'] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($br['cell']); + $br['colRow'] = Cell::coordinateFromString($br['cell']); $objWriter->startElement('xdr:twoCellAnchor'); $objWriter->startElement('xdr:from'); - $objWriter->writeElement('xdr:col', \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($tl['colRow'][0]) - 1); + $objWriter->writeElement('xdr:col', Cell::columnIndexFromString($tl['colRow'][0]) - 1); $objWriter->writeElement('xdr:colOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($tl['xOffset'])); $objWriter->writeElement('xdr:row', $tl['colRow'][1] - 1); $objWriter->writeElement('xdr:rowOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($tl['yOffset'])); $objWriter->endElement(); $objWriter->startElement('xdr:to'); - $objWriter->writeElement('xdr:col', \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($br['colRow'][0]) - 1); + $objWriter->writeElement('xdr:col', Cell::columnIndexFromString($br['colRow'][0]) - 1); $objWriter->writeElement('xdr:colOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($br['xOffset'])); $objWriter->writeElement('xdr:row', $br['colRow'][1] - 1); $objWriter->writeElement('xdr:rowOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($br['yOffset'])); @@ -157,20 +164,20 @@ class Drawing extends WriterPart /** * Write drawings to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing $pDrawing + * @param XMLWriter $objWriter XML Writer + * @param BaseDrawing $pDrawing * @param int $pRelationId * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - public function writeDrawing(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing $pDrawing, $pRelationId = -1) + public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRelationId = -1) { if ($pRelationId >= 0) { // xdr:oneCellAnchor $objWriter->startElement('xdr:oneCellAnchor'); // Image location - $aCoordinates = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($pDrawing->getCoordinates()); - $aCoordinates[0] = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($aCoordinates[0]); + $aCoordinates = Cell::coordinateFromString($pDrawing->getCoordinates()); + $aCoordinates[0] = Cell::columnIndexFromString($aCoordinates[0]); // xdr:from $objWriter->startElement('xdr:from'); @@ -280,7 +287,7 @@ class Drawing extends WriterPart $objWriter->endElement(); } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid parameters passed.'); + throw new WriterException('Invalid parameters passed.'); } } @@ -289,7 +296,7 @@ class Drawing extends WriterPart * * @param \PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -298,9 +305,9 @@ class Drawing extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -436,13 +443,13 @@ class Drawing extends WriterPart /** * Write VML comment to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pReference Reference - * @param \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing $pImage Image + * @param HeaderFooterDrawing $pImage Image * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeVMLHeaderFooterImage(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pReference, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing $pImage) + private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $pReference, HeaderFooterDrawing $pImage) { // Calculate object id preg_match('{(\d+)}', md5($pReference), $m); @@ -479,13 +486,13 @@ class Drawing extends WriterPart /** * Get an array of all drawings. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return \PhpOffice\PhpSpreadsheet\Worksheet\Drawing[] All drawings in PhpSpreadsheet */ - public function allDrawings(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allDrawings(Spreadsheet $spreadsheet) { // Get an array of all drawings $aDrawings = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 2d4ceef5..eec3cefa 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -2,6 +2,11 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +34,20 @@ class Rels extends WriterPart /** * Write relationships to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ - public function writeRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeRelationships(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -104,20 +109,20 @@ class Rels extends WriterPart /** * Write workbook relationships to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ - public function writeWorkbookRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeWorkbookRelationships(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -189,7 +194,7 @@ class Rels extends WriterPart * @param int $pWorksheetId * @param bool $includeCharts Flag indicating if we should write charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -198,9 +203,9 @@ class Rels extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -284,7 +289,7 @@ class Rels extends WriterPart * @param int &$chartRef Chart ID * @param bool $includeCharts Flag indicating if we should write charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -293,9 +298,9 @@ class Rels extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -310,7 +315,7 @@ class Rels extends WriterPart $iterator = $pWorksheet->getDrawingCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing - || $iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing) { + || $iterator->current() instanceof MemoryDrawing) { // Write relationship for image drawing $this->writeRelationship( $objWriter, @@ -349,7 +354,7 @@ class Rels extends WriterPart * * @param \PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -358,9 +363,9 @@ class Rels extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -389,15 +394,15 @@ class Rels extends WriterPart /** * Write Override content type. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param int $pId Relationship ID. rId will be prepended! * @param string $pType Relationship type * @param string $pTarget Relationship target * @param string $pTargetMode Relationship target mode * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeRelationship(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = '') + private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = '') { if ($pType != '' && $pTarget != '') { // Write relationship @@ -412,7 +417,7 @@ class Rels extends WriterPart $objWriter->endElement(); } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid parameters passed.'); + throw new WriterException('Invalid parameters passed.'); } } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php index da414a2f..e827d182 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +32,20 @@ class RelsRibbon extends WriterPart /** * Write relationships for additional objects of custom UI (ribbon). * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeRibbonRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeRibbonRelationships(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php index dbf4dfed..8bd7de13 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php @@ -2,6 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +32,20 @@ class RelsVBA extends WriterPart /** * Write relationships for a signed VBA Project. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeVBARelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeVBARelationships(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 4232445a..8b141e1b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -2,6 +2,12 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,10 +35,10 @@ class StringTable extends WriterPart /** * Create worksheet stringtable. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param Worksheet $pSheet Worksheet * @param string[] $pExistingTable Existing table to eventually merge with * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string[] String table for worksheet */ @@ -60,10 +66,10 @@ class StringTable extends WriterPart ($cellValue !== null) && $cellValue !== '' && !isset($aFlippedStringTable[$cellValue]) && - ($cell->getDataType() == \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING || $cell->getDataType() == \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING2 || $cell->getDataType() == \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL)) { + ($cell->getDataType() == Cell\DataType::TYPE_STRING || $cell->getDataType() == Cell\DataType::TYPE_STRING2 || $cell->getDataType() == Cell\DataType::TYPE_NULL)) { $aStringTable[] = $cellValue; $aFlippedStringTable[$cellValue] = true; - } elseif ($cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText && + } elseif ($cellValue instanceof RichText && ($cellValue !== null) && !isset($aFlippedStringTable[$cellValue->getHashCode()])) { $aStringTable[] = $cellValue; @@ -73,7 +79,7 @@ class StringTable extends WriterPart return $aStringTable; } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Invalid \PhpOffice\PhpSpreadsheet\Worksheet object passed."); + throw new WriterException('Invalid Worksheet object passed.'); } /** @@ -81,7 +87,7 @@ class StringTable extends WriterPart * * @param string[] $pStringTable * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -90,9 +96,9 @@ class StringTable extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -107,15 +113,15 @@ class StringTable extends WriterPart foreach ($pStringTable as $textElement) { $objWriter->startElement('si'); - if (!$textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { - $textToWrite = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($textElement); + if (!$textElement instanceof RichText) { + $textToWrite = StringHelper::controlCharacterPHP2OOXML($textElement); $objWriter->startElement('t'); if ($textToWrite !== trim($textToWrite)) { $objWriter->writeAttribute('xml:space', 'preserve'); } $objWriter->writeRawData($textToWrite); $objWriter->endElement(); - } elseif ($textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { + } elseif ($textElement instanceof RichText) { $this->writeRichText($objWriter, $textElement); } @@ -130,13 +136,13 @@ class StringTable extends WriterPart /** * Write Rich Text. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\RichText $pRichText Rich text + * @param XMLWriter $objWriter XML Writer + * @param RichText $pRichText Rich text * @param string $prefix Optional Namespace prefix * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - public function writeRichText(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\RichText $pRichText, $prefix = null) + public function writeRichText(XMLWriter $objWriter, RichText $pRichText, $prefix = null) { if ($prefix !== null) { $prefix .= ':'; @@ -149,7 +155,7 @@ class StringTable extends WriterPart $objWriter->startElement($prefix . 'r'); // rPr - if ($element instanceof \PhpOffice\PhpSpreadsheet\RichText\Run) { + if ($element instanceof RichText\Run) { // rPr $objWriter->startElement($prefix . 'rPr'); @@ -205,7 +211,7 @@ class StringTable extends WriterPart // t $objWriter->startElement($prefix . 't'); $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($element->getText())); + $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($element->getText())); $objWriter->endElement(); $objWriter->endElement(); @@ -215,17 +221,17 @@ class StringTable extends WriterPart /** * Write Rich Text. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param string|\PhpOffice\PhpSpreadsheet\RichText $pRichText text string or Rich text + * @param XMLWriter $objWriter XML Writer + * @param string|RichText $pRichText text string or Rich text * @param string $prefix Optional Namespace prefix * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - public function writeRichTextForCharts(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pRichText = null, $prefix = null) + public function writeRichTextForCharts(XMLWriter $objWriter, $pRichText = null, $prefix = null) { - if (!$pRichText instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if (!$pRichText instanceof RichText) { $textRun = $pRichText; - $pRichText = new \PhpOffice\PhpSpreadsheet\RichText(); + $pRichText = new RichText(); $pRichText->createTextRun($textRun); } @@ -269,7 +275,7 @@ class StringTable extends WriterPart // t $objWriter->startElement($prefix . 't'); - $objWriter->writeRawData(\PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($element->getText())); + $objWriter->writeRawData(StringHelper::controlCharacterPHP2OOXML($element->getText())); $objWriter->endElement(); $objWriter->endElement(); @@ -290,9 +296,9 @@ class StringTable extends WriterPart // Loop through stringtable and add flipped items to $returnValue foreach ($stringTable as $key => $value) { - if (!$value instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if (!$value instanceof RichText) { $returnValue[$value] = $key; - } elseif ($value instanceof \PhpOffice\PhpSpreadsheet\RichText) { + } elseif ($value instanceof RichText) { $returnValue[$value->getHashCode()] = $key; } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index 96457aa1..da49970d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -2,6 +2,16 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Borders; +use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PhpOffice\PhpSpreadsheet\Style\Protection; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +39,20 @@ class Style extends WriterPart /** * Write styles to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeStyles(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -161,16 +171,16 @@ class Style extends WriterPart /** * Write Fill. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\Fill $pFill Fill style + * @param XMLWriter $objWriter XML Writer + * @param Fill $pFill Fill style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) + private function writeFill(XMLWriter $objWriter, Fill $pFill) { // Check if this is a pattern type or gradient type - if ($pFill->getFillType() === \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR || - $pFill->getFillType() === \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH) { + if ($pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR || + $pFill->getFillType() === Fill::FILL_GRADIENT_PATH) { // Gradient fill $this->writeGradientFill($objWriter, $pFill); } elseif ($pFill->getFillType() !== null) { @@ -182,12 +192,12 @@ class Style extends WriterPart /** * Write Gradient Fill. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\Fill $pFill Fill style + * @param XMLWriter $objWriter XML Writer + * @param Fill $pFill Fill style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeGradientFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) + private function writeGradientFill(XMLWriter $objWriter, Fill $pFill) { // fill $objWriter->startElement('fill'); @@ -227,12 +237,12 @@ class Style extends WriterPart /** * Write Pattern Fill. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\Fill $pFill Fill style + * @param XMLWriter $objWriter XML Writer + * @param Fill $pFill Fill style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writePatternFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) + private function writePatternFill(XMLWriter $objWriter, Fill $pFill) { // fill $objWriter->startElement('fill'); @@ -241,7 +251,7 @@ class Style extends WriterPart $objWriter->startElement('patternFill'); $objWriter->writeAttribute('patternType', $pFill->getFillType()); - if ($pFill->getFillType() !== \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE) { + if ($pFill->getFillType() !== Fill::FILL_NONE) { // fgColor if ($pFill->getStartColor()->getARGB()) { $objWriter->startElement('fgColor'); @@ -249,7 +259,7 @@ class Style extends WriterPart $objWriter->endElement(); } } - if ($pFill->getFillType() !== \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE) { + if ($pFill->getFillType() !== Fill::FILL_NONE) { // bgColor if ($pFill->getEndColor()->getARGB()) { $objWriter->startElement('bgColor'); @@ -266,12 +276,12 @@ class Style extends WriterPart /** * Write Font. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\Font $pFont Font style + * @param XMLWriter $objWriter XML Writer + * @param Font $pFont Font style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeFont(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Font $pFont) + private function writeFont(XMLWriter $objWriter, Font $pFont) { // font $objWriter->startElement('font'); @@ -323,7 +333,7 @@ class Style extends WriterPart // Size if ($pFont->getSize() !== null) { $objWriter->startElement('sz'); - $objWriter->writeAttribute('val', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pFont->getSize())); + $objWriter->writeAttribute('val', StringHelper::formatNumber($pFont->getSize())); $objWriter->endElement(); } @@ -347,26 +357,26 @@ class Style extends WriterPart /** * Write Border. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\Borders $pBorders Borders style + * @param XMLWriter $objWriter XML Writer + * @param Borders $pBorders Borders style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBorder(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Borders $pBorders) + private function writeBorder(XMLWriter $objWriter, Borders $pBorders) { // Write border $objWriter->startElement('border'); // Diagonal? switch ($pBorders->getDiagonalDirection()) { - case \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP: + case Borders::DIAGONAL_UP: $objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalDown', 'false'); break; - case \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN: + case Borders::DIAGONAL_DOWN: $objWriter->writeAttribute('diagonalUp', 'false'); $objWriter->writeAttribute('diagonalDown', 'true'); break; - case \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH: + case Borders::DIAGONAL_BOTH: $objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalDown', 'true'); break; @@ -384,13 +394,13 @@ class Style extends WriterPart /** * Write Cell Style Xf. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Style $pStyle Style - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet Workbook + * @param Spreadsheet $spreadsheet Workbook * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeCellStyleXf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle, Spreadsheet $spreadsheet) { // xf $objWriter->startElement('xf'); @@ -415,7 +425,7 @@ class Style extends WriterPart $objWriter->writeAttribute('applyFill', ($spreadsheet->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0'); $objWriter->writeAttribute('applyBorder', ($spreadsheet->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0'); $objWriter->writeAttribute('applyAlignment', ($spreadsheet->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0'); - if ($pStyle->getProtection()->getLocked() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT) { + if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) { $objWriter->writeAttribute('applyProtection', 'true'); } @@ -444,13 +454,13 @@ class Style extends WriterPart $objWriter->endElement(); // protection - if ($pStyle->getProtection()->getLocked() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT) { + if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) { $objWriter->startElement('protection'); - if ($pStyle->getProtection()->getLocked() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT) { - $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED ? 'true' : 'false')); + if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT) { + $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } - if ($pStyle->getProtection()->getHidden() != \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT) { - $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED ? 'true' : 'false')); + if ($pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) { + $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } $objWriter->endElement(); } @@ -461,12 +471,12 @@ class Style extends WriterPart /** * Write Cell Style Dxf. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param \PhpOffice\PhpSpreadsheet\Style $pStyle Style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeCellStyleDxf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle) + private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle) { // dxf $objWriter->startElement('dxf'); @@ -505,16 +515,16 @@ class Style extends WriterPart // protection if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) { - if ($pStyle->getProtection()->getLocked() !== \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT || - $pStyle->getProtection()->getHidden() !== \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT) { + if ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT || + $pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT) { $objWriter->startElement('protection'); if (($pStyle->getProtection()->getLocked() !== null) && - ($pStyle->getProtection()->getLocked() !== \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT)) { - $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED ? 'true' : 'false')); + ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)) { + $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } if (($pStyle->getProtection()->getHidden() !== null) && - ($pStyle->getProtection()->getHidden() !== \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT)) { - $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED ? 'true' : 'false')); + ($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)) { + $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } $objWriter->endElement(); } @@ -526,16 +536,16 @@ class Style extends WriterPart /** * Write BorderPr. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pName Element name - * @param \PhpOffice\PhpSpreadsheet\Style\Border $pBorder Border style + * @param Border $pBorder Border style * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBorderPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pName, \PhpOffice\PhpSpreadsheet\Style\Border $pBorder) + private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder) { // Write BorderPr - if ($pBorder->getBorderStyle() != \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE) { + if ($pBorder->getBorderStyle() != Border::BORDER_NONE) { $objWriter->startElement($pName); $objWriter->writeAttribute('style', $pBorder->getBorderStyle()); @@ -551,13 +561,13 @@ class Style extends WriterPart /** * Write NumberFormat. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Style\NumberFormat $pNumberFormat Number Format + * @param XMLWriter $objWriter XML Writer + * @param NumberFormat $pNumberFormat Number Format * @param int $pId Number Format identifier * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeNumFmt(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\NumberFormat $pNumberFormat, $pId = 0) + private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, $pId = 0) { // Translate formatcode $formatCode = $pNumberFormat->getFormatCode(); @@ -574,13 +584,13 @@ class Style extends WriterPart /** * Get an array of all styles. * - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return \PhpOffice\PhpSpreadsheet\Style[] All styles in PhpSpreadsheet */ - public function allStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allStyles(Spreadsheet $spreadsheet) { return $spreadsheet->getCellXfCollection(); } @@ -588,13 +598,13 @@ class Style extends WriterPart /** * Get an array of all conditional styles. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Style\Conditional[] All conditional styles in PhpSpreadsheet + * @return Conditional[] All conditional styles in PhpSpreadsheet */ - public function allConditionalStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allConditionalStyles(Spreadsheet $spreadsheet) { // Get an array of all styles $aStyles = []; @@ -614,24 +624,24 @@ class Style extends WriterPart /** * Get an array of all fills. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Style\Fill[] All fills in PhpSpreadsheet + * @return Fill[] All fills in PhpSpreadsheet */ - public function allFills(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allFills(Spreadsheet $spreadsheet) { // Get an array of unique fills $aFills = []; // Two first fills are predefined - $fill0 = new \PhpOffice\PhpSpreadsheet\Style\Fill(); - $fill0->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE); + $fill0 = new Fill(); + $fill0->setFillType(Fill::FILL_NONE); $aFills[] = $fill0; - $fill1 = new \PhpOffice\PhpSpreadsheet\Style\Fill(); - $fill1->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125); + $fill1 = new Fill(); + $fill1->setFillType(Fill::FILL_PATTERN_GRAY125); $aFills[] = $fill1; // The remaining fills $aStyles = $this->allStyles($spreadsheet); @@ -648,13 +658,13 @@ class Style extends WriterPart /** * Get an array of all fonts. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Style\Font[] All fonts in PhpSpreadsheet + * @return Font[] All fonts in PhpSpreadsheet */ - public function allFonts(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allFonts(Spreadsheet $spreadsheet) { // Get an array of unique fonts $aFonts = []; @@ -673,13 +683,13 @@ class Style extends WriterPart /** * Get an array of all borders. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Style\Borders[] All borders in PhpSpreadsheet + * @return Borders[] All borders in PhpSpreadsheet */ - public function allBorders(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allBorders(Spreadsheet $spreadsheet) { // Get an array of unique borders $aBorders = []; @@ -698,13 +708,13 @@ class Style extends WriterPart /** * Get an array of all number formats. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Style\NumberFormat[] All number formats in PhpSpreadsheet + * @return NumberFormat[] All number formats in PhpSpreadsheet */ - public function allNumberFormats(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function allNumberFormats(Spreadsheet $spreadsheet) { // Get an array of unique number formats $aNumFmts = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index 4dde8153..da3f206f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; -/** +/* * PhpSpreadsheet. * * Copyright (c) 2006 - 2016 PhpSpreadsheet @@ -26,6 +26,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; * @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; /** * @category PhpSpreadsheet @@ -131,20 +133,20 @@ class Theme extends WriterPart /** * Write theme to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * * @return string XML Output */ - public function writeTheme(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + public function writeTheme(Spreadsheet $spreadsheet) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -815,7 +817,7 @@ class Theme extends WriterPart /** * Write fonts to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter + * @param XMLWriter $objWriter * @param string $latinFont * @param array of string $fontSet * @@ -851,7 +853,7 @@ class Theme extends WriterPart /** * Write colour scheme to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter + * @param XMLWriter $objWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index 16f9f73b..d21db57d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -2,6 +2,14 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\NamedRange; +use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Worksheet; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; + /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,20 +37,20 @@ class Workbook extends WriterPart /** * Write workbook to XML format. * - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param Spreadsheet $spreadsheet * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ - public function writeWorkbook(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet, $recalcRequired = false) + public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false) { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -86,11 +94,11 @@ class Workbook extends WriterPart /** * Write file version. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeFileVersion(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter) + private function writeFileVersion(XMLWriter $objWriter) { $objWriter->startElement('fileVersion'); $objWriter->writeAttribute('appName', 'xl'); @@ -103,15 +111,15 @@ class Workbook extends WriterPart /** * Write WorkbookPr. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeWorkbookPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter) + private function writeWorkbookPr(XMLWriter $objWriter) { $objWriter->startElement('workbookPr'); - if (\PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar() == \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904) { + if (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) { $objWriter->writeAttribute('date1904', '1'); } @@ -123,12 +131,12 @@ class Workbook extends WriterPart /** * Write BookViews. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param XMLWriter $objWriter XML Writer + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeBookViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeBookViews(XMLWriter $objWriter, Spreadsheet $spreadsheet) { // bookViews $objWriter->startElement('bookViews'); @@ -154,12 +162,12 @@ class Workbook extends WriterPart /** * Write WorkbookProtection. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param XMLWriter $objWriter XML Writer + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeWorkbookProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spreadsheet) { if ($spreadsheet->getSecurity()->isSecurityEnabled()) { $objWriter->startElement('workbookProtection'); @@ -182,12 +190,12 @@ class Workbook extends WriterPart /** * Write calcPr. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeCalcPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $recalcRequired = true) + private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true) { $objWriter->startElement('calcPr'); @@ -206,12 +214,12 @@ class Workbook extends WriterPart /** * Write sheets. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param XMLWriter $objWriter XML Writer + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheets(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet) { // Write sheets $objWriter->startElement('sheets'); @@ -233,15 +241,15 @@ class Workbook extends WriterPart /** * Write sheet. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer + * @param XMLWriter $objWriter XML Writer * @param string $pSheetname Sheet name * @param int $pSheetId Sheet id * @param int $pRelId Relationship ID * @param string $sheetState Sheet state (visible, hidden, veryHidden) * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheet(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') + private function writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') { if ($pSheetname != '') { // Write sheet @@ -254,19 +262,19 @@ class Workbook extends WriterPart $objWriter->writeAttribute('r:id', 'rId' . $pRelId); $objWriter->endElement(); } else { - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid parameters passed.'); + throw new WriterException('Invalid parameters passed.'); } } /** * Write Defined Names. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet + * @param XMLWriter $objWriter XML Writer + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefinedNames(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeDefinedNames(XMLWriter $objWriter, Spreadsheet $spreadsheet) { // Write defined names $objWriter->startElement('definedNames'); @@ -296,12 +304,12 @@ class Workbook extends WriterPart /** * Write named ranges. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet + * @param XMLWriter $objWriter XML Writer + * @param Spreadsheet $spreadsheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeNamedRanges(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) + private function writeNamedRanges(XMLWriter $objWriter, Spreadsheet $spreadsheet) { // Loop named ranges $namedRanges = $spreadsheet->getNamedRanges(); @@ -313,12 +321,12 @@ class Workbook extends WriterPart /** * Write Defined Name for named range. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\NamedRange $pNamedRange + * @param XMLWriter $objWriter XML Writer + * @param NamedRange $pNamedRange * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefinedNameForNamedRange(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\NamedRange $pNamedRange) + private function writeDefinedNameForNamedRange(XMLWriter $objWriter, NamedRange $pNamedRange) { // definedName for named range $objWriter->startElement('definedName'); @@ -328,14 +336,14 @@ class Workbook extends WriterPart } // Create absolute coordinate and write as raw text - $range = \PhpOffice\PhpSpreadsheet\Cell::splitRange($pNamedRange->getRange()); + $range = Cell::splitRange($pNamedRange->getRange()); for ($i = 0; $i < count($range); ++$i) { - $range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . \PhpOffice\PhpSpreadsheet\Cell::absoluteReference($range[$i][0]); + $range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . Cell::absoluteReference($range[$i][0]); if (isset($range[$i][1])) { - $range[$i][1] = \PhpOffice\PhpSpreadsheet\Cell::absoluteReference($range[$i][1]); + $range[$i][1] = Cell::absoluteReference($range[$i][1]); } } - $range = \PhpOffice\PhpSpreadsheet\Cell::buildRange($range); + $range = Cell::buildRange($range); $objWriter->writeRawData($range); @@ -345,13 +353,13 @@ class Workbook extends WriterPart /** * Write Defined Name for autoFilter. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param XMLWriter $objWriter XML Writer + * @param Worksheet $pSheet * @param int $pSheetId * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefinedNameForAutofilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForAutofilter(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) { // definedName for autoFilter $autoFilterRange = $pSheet->getAutoFilter()->getRange(); @@ -362,15 +370,15 @@ class Workbook extends WriterPart $objWriter->writeAttribute('hidden', '1'); // Create absolute coordinate and write as raw text - $range = \PhpOffice\PhpSpreadsheet\Cell::splitRange($autoFilterRange); + $range = Cell::splitRange($autoFilterRange); $range = $range[0]; // Strip any worksheet ref so we can make the cell ref absolute if (strpos($range[0], '!') !== false) { list($ws, $range[0]) = explode('!', $range[0]); } - $range[0] = \PhpOffice\PhpSpreadsheet\Cell::absoluteCoordinate($range[0]); - $range[1] = \PhpOffice\PhpSpreadsheet\Cell::absoluteCoordinate($range[1]); + $range[0] = Cell::absoluteCoordinate($range[0]); + $range[1] = Cell::absoluteCoordinate($range[1]); $range = implode(':', $range); $objWriter->writeRawData('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . $range); @@ -382,13 +390,13 @@ class Workbook extends WriterPart /** * Write Defined Name for PrintTitles. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param XMLWriter $objWriter XML Writer + * @param Worksheet $pSheet * @param int $pSheetId * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefinedNameForPrintTitles(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForPrintTitles(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) { // definedName for PrintTitles if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) { @@ -426,13 +434,13 @@ class Workbook extends WriterPart /** * Write Defined Name for PrintTitles. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param XMLWriter $objWriter XML Writer + * @param Worksheet $pSheet * @param int $pSheetId * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDefinedNameForPrintArea(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) + private function writeDefinedNameForPrintArea(XMLWriter $objWriter, Worksheet $pSheet, $pSheetId = 0) { // definedName for PrintArea if ($pSheet->getPageSetup()->isPrintAreaSet()) { @@ -444,12 +452,12 @@ class Workbook extends WriterPart $settingString = ''; // Print area - $printArea = \PhpOffice\PhpSpreadsheet\Cell::splitRange($pSheet->getPageSetup()->getPrintArea()); + $printArea = Cell::splitRange($pSheet->getPageSetup()->getPrintArea()); $chunks = []; foreach ($printArea as $printAreaRect) { - $printAreaRect[0] = \PhpOffice\PhpSpreadsheet\Cell::absoluteReference($printAreaRect[0]); - $printAreaRect[1] = \PhpOffice\PhpSpreadsheet\Cell::absoluteReference($printAreaRect[1]); + $printAreaRect[0] = Cell::absoluteReference($printAreaRect[0]); + $printAreaRect[1] = Cell::absoluteReference($printAreaRect[1]); $chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index e8d3b715..f5bf2bf7 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; -/** +/* * PhpSpreadsheet. * * Copyright (c) 2006 - 2015 PhpSpreadsheet @@ -26,6 +26,16 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; * @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ +use PhpOffice\PhpSpreadsheet\Cell; +use PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; +use PhpOffice\PhpSpreadsheet\Style\Conditional; +use PhpOffice\PhpSpreadsheet\Worksheet as PhpspreadsheetWorksheet; +use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; +use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; +use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; +use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException; /** * @category PhpSpreadsheet @@ -37,11 +47,11 @@ class Worksheet extends WriterPart /** * Write worksheet to XML format. * - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet + * @param PhpspreadsheetWorksheet $pSheet * @param string[] $pStringTable * @param bool $includeCharts Flag indicating if we should write charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException * * @return string XML Output */ @@ -51,9 +61,9 @@ class Worksheet extends WriterPart // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header @@ -133,18 +143,18 @@ class Worksheet extends WriterPart // Return return $objWriter->getData(); } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid \\PhpOffice\\PhpSpreadsheet\\Worksheet object passed.'); + throw new WriterException('Invalid \\PhpOffice\\PhpSpreadsheet\\Worksheet object passed.'); } /** * Write SheetPr. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheetPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeSheetPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // sheetPr $objWriter->startElement('sheetPr'); @@ -187,12 +197,12 @@ class Worksheet extends WriterPart /** * Write Dimension. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDimension(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeDimension(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // dimension $objWriter->startElement('dimension'); @@ -203,12 +213,12 @@ class Worksheet extends WriterPart /** * Write SheetViews. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheetViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // sheetViews $objWriter->startElement('sheetViews'); @@ -233,7 +243,7 @@ class Worksheet extends WriterPart } // View Layout Type - if ($pSheet->getSheetView()->getView() !== \PhpOffice\PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_NORMAL) { + if ($pSheet->getSheetView()->getView() !== SheetView::SHEETVIEW_NORMAL) { $objWriter->writeAttribute('view', $pSheet->getSheetView()->getView()); } @@ -266,8 +276,8 @@ class Worksheet extends WriterPart // Calculate freeze coordinates $xSplit = $ySplit = 0; - list($xSplit, $ySplit) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($topLeftCell); - $xSplit = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($xSplit); + list($xSplit, $ySplit) = Cell::coordinateFromString($topLeftCell); + $xSplit = Cell::columnIndexFromString($xSplit); // pane $pane = 'topRight'; @@ -316,12 +326,12 @@ class Worksheet extends WriterPart /** * Write SheetFormatPr. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheetFormatPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeSheetFormatPr(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // sheetFormatPr $objWriter->startElement('sheetFormatPr'); @@ -329,7 +339,7 @@ class Worksheet extends WriterPart // Default row height if ($pSheet->getDefaultRowDimension()->getRowHeight() >= 0) { $objWriter->writeAttribute('customHeight', 'true'); - $objWriter->writeAttribute('defaultRowHeight', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getDefaultRowDimension()->getRowHeight())); + $objWriter->writeAttribute('defaultRowHeight', StringHelper::formatNumber($pSheet->getDefaultRowDimension()->getRowHeight())); } else { $objWriter->writeAttribute('defaultRowHeight', '14.4'); } @@ -342,7 +352,7 @@ class Worksheet extends WriterPart // Default column width if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) { - $objWriter->writeAttribute('defaultColWidth', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getDefaultColumnDimension()->getWidth())); + $objWriter->writeAttribute('defaultColWidth', StringHelper::formatNumber($pSheet->getDefaultColumnDimension()->getWidth())); } // Outline level - row @@ -369,12 +379,12 @@ class Worksheet extends WriterPart /** * Write Cols. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeCols(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeCols(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // cols if (count($pSheet->getColumnDimensions()) > 0) { @@ -386,15 +396,15 @@ class Worksheet extends WriterPart foreach ($pSheet->getColumnDimensions() as $colDimension) { // col $objWriter->startElement('col'); - $objWriter->writeAttribute('min', \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colDimension->getColumnIndex())); - $objWriter->writeAttribute('max', \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($colDimension->getColumnIndex())); + $objWriter->writeAttribute('min', Cell::columnIndexFromString($colDimension->getColumnIndex())); + $objWriter->writeAttribute('max', Cell::columnIndexFromString($colDimension->getColumnIndex())); if ($colDimension->getWidth() < 0) { // No width set, apply default of 10 $objWriter->writeAttribute('width', '9.10'); } else { // Width set - $objWriter->writeAttribute('width', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($colDimension->getWidth())); + $objWriter->writeAttribute('width', StringHelper::formatNumber($colDimension->getWidth())); } // Column visibility @@ -435,12 +445,12 @@ class Worksheet extends WriterPart /** * Write SheetProtection. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheetProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeSheetProtection(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // sheetProtection $objWriter->startElement('sheetProtection'); @@ -471,12 +481,12 @@ class Worksheet extends WriterPart /** * Write ConditionalFormatting. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeConditionalFormatting(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeConditionalFormatting(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // Conditional id $id = 1; @@ -488,7 +498,7 @@ class Worksheet extends WriterPart // if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()) == '') { // continue; // } - if ($conditional->getConditionType() != \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_NONE) { + if ($conditional->getConditionType() != Conditional::CONDITION_NONE) { // conditionalFormatting $objWriter->startElement('conditionalFormatting'); $objWriter->writeAttribute('sqref', $cellCoordinate); @@ -499,35 +509,35 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode())); $objWriter->writeAttribute('priority', $id++); - if (($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT) - && $conditional->getOperatorType() != \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_NONE) { + if (($conditional->getConditionType() == Conditional::CONDITION_CELLIS || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT) + && $conditional->getOperatorType() != Conditional::OPERATOR_NONE) { $objWriter->writeAttribute('operator', $conditional->getOperatorType()); } - if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT + if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT && !is_null($conditional->getText())) { $objWriter->writeAttribute('text', $conditional->getText()); } - if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_CONTAINSTEXT + if ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + && $conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))'); - } elseif ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_BEGINSWITH + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + && $conditional->getOperatorType() == Conditional::OPERATOR_BEGINSWITH && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } elseif ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_ENDSWITH + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + && $conditional->getOperatorType() == Conditional::OPERATOR_ENDSWITH && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); - } elseif ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT - && $conditional->getOperatorType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_NOTCONTAINS + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + && $conditional->getOperatorType() == Conditional::OPERATOR_NOTCONTAINS && !is_null($conditional->getText())) { $objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))'); - } elseif ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS - || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT - || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION) { + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CELLIS + || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT + || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { foreach ($conditional->getConditions() as $formula) { // Formula $objWriter->writeElement('formula', $formula); @@ -545,12 +555,12 @@ class Worksheet extends WriterPart /** * Write DataValidations. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDataValidations(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeDataValidations(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // Datavalidation collection $dataValidationCollection = $pSheet->getDataValidationCollection(); @@ -612,12 +622,12 @@ class Worksheet extends WriterPart /** * Write Hyperlinks. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeHyperlinks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeHyperlinks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // Hyperlink collection $hyperlinkCollection = $pSheet->getHyperlinkCollection(); @@ -654,12 +664,12 @@ class Worksheet extends WriterPart /** * Write ProtectedRanges. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeProtectedRanges(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeProtectedRanges(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { if (count($pSheet->getProtectedCells()) > 0) { // protectedRanges @@ -684,12 +694,12 @@ class Worksheet extends WriterPart /** * Write MergeCells. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeMergeCells(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeMergeCells(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { if (count($pSheet->getMergeCells()) > 0) { // mergeCells @@ -710,12 +720,12 @@ class Worksheet extends WriterPart /** * Write PrintOptions. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writePrintOptions(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writePrintOptions(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // printOptions $objWriter->startElement('printOptions'); @@ -737,33 +747,33 @@ class Worksheet extends WriterPart /** * Write PageMargins. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writePageMargins(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writePageMargins(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // pageMargins $objWriter->startElement('pageMargins'); - $objWriter->writeAttribute('left', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getLeft())); - $objWriter->writeAttribute('right', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getRight())); - $objWriter->writeAttribute('top', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getTop())); - $objWriter->writeAttribute('bottom', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getBottom())); - $objWriter->writeAttribute('header', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getHeader())); - $objWriter->writeAttribute('footer', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($pSheet->getPageMargins()->getFooter())); + $objWriter->writeAttribute('left', StringHelper::formatNumber($pSheet->getPageMargins()->getLeft())); + $objWriter->writeAttribute('right', StringHelper::formatNumber($pSheet->getPageMargins()->getRight())); + $objWriter->writeAttribute('top', StringHelper::formatNumber($pSheet->getPageMargins()->getTop())); + $objWriter->writeAttribute('bottom', StringHelper::formatNumber($pSheet->getPageMargins()->getBottom())); + $objWriter->writeAttribute('header', StringHelper::formatNumber($pSheet->getPageMargins()->getHeader())); + $objWriter->writeAttribute('footer', StringHelper::formatNumber($pSheet->getPageMargins()->getFooter())); $objWriter->endElement(); } /** * Write AutoFilter. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeAutoFilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeAutoFilter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { $autoFilterRange = $pSheet->getAutoFilter()->getRange(); if (!empty($autoFilterRange)) { @@ -771,7 +781,7 @@ class Worksheet extends WriterPart $objWriter->startElement('autoFilter'); // Strip any worksheet reference from the filter coordinates - $range = \PhpOffice\PhpSpreadsheet\Cell::splitRange($autoFilterRange); + $range = Cell::splitRange($autoFilterRange); $range = $range[0]; // Strip any worksheet ref if (strpos($range[0], '!') !== false) { @@ -790,17 +800,17 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID)); $objWriter->startElement($column->getFilterType()); - if ($column->getJoin() == \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND) { + if ($column->getJoin() == Column::AUTOFILTER_COLUMN_JOIN_AND) { $objWriter->writeAttribute('and', 1); } foreach ($rules as $rule) { - if (($column->getFilterType() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER) && - ($rule->getOperator() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && + if (($column->getFilterType() === Column::AUTOFILTER_FILTERTYPE_FILTER) && + ($rule->getOperator() === Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && ($rule->getValue() === '')) { // Filter rule for Blanks $objWriter->writeAttribute('blank', 1); - } elseif ($rule->getRuleType() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { + } elseif ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { // Dynamic Filter Rule $objWriter->writeAttribute('type', $rule->getGrouping()); $val = $column->getAttribute('val'); @@ -811,19 +821,19 @@ class Worksheet extends WriterPart if ($maxVal !== null) { $objWriter->writeAttribute('maxVal', $maxVal); } - } elseif ($rule->getRuleType() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) { + } elseif ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) { // Top 10 Filter Rule $objWriter->writeAttribute('val', $rule->getValue()); - $objWriter->writeAttribute('percent', (($rule->getOperator() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0')); - $objWriter->writeAttribute('top', (($rule->getGrouping() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1' : '0')); + $objWriter->writeAttribute('percent', (($rule->getOperator() === Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0')); + $objWriter->writeAttribute('top', (($rule->getGrouping() === Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1' : '0')); } else { // Filter, DateGroupItem or CustomFilter $objWriter->startElement($rule->getRuleType()); - if ($rule->getOperator() !== \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL) { + if ($rule->getOperator() !== Rule::AUTOFILTER_COLUMN_RULE_EQUAL) { $objWriter->writeAttribute('operator', $rule->getOperator()); } - if ($rule->getRuleType() === \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP) { + if ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_DATEGROUP) { // Date Group filters foreach ($rule->getValue() as $key => $value) { if ($value > '') { @@ -852,12 +862,12 @@ class Worksheet extends WriterPart /** * Write PageSetup. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writePageSetup(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writePageSetup(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // pageSetup $objWriter->startElement('pageSetup'); @@ -888,12 +898,12 @@ class Worksheet extends WriterPart /** * Write Header / Footer. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeHeaderFooter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeHeaderFooter(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // headerFooter $objWriter->startElement('headerFooter'); @@ -914,20 +924,20 @@ class Worksheet extends WriterPart /** * Write Breaks. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeBreaks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeBreaks(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // Get row and column breaks $aRowBreaks = []; $aColumnBreaks = []; foreach ($pSheet->getBreaks() as $cell => $breakType) { - if ($breakType == \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW) { + if ($breakType == PhpspreadsheetWorksheet::BREAK_ROW) { $aRowBreaks[] = $cell; - } elseif ($breakType == \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_COLUMN) { + } elseif ($breakType == PhpspreadsheetWorksheet::BREAK_COLUMN) { $aColumnBreaks[] = $cell; } } @@ -939,7 +949,7 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('manualBreakCount', count($aRowBreaks)); foreach ($aRowBreaks as $cell) { - $coords = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($cell); + $coords = Cell::coordinateFromString($cell); $objWriter->startElement('brk'); $objWriter->writeAttribute('id', $coords[1]); @@ -957,10 +967,10 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks)); foreach ($aColumnBreaks as $cell) { - $coords = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($cell); + $coords = Cell::coordinateFromString($cell); $objWriter->startElement('brk'); - $objWriter->writeAttribute('id', \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($coords[0]) - 1); + $objWriter->writeAttribute('id', Cell::columnIndexFromString($coords[0]) - 1); $objWriter->writeAttribute('man', '1'); $objWriter->endElement(); } @@ -972,13 +982,13 @@ class Worksheet extends WriterPart /** * Write SheetData. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param string[] $pStringTable String table * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeSheetData(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, array $pStringTable) + private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, array $pStringTable) { // Flipped stringtable, for faster index searching $aFlippedStringTable = $this->getParentWriter()->getWriterPart('stringtable')->flipStringTable($pStringTable); @@ -987,7 +997,7 @@ class Worksheet extends WriterPart $objWriter->startElement('sheetData'); // Get column count - $colCount = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($pSheet->getHighestColumn()); + $colCount = Cell::columnIndexFromString($pSheet->getHighestColumn()); // Highest row number $highestRow = $pSheet->getHighestRow(); @@ -995,7 +1005,7 @@ class Worksheet extends WriterPart // Loop through cells $cellsByRow = []; foreach ($pSheet->getCoordinates() as $coordinate) { - $cellAddress = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($coordinate); + $cellAddress = Cell::coordinateFromString($coordinate); $cellsByRow[$cellAddress[1]][] = $coordinate; } @@ -1016,7 +1026,7 @@ class Worksheet extends WriterPart // Row dimensions if ($rowDimension->getRowHeight() >= 0) { $objWriter->writeAttribute('customHeight', '1'); - $objWriter->writeAttribute('ht', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($rowDimension->getRowHeight())); + $objWriter->writeAttribute('ht', StringHelper::formatNumber($rowDimension->getRowHeight())); } // Row visibility @@ -1059,15 +1069,15 @@ class Worksheet extends WriterPart /** * Write Cell. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet - * @param \PhpOffice\PhpSpreadsheet\Cell $pCellAddress Cell Address + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet + * @param Cell $pCellAddress Cell Address * @param string[] $pStringTable String table * @param string[] $pFlippedStringTable String table (flipped), for faster index searching * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeCell(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pCellAddress, array $pFlippedStringTable) + private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $pCellAddress, array $pFlippedStringTable) { // Cell $pCell = $pSheet->getCell($pCellAddress); @@ -1106,9 +1116,9 @@ class Worksheet extends WriterPart // Write data depending on its type switch (strtolower($mappedType)) { case 'inlinestr': // Inline string - if (!$cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { - $objWriter->writeElement('t', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue))); - } elseif ($cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if (!$cellValue instanceof RichText) { + $objWriter->writeElement('t', StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue))); + } elseif ($cellValue instanceof RichText) { $objWriter->startElement('is'); $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); $objWriter->endElement(); @@ -1116,11 +1126,11 @@ class Worksheet extends WriterPart break; case 's': // String - if (!$cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { + if (!$cellValue instanceof RichText) { if (isset($pFlippedStringTable[$cellValue])) { $objWriter->writeElement('v', $pFlippedStringTable[$cellValue]); } - } elseif ($cellValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { + } elseif ($cellValue instanceof RichText) { $objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]); } @@ -1141,7 +1151,7 @@ class Worksheet extends WriterPart if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getPreCalculateFormulas()) { if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') { - $objWriter->writeElement('v', \PhpOffice\PhpSpreadsheet\Shared\StringHelper::formatNumber($calculatedValue)); + $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue)); } else { $objWriter->writeElement('v', '0'); } @@ -1175,13 +1185,13 @@ class Worksheet extends WriterPart /** * Write Drawings. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeDrawings(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null, $includeCharts = false) + private function writeDrawings(XMLWriter $objWriter = null, PhpspreadsheetWorksheet $pSheet = null, $includeCharts = false) { $chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0; // If sheet contains drawings, add the relationships @@ -1196,12 +1206,12 @@ class Worksheet extends WriterPart /** * Write LegacyDrawing. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeLegacyDrawing(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeLegacyDrawing(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // If sheet contains comments, add the relationships if (count($pSheet->getComments()) > 0) { @@ -1214,12 +1224,12 @@ class Worksheet extends WriterPart /** * Write LegacyDrawingHF. * - * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet $pSheet Worksheet + * @param XMLWriter $objWriter XML Writer + * @param PhpspreadsheetWorksheet $pSheet Worksheet * - * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + * @throws WriterException */ - private function writeLegacyDrawingHF(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) + private function writeLegacyDrawingHF(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet) { // If sheet contains images, add the relationships if (count($pSheet->getHeaderFooter()->getImages()) > 0) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php index a743ab12..e6a16fda 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; + /** * Copyright (c) 2006 - 2015 PhpSpreadsheet. * @@ -29,7 +31,7 @@ abstract class WriterPart /** * Parent Xlsx object. * - * @var \PhpOffice\PhpSpreadsheet\Writer\Xlsx + * @var Xlsx */ private $parentWriter; @@ -38,7 +40,7 @@ abstract class WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * - * @return \PhpOffice\PhpSpreadsheet\Writer\Xlsx + * @return Xlsx */ public function getParentWriter() { @@ -48,9 +50,9 @@ abstract class WriterPart /** * Set parent Xlsx object. * - * @param \PhpOffice\PhpSpreadsheet\Writer\Xlsx $pWriter + * @param Xlsx $pWriter */ - public function __construct(\PhpOffice\PhpSpreadsheet\Writer\Xlsx $pWriter) + public function __construct(Xlsx $pWriter) { $this->parentWriter = $pWriter; } diff --git a/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php b/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php index d8458045..6b05d454 100644 --- a/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php @@ -5,11 +5,12 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Shared\Date; +use PHPUnit_Framework_TestCase; /** * Class DateTimeTest. */ -class DateTimeTest extends \PHPUnit_Framework_TestCase +class DateTimeTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php b/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php index 89d1e5f1..2e19eff7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php @@ -4,17 +4,19 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert; +use PHPUnit_Framework_TestCase; -class EngineeringTest extends \PHPUnit_Framework_TestCase +class EngineeringTest extends PHPUnit_Framework_TestCase { /** - * @var \PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert + * @var ComplexAssert */ protected $complexAssert; public function setUp() { - $this->complexAssert = new \PhpOffice\PhpSpreadsheetTests\Custom\ComplexAssert(); + $this->complexAssert = new ComplexAssert(); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php index b61ef6ae..04f6b4e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PHPUnit_Framework_TestCase; -class FinancialTest extends \PHPUnit_Framework_TestCase +class FinancialTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index 2f6aaa06..371f2826 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PHPUnit_Framework_TestCase; -class FunctionsTest extends \PHPUnit_Framework_TestCase +class FunctionsTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php b/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php index ab9cf4fd..d1aac26a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PHPUnit_Framework_TestCase; -class LogicalTest extends \PHPUnit_Framework_TestCase +class LogicalTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php index 39dfa17d..94696e4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php @@ -4,11 +4,12 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PHPUnit_Framework_TestCase; /** * Class LookupRefTest. */ -class LookupRefTest extends \PHPUnit_Framework_TestCase +class LookupRefTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php b/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php index 518250fa..d765931c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; +use PHPUnit_Framework_TestCase; -class MathTrigTest extends \PHPUnit_Framework_TestCase +class MathTrigTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php b/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php index e4c06b2d..8a6cd0c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\TextData; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PHPUnit_Framework_TestCase; -class TextDataTest extends \PHPUnit_Framework_TestCase +class TextDataTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/CalculationTest.php b/tests/PhpSpreadsheetTests/CalculationTest.php index 8711e6ac..d8979979 100644 --- a/tests/PhpSpreadsheetTests/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/CalculationTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests; use PhpOffice\PhpSpreadsheet\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Functions; +use PHPUnit_Framework_TestCase; -class CalculationTest extends \PHPUnit_Framework_TestCase +class CalculationTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php index 2f8b29a3..637ced24 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -9,8 +9,9 @@ use PhpOffice\PhpSpreadsheet\Collection\Cells; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Worksheet; +use PHPUnit_Framework_TestCase; -class AdvancedValueBinderTest extends \PHPUnit_Framework_TestCase +class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase { public function provider() { diff --git a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php index f98f4fb5..92ab1f29 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Cell; use PhpOffice\PhpSpreadsheet\Cell\DataType; +use PHPUnit_Framework_TestCase; -class DataTypeTest extends \PHPUnit_Framework_TestCase +class DataTypeTest extends PHPUnit_Framework_TestCase { public function testGetErrorCodes() { diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index ca892d66..4d09a56a 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -2,12 +2,14 @@ namespace PhpOffice\PhpSpreadsheetTests\Cell; +use DateTime; use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder; use PhpOffice\PhpSpreadsheet\RichText; +use PHPUnit_Framework_TestCase; -class DefaultValueBinderTest extends \PHPUnit_Framework_TestCase +class DefaultValueBinderTest extends PHPUnit_Framework_TestCase { protected $cellStub; @@ -50,7 +52,7 @@ class DefaultValueBinderTest extends \PHPUnit_Framework_TestCase ['123'], ['-123.456'], ['#REF!'], - [new \DateTime()], + [new DateTime()], ]; } diff --git a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php index b4c68f62..3d86cb62 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Cell; use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; +use PHPUnit_Framework_TestCase; -class HyperlinkTest extends \PHPUnit_Framework_TestCase +class HyperlinkTest extends PHPUnit_Framework_TestCase { public function testGetUrl() { diff --git a/tests/PhpSpreadsheetTests/CellTest.php b/tests/PhpSpreadsheetTests/CellTest.php index 6e60efe5..118978f9 100644 --- a/tests/PhpSpreadsheetTests/CellTest.php +++ b/tests/PhpSpreadsheetTests/CellTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests; use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Exception; +use PHPUnit_Framework_TestCase; -class CellTest extends \PHPUnit_Framework_TestCase +class CellTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerColumnString diff --git a/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php b/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php index 7e87bfab..a7746b16 100644 --- a/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php +++ b/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Chart; use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues; use PhpOffice\PhpSpreadsheet\Exception; +use PHPUnit_Framework_TestCase; -class DataSeriesValuesTest extends \PHPUnit_Framework_TestCase +class DataSeriesValuesTest extends PHPUnit_Framework_TestCase { public function testSetDataType() { diff --git a/tests/PhpSpreadsheetTests/Chart/LayoutTest.php b/tests/PhpSpreadsheetTests/Chart/LayoutTest.php index de8d3c9f..22daa18d 100644 --- a/tests/PhpSpreadsheetTests/Chart/LayoutTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LayoutTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Chart; use PhpOffice\PhpSpreadsheet\Chart\Layout; +use PHPUnit_Framework_TestCase; -class LayoutTest extends \PHPUnit_Framework_TestCase +class LayoutTest extends PHPUnit_Framework_TestCase { public function testSetLayoutTarget() { diff --git a/tests/PhpSpreadsheetTests/Chart/LegendTest.php b/tests/PhpSpreadsheetTests/Chart/LegendTest.php index e472fbfe..1df0ab70 100644 --- a/tests/PhpSpreadsheetTests/Chart/LegendTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LegendTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Chart; use PhpOffice\PhpSpreadsheet\Chart\Legend; +use PHPUnit_Framework_TestCase; -class LegendTest extends \PHPUnit_Framework_TestCase +class LegendTest extends PHPUnit_Framework_TestCase { public function testSetPosition() { diff --git a/tests/PhpSpreadsheetTests/Collection/CellsTest.php b/tests/PhpSpreadsheetTests/Collection/CellsTest.php index 6b91ec6f..33899be7 100644 --- a/tests/PhpSpreadsheetTests/Collection/CellsTest.php +++ b/tests/PhpSpreadsheetTests/Collection/CellsTest.php @@ -7,8 +7,9 @@ use PhpOffice\PhpSpreadsheet\Collection\Cells; use PhpOffice\PhpSpreadsheet\Collection\Memory; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet; +use PHPUnit_Framework_TestCase; -class CellsTest extends \PHPUnit_Framework_TestCase +class CellsTest extends PHPUnit_Framework_TestCase { public function testCollectionCell() { diff --git a/tests/PhpSpreadsheetTests/Helper/MigratorTest.php b/tests/PhpSpreadsheetTests/Helper/MigratorTest.php index 39a922ab..cb91f65a 100644 --- a/tests/PhpSpreadsheetTests/Helper/MigratorTest.php +++ b/tests/PhpSpreadsheetTests/Helper/MigratorTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Helper; use PhpOffice\PhpSpreadsheet\Helper\Migrator; +use PHPUnit_Framework_TestCase; -class MigratorTest extends \PHPUnit_Framework_TestCase +class MigratorTest extends PHPUnit_Framework_TestCase { public function testMappingOnlyContainExistingClasses() { diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 51787521..071e4bb6 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests; use PhpOffice\PhpSpreadsheet\IOFactory; +use PHPUnit_Framework_TestCase; -class IOFactoryTest extends \PHPUnit_Framework_TestCase +class IOFactoryTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerIdentify diff --git a/tests/PhpSpreadsheetTests/Reader/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/CsvTest.php index 6727b10b..90e94a52 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvTest.php @@ -2,10 +2,13 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; +use PhpOffice\PhpSpreadsheet\Reader\Csv as ReaderCsv; use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Csv as WriterCsv; +use PHPUnit_Framework_TestCase; -class CsvTest extends \PHPUnit_Framework_TestCase +class CsvTest extends PHPUnit_Framework_TestCase { public function testEnclosure() { @@ -15,11 +18,11 @@ class CsvTest extends \PHPUnit_Framework_TestCase // Write temp file with value $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->getCell('A1')->setValue($value); - $writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet); + $writer = new WriterCsv($spreadsheet); $writer->save($filename); // Read written file - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); + $reader = new ReaderCsv(); $reloadedSpreadsheet = $reader->load($filename); $actual = $reloadedSpreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue(); $this->assertSame($value, $actual, 'should be able to write and read strings with multiples quotes'); @@ -27,7 +30,7 @@ class CsvTest extends \PHPUnit_Framework_TestCase public function testDelimiterDetection() { - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); + $reader = new ReaderCsv(); $this->assertNull($reader->getDelimiter()); $filename = __DIR__ . '/../../data/Reader/CSV/semicolon_separated.csv'; diff --git a/tests/PhpSpreadsheetTests/Reader/HTMLTest.php b/tests/PhpSpreadsheetTests/Reader/HTMLTest.php index 03ad95f9..b1b51a59 100644 --- a/tests/PhpSpreadsheetTests/Reader/HTMLTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HTMLTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; use PhpOffice\PhpSpreadsheet\Reader\Html; +use PHPUnit_Framework_TestCase; -class HTMLTest extends \PHPUnit_Framework_TestCase +class HTMLTest extends PHPUnit_Framework_TestCase { public function testCsvWithAngleBracket() { diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php index ccda9958..658869b0 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -4,25 +4,27 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Reader\Ods; +use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Font; +use PHPUnit_Framework_TestCase; /** * @todo The class doesn't read the bold/italic/underline properties (rich text) */ -class OdsTest extends \PHPUnit_Framework_TestCase +class OdsTest extends PHPUnit_Framework_TestCase { /** - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadsheetOOCalcTest; /** - * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + * @var Spreadsheet */ private $spreadsheetData; /** - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ protected function loadOOCalcTestFile() { @@ -31,14 +33,14 @@ class OdsTest extends \PHPUnit_Framework_TestCase // Load into this instance $reader = new Ods(); - $this->spreadsheetOOCalcTest = $reader->loadIntoExisting($filename, new \PhpOffice\PhpSpreadsheet\Spreadsheet()); + $this->spreadsheetOOCalcTest = $reader->loadIntoExisting($filename, new Spreadsheet()); } return $this->spreadsheetOOCalcTest; } /** - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ protected function loadDataFile() { @@ -47,7 +49,7 @@ class OdsTest extends \PHPUnit_Framework_TestCase // Load into this instance $reader = new Ods(); - $this->spreadsheetData = $reader->loadIntoExisting($filename, new \PhpOffice\PhpSpreadsheet\Spreadsheet()); + $this->spreadsheetData = $reader->loadIntoExisting($filename, new Spreadsheet()); } return $this->spreadsheetData; diff --git a/tests/PhpSpreadsheetTests/Reader/XEEValidatorTest.php b/tests/PhpSpreadsheetTests/Reader/XEEValidatorTest.php index a9a97314..372e51bb 100644 --- a/tests/PhpSpreadsheetTests/Reader/XEEValidatorTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XEEValidatorTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader; use PhpOffice\PhpSpreadsheet\Reader\BaseReader; +use PHPUnit_Framework_TestCase; -class XEEValidatorTest extends \PHPUnit_Framework_TestCase +class XEEValidatorTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerInvalidXML diff --git a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php index ecbcd081..1f7e0d56 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelperTest.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelperTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests; use PhpOffice\PhpSpreadsheet\ReferenceHelper; +use PHPUnit_Framework_TestCase; -class ReferenceHelperTest extends \PHPUnit_Framework_TestCase +class ReferenceHelperTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/SampleTest.php b/tests/PhpSpreadsheetTests/SampleTest.php index a7e1e075..ecbedfbd 100644 --- a/tests/PhpSpreadsheetTests/SampleTest.php +++ b/tests/PhpSpreadsheetTests/SampleTest.php @@ -2,7 +2,10 @@ namespace PhpOffice\PhpSpreadsheetTests; -class SampleTest extends \PHPUnit_Framework_TestCase +use PhpOffice\PhpSpreadsheet\Helper\Sample; +use PHPUnit_Framework_TestCase; + +class SampleTest extends PHPUnit_Framework_TestCase { /** * @runInSeparateProcess @@ -35,7 +38,7 @@ class SampleTest extends \PHPUnit_Framework_TestCase $skipped = array_merge($skipped, $tooLongToBeCovered); } - $helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample(); + $helper = new Sample(); $samples = []; foreach ($helper->getSamples() as $name => $sample) { if (!in_array($name, $skipped)) { diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index 02a8c36b..ec0e12ea 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -2,7 +2,10 @@ namespace PhpOffice\PhpSpreadsheetTests; -class SettingsTest extends \PHPUnit_Framework_TestCase +use PhpOffice\PhpSpreadsheet\Settings; +use PHPUnit_Framework_TestCase; + +class SettingsTest extends PHPUnit_Framework_TestCase { /** * @var string @@ -22,15 +25,15 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testGetXMLSettings() { - $result = \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions(); + $result = Settings::getLibXmlLoaderOptions(); $this->assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result)); $this->assertFalse(libxml_disable_entity_loader()); } public function testSetXMLSettings() { - \PhpOffice\PhpSpreadsheet\Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); - $result = \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions(); + Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); + $result = Settings::getLibXmlLoaderOptions(); $this->assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result)); $this->assertFalse(libxml_disable_entity_loader()); } diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php index 337b8ed4..7841fe98 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Shared\CodePage; +use PHPUnit_Framework_TestCase; -class CodePageTest extends \PHPUnit_Framework_TestCase +class CodePageTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerCodePage diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 0439cf60..2e6d028d 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\Date; +use PHPUnit_Framework_TestCase; -class DateTest extends \PHPUnit_Framework_TestCase +class DateTest extends PHPUnit_Framework_TestCase { public function testSetExcelCalendar() { diff --git a/tests/PhpSpreadsheetTests/Shared/FileTest.php b/tests/PhpSpreadsheetTests/Shared/FileTest.php index eb802a0f..5f148a2a 100644 --- a/tests/PhpSpreadsheetTests/Shared/FileTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FileTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\File; +use PHPUnit_Framework_TestCase; -class FileTest extends \PHPUnit_Framework_TestCase +class FileTest extends PHPUnit_Framework_TestCase { public function testGetUseUploadTempDirectory() { diff --git a/tests/PhpSpreadsheetTests/Shared/FontTest.php b/tests/PhpSpreadsheetTests/Shared/FontTest.php index c104cb14..76a40d1c 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\Font; +use PHPUnit_Framework_TestCase; -class FontTest extends \PHPUnit_Framework_TestCase +class FontTest extends PHPUnit_Framework_TestCase { public function testGetAutoSizeMethod() { diff --git a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php index 444883cb..271deefc 100644 --- a/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php +++ b/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\PasswordHasher; +use PHPUnit_Framework_TestCase; -class PasswordHasherTest extends \PHPUnit_Framework_TestCase +class PasswordHasherTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerHashPassword diff --git a/tests/PhpSpreadsheetTests/Shared/StringTest.php b/tests/PhpSpreadsheetTests/Shared/StringTest.php index 83643127..9fbaba33 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use PHPUnit_Framework_TestCase; -class StringTest extends \PHPUnit_Framework_TestCase +class StringTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php index 58f791d1..706955c2 100644 --- a/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php +++ b/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\TimeZone; +use PHPUnit_Framework_TestCase; -class TimeZoneTest extends \PHPUnit_Framework_TestCase +class TimeZoneTest extends PHPUnit_Framework_TestCase { public function testSetTimezone() { diff --git a/tests/PhpSpreadsheetTests/Style/ColorTest.php b/tests/PhpSpreadsheetTests/Style/ColorTest.php index 8dca92f1..6ed161d2 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Style; use PhpOffice\PhpSpreadsheet\Style\Color; +use PHPUnit_Framework_TestCase; -class ColorTest extends \PHPUnit_Framework_TestCase +class ColorTest extends PHPUnit_Framework_TestCase { /** * @dataProvider providerColorGetRed diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatDateTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatDateTest.php index 01c51c59..af462e41 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatDateTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatDateTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Style; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PHPUnit_Framework_TestCase; -class NumberFormatDateTest extends \PHPUnit_Framework_TestCase +class NumberFormatDateTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php index d900962a..72c7fbe4 100644 --- a/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php @@ -4,8 +4,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Style; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PHPUnit_Framework_TestCase; -class NumberFormatTest extends \PHPUnit_Framework_TestCase +class NumberFormatTest extends PHPUnit_Framework_TestCase { public function setUp() { diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php index 15d29f32..b7760e25 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/Column/RuleTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet\AutoFilter\Column; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; +use PHPUnit_Framework_TestCase; -class RuleTest extends \PHPUnit_Framework_TestCase +class RuleTest extends PHPUnit_Framework_TestCase { private $testAutoFilterRuleObject; private $mockAutoFilterColumnObject; diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php index 8a92c8ad..e171e814 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php @@ -3,8 +3,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet\AutoFilter; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter; +use PHPUnit_Framework_TestCase; -class ColumnTest extends \PHPUnit_Framework_TestCase +class ColumnTest extends PHPUnit_Framework_TestCase { private $testInitialColumn = 'H'; private $testAutoFilterColumnObject; diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php index 7a943642..974dbd70 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php @@ -6,8 +6,9 @@ use PhpOffice\PhpSpreadsheet\Collection\Cells; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; +use PHPUnit_Framework_TestCase; -class AutoFilterTest extends \PHPUnit_Framework_TestCase +class AutoFilterTest extends PHPUnit_Framework_TestCase { private $testInitialRange = 'H2:O256'; private $testAutoFilterObject; diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php index 997307a4..5af397a5 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator; +use PHPUnit_Framework_TestCase; -class ColumnCellIteratorTest extends \PHPUnit_Framework_TestCase +class ColumnCellIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockColumnCell; diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php index 3fdcd446..3f107f45 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Column; use PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator; +use PHPUnit_Framework_TestCase; -class ColumnIteratorTest extends \PHPUnit_Framework_TestCase +class ColumnIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockColumn; diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php index e63d3f95..edb76a55 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Cell; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator; +use PHPUnit_Framework_TestCase; -class RowCellIteratorTest extends \PHPUnit_Framework_TestCase +class RowCellIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockRowCell; diff --git a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php index 1bfa69d7..071baf7d 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Row; use PhpOffice\PhpSpreadsheet\Worksheet\RowIterator; +use PHPUnit_Framework_TestCase; -class RowIteratorTest extends \PHPUnit_Framework_TestCase +class RowIteratorTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockRow; diff --git a/tests/PhpSpreadsheetTests/Worksheet/WorksheetColumnTest.php b/tests/PhpSpreadsheetTests/Worksheet/WorksheetColumnTest.php index 7c1c3487..c8730e25 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/WorksheetColumnTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/WorksheetColumnTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Column; use PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator; +use PHPUnit_Framework_TestCase; -class WorksheetColumnTest extends \PHPUnit_Framework_TestCase +class WorksheetColumnTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockColumn; diff --git a/tests/PhpSpreadsheetTests/Worksheet/WorksheetRowTest.php b/tests/PhpSpreadsheetTests/Worksheet/WorksheetRowTest.php index 59901f44..d16149fb 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/WorksheetRowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/WorksheetRowTest.php @@ -5,8 +5,9 @@ namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Row; use PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator; +use PHPUnit_Framework_TestCase; -class WorksheetRowTest extends \PHPUnit_Framework_TestCase +class WorksheetRowTest extends PHPUnit_Framework_TestCase { public $mockWorksheet; public $mockRow; diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index 8a4aae64..00cf5cc5 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -12,8 +12,9 @@ use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Writer\Ods\Content; +use PHPUnit_Framework_TestCase; -class ContentTest extends \PHPUnit_Framework_TestCase +class ContentTest extends PHPUnit_Framework_TestCase { private $samplesPath = __DIR__ . '/../../../data/Writer/Ods'; From 44e2461b7b7c532e8892997df267b4c1c89fe2d8 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Fri, 19 May 2017 23:49:12 +0200 Subject: [PATCH 05/31] Refactor `define()` as class constants This will improve interoperability with other projects and simplify our code. Closes #157 --- src/PhpSpreadsheet/Calculation.php | 19 +---- .../Calculation/Engineering.php | 18 +++-- src/PhpSpreadsheet/Calculation/Financial.php | 28 +++---- src/PhpSpreadsheet/Calculation/Functions.php | 20 ++--- .../Calculation/Statistical.php | 77 +++++++++--------- .../Shared/JAMA/CholeskyDecomposition.php | 4 +- src/PhpSpreadsheet/Shared/JAMA/Matrix.php | 5 +- .../Shared/JAMA/utils/Error.php | 79 ------------------- src/PhpSpreadsheet/Shared/OLERead.php | 9 +-- src/PhpSpreadsheet/Shared/XMLWriter.php | 12 +-- 10 files changed, 78 insertions(+), 193 deletions(-) delete mode 100644 src/PhpSpreadsheet/Shared/JAMA/utils/Error.php diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index 684070ab..17556270 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -14,21 +14,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; use PhpOffice\PhpSpreadsheet\Calculation\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\TextData; -if (!defined('CALCULATION_REGEXP_CELLREF')) { - // Test for support of \P (multibyte options) in PCRE - if (defined('PREG_BAD_UTF8_ERROR')) { - // Cell reference (cell or range of cells, with or without a sheet reference) - define('CALCULATION_REGEXP_CELLREF', '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'); - // Named Range of cells - define('CALCULATION_REGEXP_NAMEDRANGE', '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'); - } else { - // Cell reference (cell or range of cells, with or without a sheet reference) - define('CALCULATION_REGEXP_CELLREF', '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)'); - // Named Range of cells - define('CALCULATION_REGEXP_NAMEDRANGE', '(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)'); - } -} - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -64,9 +49,9 @@ class Calculation // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it) const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; // Cell reference (cell or range of cells, with or without a sheet reference) - const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; + const CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'; // Named Range of cells - const CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE; + const CALCULATION_REGEXP_NAMEDRANGE = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'; // Error const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 6fe07b39..582c6cbd 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -2,9 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; -/* EULER */ -define('EULER', 2.71828182845904523536); - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -29,6 +26,11 @@ define('EULER', 2.71828182845904523536); */ class Engineering { + /** + * EULER. + */ + const EULER = 2.71828182845904523536; + /** * Details of the Units of measure that can be used in CONVERTUOM(). * @@ -944,7 +946,7 @@ class Engineering $f_PI_DIV_4 = M_PI / 4; $fXAbs = abs($x); - $fResult = sqrt(M_2DIVPI / $fXAbs) * cos($fXAbs - $ord * $f_PI_DIV_2 - $f_PI_DIV_4); + $fResult = sqrt(Functions::M_2DIVPI / $fXAbs) * cos($fXAbs - $ord * $f_PI_DIV_2 - $f_PI_DIV_4); if (($ord & 1) && ($x < 0)) { $fResult = -$fResult; } @@ -2103,7 +2105,7 @@ class Engineering return log10($parsedComplex['real']); } - return self::IMPRODUCT(log10(EULER), self::IMLN($complexNumber)); + return self::IMPRODUCT(log10(self::EULER), self::IMLN($complexNumber)); } /** @@ -2130,7 +2132,7 @@ class Engineering return log($parsedComplex['real'], 2); } - return self::IMPRODUCT(log(EULER, 2), self::IMLN($complexNumber)); + return self::IMPRODUCT(log(self::EULER, 2), self::IMLN($complexNumber)); } /** @@ -2434,7 +2436,7 @@ class Engineering if ($sum == 0.0) { break; } - } while (abs($term / $sum) > PRECISION); + } while (abs($term / $sum) > Functions::PRECISION); return self::$twoSqrtPi * $sum; } @@ -2503,7 +2505,7 @@ class Engineering $n += 0.5; $q1 = $q2; $q2 = $b / $d; - } while ((abs($q1 - $q2) / $q2) > PRECISION); + } while ((abs($q1 - $q2) / $q2) > Functions::PRECISION); return self::$oneSqrtPi * exp(-$x * $x) * $q2; } diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 305494be..ea6dbce8 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -2,14 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; -/* FINANCIAL_MAX_ITERATIONS */ use PhpOffice\PhpSpreadsheet\Shared\Date; -define('FINANCIAL_MAX_ITERATIONS', 128); - -/* FINANCIAL_PRECISION */ -define('FINANCIAL_PRECISION', 1.0e-08); - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -34,6 +28,10 @@ define('FINANCIAL_PRECISION', 1.0e-08); */ class Financial { + const FINANCIAL_MAX_ITERATIONS = 128; + + const FINANCIAL_PRECISION = 1.0e-08; + /** * isLastDayOfMonth. * @@ -1428,7 +1426,7 @@ class Financial $x2 = $guess; $f1 = self::NPV($x1, $values); $f2 = self::NPV($x2, $values); - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { + for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { if (($f1 * $f2) < 0.0) { break; } @@ -1451,14 +1449,14 @@ class Financial $dx = $x1 - $x2; } - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { + for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { $dx *= 0.5; $x_mid = $rtb + $dx; $f_mid = self::NPV($x_mid, $values); if ($f_mid <= 0.0) { $rtb = $x_mid; } - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { + if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) { return $x_mid; } } @@ -1965,7 +1963,7 @@ class Financial $guess = (is_null($guess)) ? 0.1 : Functions::flattenSingleValue($guess); $rate = $guess; - if (abs($rate) < FINANCIAL_PRECISION) { + if (abs($rate) < self::FINANCIAL_PRECISION) { $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; } else { $f = exp($nper * log(1 + $rate)); @@ -1977,14 +1975,14 @@ class Financial // find root by secant method $i = $x0 = 0.0; $x1 = $rate; - while ((abs($y0 - $y1) > FINANCIAL_PRECISION) && ($i < FINANCIAL_MAX_ITERATIONS)) { + while ((abs($y0 - $y1) > self::FINANCIAL_PRECISION) && ($i < self::FINANCIAL_MAX_ITERATIONS)) { $rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0); $x0 = $x1; $x1 = $rate; if (($nper * abs($pmt)) > ($pv - $fv)) { $x1 = abs($x1); } - if (abs($rate) < FINANCIAL_PRECISION) { + if (abs($rate) < self::FINANCIAL_PRECISION) { $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; } else { $f = exp($nper * log(1 + $rate)); @@ -2282,7 +2280,7 @@ class Financial $x2 = $guess; $f1 = self::XNPV($x1, $values, $dates); $f2 = self::XNPV($x2, $values, $dates); - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { + for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { if (($f1 * $f2) < 0.0) { break; } elseif (abs($f1) < abs($f2)) { @@ -2304,14 +2302,14 @@ class Financial $dx = $x1 - $x2; } - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { + for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { $dx *= 0.5; $x_mid = $rtb + $dx; $f_mid = self::XNPV($x_mid, $values, $dates); if ($f_mid <= 0.0) { $rtb = $x_mid; } - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { + if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) { return $x_mid; } } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index b13e987d..49ff4182 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -2,20 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; -/* MAX_VALUE */ use PhpOffice\PhpSpreadsheet\Calculation; -define('MAX_VALUE', 1.2e308); - -/* 2 / PI */ -define('M_2DIVPI', 0.63661977236758134307553505349006); - -/* MAX_ITERATIONS */ -define('MAX_ITERATIONS', 256); - -/* PRECISION */ -define('PRECISION', 8.88E-016); - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -40,11 +28,17 @@ define('PRECISION', 8.88E-016); */ class Functions { + const PRECISION = 8.88E-016; + + /** + * 2 / PI. + */ + const M_2DIVPI = 0.63661977236758134307553505349006; + /** constants */ const COMPATIBILITY_EXCEL = 'Excel'; const COMPATIBILITY_GNUMERIC = 'Gnumeric'; const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'; - const RETURNDATE_PHP_NUMERIC = 'P'; const RETURNDATE_PHP_OBJECT = 'O'; const RETURNDATE_EXCEL = 'E'; diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index b379b1ba..fc5cdbb3 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -2,21 +2,9 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; -/* LOG_GAMMA_X_MAX_VALUE */ use PhpOffice\PhpSpreadsheet\Calculation; use PhpOffice\PhpSpreadsheet\Shared\Trend\Trend; -define('LOG_GAMMA_X_MAX_VALUE', 2.55e305); - -/* XMININ */ -define('XMININ', 2.23e-308); - -/* EPS */ -define('EPS', 2.22e-16); - -/* SQRT2PI */ -define('SQRT2PI', 2.5066282746310005024157652848110452530069867406099); - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -41,6 +29,13 @@ define('SQRT2PI', 2.5066282746310005024157652848110452530069867406099); */ class Statistical { + const LOG_GAMMA_X_MAX_VALUE = 2.55e305; + const XMININ = 2.23e-308; + const EPS = 2.22e-16; + const MAX_VALUE = 1.2e308; + const MAX_ITERATIONS = 256; + const SQRT2PI = 2.5066282746310005024157652848110452530069867406099; + private static function checkTrendArrays(&$array1, &$array2) { if (!is_array($array1)) { @@ -82,7 +77,7 @@ class Statistical */ private static function beta($p, $q) { - if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) { + if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > self::LOG_GAMMA_X_MAX_VALUE) { return 0.0; } @@ -112,7 +107,7 @@ class Statistical return 0.0; } elseif ($x >= 1.0) { return 1.0; - } elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) { + } elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > self::LOG_GAMMA_X_MAX_VALUE)) { return 0.0; } $beta_gam = exp((0 - self::logBeta($p, $q)) + $p * log($x) + $q * log(1.0 - $x)); @@ -145,7 +140,7 @@ class Statistical if ($p != self::$logBetaCacheP || $q != self::$logBetaCacheQ) { self::$logBetaCacheP = $p; self::$logBetaCacheQ = $q; - if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) { + if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > self::LOG_GAMMA_X_MAX_VALUE)) { self::$logBetaCacheResult = 0.0; } else { self::$logBetaCacheResult = self::logGamma($p) + self::logGamma($q) - self::logGamma($p + $q); @@ -172,37 +167,37 @@ class Statistical $p_plus = $p + 1.0; $p_minus = $p - 1.0; $h = 1.0 - $sum_pq * $x / $p_plus; - if (abs($h) < XMININ) { - $h = XMININ; + if (abs($h) < self::XMININ) { + $h = self::XMININ; } $h = 1.0 / $h; $frac = $h; $m = 1; $delta = 0.0; - while ($m <= MAX_ITERATIONS && abs($delta - 1.0) > PRECISION) { + while ($m <= self::MAX_ITERATIONS && abs($delta - 1.0) > Functions::PRECISION) { $m2 = 2 * $m; // even index for d $d = $m * ($q - $m) * $x / (($p_minus + $m2) * ($p + $m2)); $h = 1.0 + $d * $h; - if (abs($h) < XMININ) { - $h = XMININ; + if (abs($h) < self::XMININ) { + $h = self::XMININ; } $h = 1.0 / $h; $c = 1.0 + $d / $c; - if (abs($c) < XMININ) { - $c = XMININ; + if (abs($c) < self::XMININ) { + $c = self::XMININ; } $frac *= $h * $c; // odd index for d $d = -($p + $m) * ($sum_pq + $m) * $x / (($p + $m2) * ($p_plus + $m2)); $h = 1.0 + $d * $h; - if (abs($h) < XMININ) { - $h = XMININ; + if (abs($h) < self::XMININ) { + $h = self::XMININ; } $h = 1.0 / $h; $c = 1.0 + $d / $c; - if (abs($c) < XMININ) { - $c = XMININ; + if (abs($c) < self::XMININ) { + $c = self::XMININ; } $delta = $h * $c; $frac *= $delta; @@ -346,8 +341,8 @@ class Statistical return self::$logGammaCacheResult; } $y = $x; - if ($y > 0.0 && $y <= LOG_GAMMA_X_MAX_VALUE) { - if ($y <= EPS) { + if ($y > 0.0 && $y <= self::LOG_GAMMA_X_MAX_VALUE) { + if ($y <= self::EPS) { $res = -log(y); } elseif ($y <= 1.5) { // --------------------- @@ -415,7 +410,7 @@ class Statistical } $res /= $y; $corr = log($y); - $res = $res + log(SQRT2PI) - 0.5 * $corr; + $res = $res + log(self::SQRT2PI) - 0.5 * $corr; $res += $y * ($corr - 1.0); } } @@ -423,7 +418,7 @@ class Statistical // -------------------------- // Return for bad arguments // -------------------------- - $res = MAX_VALUE; + $res = self::MAX_VALUE; } // ------------------------------ // Final adjustments and return @@ -480,7 +475,7 @@ class Statistical $summer += ($p[$j] / ++$y); } - return exp(0 - $tmp + log(SQRT2PI * $summer / $x)); + return exp(0 - $tmp + log(self::SQRT2PI * $summer / $x)); } /*************************************************************************** @@ -977,7 +972,7 @@ class Statistical $b = 2; $i = 0; - while ((($b - $a) > PRECISION) && ($i++ < MAX_ITERATIONS)) { + while ((($b - $a) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) { $guess = ($a + $b) / 2; $result = self::BETADIST($guess, $alpha, $beta); if (($result == $probability) || ($result == 0)) { @@ -988,7 +983,7 @@ class Statistical $a = $guess; } } - if ($i == MAX_ITERATIONS) { + if ($i == self::MAX_ITERATIONS) { return Functions::NA(); } @@ -1102,7 +1097,7 @@ class Statistical $dx = 1; $i = 0; - while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { + while ((abs($dx) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) { // Apply Newton-Raphson step $result = self::CHIDIST($x, $degrees); $error = $result - $probability; @@ -1127,7 +1122,7 @@ class Statistical } $x = $xNew; } - if ($i == MAX_ITERATIONS) { + if ($i == self::MAX_ITERATIONS) { return Functions::NA(); } @@ -1721,7 +1716,7 @@ class Statistical $dx = 1024; $i = 0; - while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { + while ((abs($dx) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) { // Apply Newton-Raphson step $error = self::GAMMADIST($x, $alpha, $beta, true) - $probability; if ($error < 0.0) { @@ -1744,7 +1739,7 @@ class Statistical } $x = $xNew; } - if ($i == MAX_ITERATIONS) { + if ($i == self::MAX_ITERATIONS) { return Functions::NA(); } @@ -2667,7 +2662,7 @@ class Statistical return 0.5 * (1 + Engineering::erfVal(($value - $mean) / ($stdDev * sqrt(2)))); } - return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); + return (1 / (self::SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); } } @@ -3439,7 +3434,7 @@ class Statistical } $tsum *= $ts; if (($degrees % 2) == 1) { - $tsum = M_2DIVPI * ($tsum + $ttheta); + $tsum = Functions::M_2DIVPI * ($tsum + $ttheta); } $tValue = 0.5 * (1 + $tsum); if ($tails == 1) { @@ -3475,7 +3470,7 @@ class Statistical $dx = 1; $i = 0; - while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { + while ((abs($dx) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) { // Apply Newton-Raphson step $result = self::TDIST($x, $degrees, 2); $error = $result - $probability; @@ -3500,7 +3495,7 @@ class Statistical } $x = $xNew; } - if ($i == MAX_ITERATIONS) { + if ($i == self::MAX_ITERATIONS) { return Functions::NA(); } diff --git a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php index 99c27711..6cf68ced 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php @@ -139,8 +139,8 @@ class CholeskyDecomposition return new Matrix($X, $this->m, $nx); } - throw new CalculationException(JAMAError(MatrixSPDException)); + throw new CalculationException(Matrix::MATRIX_SPD_EXCEPTION); } - throw new CalculationException(JAMAError(MATRIX_DIMENSION_EXCEPTION)); + throw new CalculationException(Matrix::MATRIX_DIMENSION_EXCEPTION); } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index e9ec3d06..e2f4ffb0 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -24,6 +24,7 @@ class Matrix const ARGUMENT_BOUNDS_EXCEPTION = 'Invalid argument range.'; const MATRIX_DIMENSION_EXCEPTION = 'Matrix dimensions are not equal.'; const ARRAY_LENGTH_EXCEPTION = 'Array length must be a multiple of m.'; + const MATRIX_SPD_EXCEPTION = 'Can only perform operation on symmetric positive definite matrix.'; /** * Matrix storage. @@ -971,7 +972,7 @@ class Matrix return $C; } - throw new CalculationException(JAMAError(MatrixDimensionMismatch)); + throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); case 'array': $B = new self($args[0]); if ($this->n == $B->m) { @@ -988,7 +989,7 @@ class Matrix return $C; } - throw new CalculationException(JAMAError(MatrixDimensionMismatch)); + throw new CalculationException(self::MATRIX_DIMENSION_EXCEPTION); case 'integer': $C = new self($this->A); for ($i = 0; $i < $C->m; ++$i) { diff --git a/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php b/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php deleted file mode 100644 index 8aa78c55..00000000 --- a/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php +++ /dev/null @@ -1,79 +0,0 @@ -data = file_get_contents($pFilename, false, null, 0, 8); // Check OLE identifier - if ($this->data != self::IDENTIFIER_OLE) { + $identifierOle = pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1); + if ($this->data != $identifierOle) { throw new ReaderException('The filename ' . $pFilename . ' is not recognised as an OLE file'); } diff --git a/src/PhpSpreadsheet/Shared/XMLWriter.php b/src/PhpSpreadsheet/Shared/XMLWriter.php index 8390c765..02ebd99d 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -2,14 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Shared; -if (!defined('DATE_W3C')) { - define('DATE_W3C', 'Y-m-d\TH:i:sP'); -} - -if (!defined('DEBUGMODE_ENABLED')) { - define('DEBUGMODE_ENABLED', false); -} - /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. * @@ -34,6 +26,8 @@ if (!defined('DEBUGMODE_ENABLED')) { */ class XMLWriter extends \XMLWriter { + public static $debugEnabled = false; + /** Temporary storage method */ const STORAGE_MEMORY = 1; const STORAGE_DISK = 2; @@ -71,7 +65,7 @@ class XMLWriter extends \XMLWriter } // Set default values - if (DEBUGMODE_ENABLED) { + if (self::$debugEnabled) { $this->setIndent(true); } } From 6e4e0a65f5d28b95b63d645eb2c1389ab25653e4 Mon Sep 17 00:00:00 2001 From: Zharikov Viktor Date: Tue, 23 May 2017 13:24:56 +0300 Subject: [PATCH 06/31] Could not read old PNG with latest libpng on Ubuntu 17.04 Fixes #150 Closes #162 --- samples/templates/27template.xls | Bin 376832 -> 364544 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/samples/templates/27template.xls b/samples/templates/27template.xls index 39bc8bac3939e97ad14b9671c834fa641bb00b5f..cb6cd6df501fcf6eae8b877ab9aea07b1d241c13 100644 GIT binary patch delta 64768 zcmbq(bzB_5mhK>d!QFlE;1Vo21a}gG1=ry24DRku@FciHaCZ;x5ZvA24Y_;o?%sX- z{&_XOQ>V^X$GW=u%ydut_~7|`!;Qh0eh+{FJij0S-~j*GUdKJq{~@CT0G*IA6hwS} zd3pJ#mJej$3n4!U`9mlmnUxcopkBD)O%PNZG%PGc^`#mJ?Fj`mfXo^~C_Vzl7Ai3Q z2}benWPB_v73{0W?DTZ&?4|;`{#^9svl+3+@e|31t`_;`?v<>i}p#1#AbT z2LLu8qz$kIzybhb`j&>t`h?Kt@hNbmRH%S*s8@yNzr6qe6EcQ0VE{SL-vJch5-R=> z?j0Ba4LD3B*J-`wRXJ2La>Jf!L_05CtIMzd^4_3H>_+4Z!<%2mrwNpAgpngb@EHgz&G- z{wDDn@jsLO7liPihJy$cP=NSD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M3cO+j$8;oIL0~fX0f7-b00ia%38`p z!8#ECSs^PIPZxKv^#n^3^Qs{HBSFyd-(IhQIbn((Q|z+tj(mSP`2TVU0EA!=Og@-G z!^o~>ZR>1p?(X<{9 From 6aae7649203a680e798c4b44a2bf1333920d5418 Mon Sep 17 00:00:00 2001 From: Mewes Kochheim Date: Sun, 28 May 2017 22:20:14 +0200 Subject: [PATCH 07/31] Use default values when writing validation in Xls Fixes the PHP 7.1 bug reported over at PHPOffice/PHPExcel#1110 The behavior should not change since the default value used should behave the same way as the string value in earlier PHP versions. Fixes a return type in the doc block of IReader. Closes #165 --- src/PhpSpreadsheet/Reader/IReader.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 3d4bfa99..7ef8d48b 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -42,7 +42,7 @@ interface IReader * * @throws Exception * - * @return Spreadsheet + * @return \PhpOffice\PhpSpreadsheet\Spreadsheet */ public function load($pFilename); } diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 3e02af33..939b0f50 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2791,6 +2791,8 @@ class Worksheet extends BIFFwriter /** * Store the DATAVALIDATIONS and DATAVALIDATION records. + * + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ private function writeDataValidity() { @@ -2823,8 +2825,8 @@ class Worksheet extends BIFFwriter $options = 0x00000000; // data type - $type = $dataValidation->getType(); - switch ($type) { + $type = 0x00; + switch ($dataValidation->getType()) { case DataValidation::TYPE_NONE: $type = 0x00; break; @@ -2854,8 +2856,8 @@ class Worksheet extends BIFFwriter $options |= $type << 0; // error style - $errorStyle = $dataValidation->getErrorStyle(); - switch ($errorStyle) { + $errorStyle = 0x00; + switch ($dataValidation->getErrorStyle()) { case DataValidation::STYLE_STOP: $errorStyle = 0x00; break; @@ -2887,8 +2889,8 @@ class Worksheet extends BIFFwriter $options |= $dataValidation->getShowErrorMessage() << 19; // condition operator - $operator = $dataValidation->getOperator(); - switch ($operator) { + $operator = 0x00; + switch ($dataValidation->getOperator()) { case DataValidation::OPERATOR_BETWEEN: $operator = 0x00; break; From 2a6ab1776c8f31bcb84d2354be0c60d1b70b74a5 Mon Sep 17 00:00:00 2001 From: Kifni Taufik Darmawan Date: Fri, 16 Jun 2017 14:36:27 +0700 Subject: [PATCH 08/31] HTML reader supports text and background color from inline CSS, for `td` and `th` element Closes #180 --- CHANGELOG.md | 1 + docs/references/features-cross-reference.md | 2 +- samples/46_ReadHtml.php | 19 +++ samples/templates/46readHtml.html | 130 ++++++++++++++++++++ src/PhpSpreadsheet/Reader/Html.php | 55 +++++++++ 5 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 samples/46_ReadHtml.php create mode 100644 samples/templates/46readHtml.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 30c28392..a2da4900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Additional codepages - MemoryDrawing not working in HTML writer [#808](https://github.com/PHPOffice/PHPExcel/issues/808) - CSV Reader can auto-detect the separator used in file [#141](https://github.com/PHPOffice/PhpSpreadsheet/pull/141) +- HTML Reader supports some basic inline styles [#180](https://github.com/PHPOffice/PhpSpreadsheet/pull/180) ### Changed diff --git a/docs/references/features-cross-reference.md b/docs/references/features-cross-reference.md index a1b1e012..7ab9d068 100644 --- a/docs/references/features-cross-reference.md +++ b/docs/references/features-cross-reference.md @@ -906,7 +906,7 @@

- + diff --git a/samples/46_ReadHtml.php b/samples/46_ReadHtml.php new file mode 100644 index 00000000..838d2868 --- /dev/null +++ b/samples/46_ReadHtml.php @@ -0,0 +1,19 @@ +load($html); + +$helper->logRead('Html', $html, $callStartTime); + +// Save +$helper->write($objPHPExcel, __FILE__); diff --git a/samples/templates/46readHtml.html b/samples/templates/46readHtml.html new file mode 100644 index 00000000..56f745dd --- /dev/null +++ b/samples/templates/46readHtml.html @@ -0,0 +1,130 @@ + + + + + + Competency List + + +
Readers
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Color NameHEXColor
Black#000000 
Blue#0000FF 
Green#008000 
Cyan#00FFFF 
Purple#800080 
Grey#808080 
SkyBlue#87CEEB 
Brown#A52A2A 
Silver#C0C0C0 
Chocolate#D2691E 
Tan#D2B48C 
Violet#EE82EE 
Red#FF0000 
Pink#FFC0CB 
Gold#FFD700 
Yellow#FFFF00 
LightYellow#FFFFE0 
White#FFFFFF 
+ + diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 4db753b5..f77ef7a8 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -442,6 +442,9 @@ class Html extends BaseReader implements IReader case 'td': $this->processDomElement($child, $sheet, $row, $column, $cellContent); + // apply inline style + $this->applyInlineStyle($sheet, $row, $column, $attributeArray); + while (isset($this->rowspan[$column . $row])) { ++$column; } @@ -584,4 +587,56 @@ class Html extends BaseReader implements IReader return $xml; } + + /** + * Apply inline css inline style. + * + * NOTES : + * Currently only intended for td & th element, + * and only takes 'background-color' and 'color'; property with HEX color + * + * TODO : + * - Implement to other propertie, such as border + * + * @param Worksheet $sheet + * @param array $attributeArray + * @param int $row + * @param string $column + */ + private function applyInlineStyle(&$sheet, $row, $column, $attributeArray) + { + if (!isset($attributeArray['style'])) { + return; + } + + $supported_styles = ['background-color', 'color']; + + // add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color + $styles = explode(';', $attributeArray['style']); + foreach ($styles as $st) { + $value = explode(':', $st); + + if (empty(trim($value[0])) || !in_array(trim($value[0]), $supported_styles)) { + continue; + } + + //check if has #, so we can get clean hex + if (substr(trim($value[1]), 0, 1) == '#') { + $style_color = substr(trim($value[1]), 1); + } + + if (empty($style_color)) { + continue; + } + + switch (trim($value[0])) { + case 'background-color': + $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['type' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); + break; + case 'color': + $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]); + break; + } + } + } } From fb12e82d62df6adf8efb734e799a250c0aada70a Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Fri, 14 Jul 2017 10:06:04 +0200 Subject: [PATCH 09/31] Drop HHVM support Because HHVM usage is very low (https://seld.be/notes/php-versions-stats-2017-1-edition) and because we don't have the necessary resources to properly support it, we drop all support for HHVM --- .travis.yml | 3 --- CHANGELOG.md | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 67bf8db2..0dd8db1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,14 +6,11 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm matrix: include: - php: 7.0 env: COVERAGE=1 - allow_failures: - - php: hhvm cache: directories: diff --git a/CHANGELOG.md b/CHANGELOG.md index a2da4900..8f2e317c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ For a comprehensive list of all class changes, and a semi-automated migration pa - Dropped `PHPExcel_Calculation_Functions::VERSION()`. Composer or git should be used to know the version. - Dropped `PHPExcel_Settings::setPdfRenderer()` and `PHPExcel_Settings::setPdfRenderer()`. Composer should be used to autoload PDF libs. +- Dropped support for HHVM ## Previous versions of PHPExcel From 1853aaac793e704a7d42cb36a12fdb9229f77db6 Mon Sep 17 00:00:00 2001 From: Mikkel Paulson Date: Fri, 14 Jul 2017 04:53:13 -0400 Subject: [PATCH 10/31] Add option to suppress validation of sheet titles (#186) Add option to suppress validation of sheet titles Based on a "lowest common denominator" approach to compatibility, we will continue to enforce a 31-character limit for sheet titles. However, this limit should not be enforced when loading an existing file. Added a new optional parameter to Worksheet::setTitle() and Worksheet::setCodeName() to suppress validation and massaging, based on the premise that existing files should be given a best-effort approach to loading and parsing. Unfortunately, it's not possible with the current architecture to prevent users from making use of this functionality, aside from with a strongly-worded warning. Added test coverage. I didn't see any existing unit tests of the Worksheet class, so I created a new test to cover these methods. Fixes #176 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Gnumeric.php | 2 +- src/PhpSpreadsheet/Reader/Html.php | 2 +- src/PhpSpreadsheet/Reader/Ods.php | 2 +- src/PhpSpreadsheet/Reader/Xls.php | 2 +- src/PhpSpreadsheet/Reader/Xlsx.php | 4 +- src/PhpSpreadsheet/Reader/Xml.php | 2 +- src/PhpSpreadsheet/Worksheet.php | 116 +++++++++--------- tests/PhpSpreadsheetTests/WorksheetTest.php | 126 ++++++++++++++++++++ 9 files changed, 195 insertions(+), 62 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/WorksheetTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2e317c..1a1f8773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix to getCell() method when cell reference includes a worksheet reference - @MarkBaker - Ignore inlineStr type if formula element exists - @ncrypthic [#570](https://github.com/PHPOffice/PHPExcel/issues/570) - Excel 2007 Reader freezes because of conditional formatting - @rentalhost [#575](https://github.com/PHPOffice/PHPExcel/issues/575) +- Readers will now parse files containing worksheet titles over 31 characters [#176](https://github.com/PHPOffice/PhpSpreadsheet/pull/176) ### General diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 313fcf00..e1bef14f 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -351,7 +351,7 @@ class Gnumeric extends BaseReader implements IReader // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet // name in line with the formula, not the reverse - $spreadsheet->getActiveSheet()->setTitle($worksheetName, false); + $spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) { if (isset($sheet->PrintInformation->Margins)) { diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index f77ef7a8..67dfa184 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -317,7 +317,7 @@ class Html extends BaseReader implements IReader break; case 'title': $this->processDomElement($child, $sheet, $row, $column, $cellContent); - $sheet->setTitle($cellContent); + $sheet->setTitle($cellContent, true, false); $cellContent = ''; break; case 'span': diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index e82d2d4e..d454a86d 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -440,7 +440,7 @@ class Ods extends BaseReader implements IReader // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // formula cells... during the load, all formulae should be correct, and we're simply // bringing the worksheet name in line with the formula, not the reverse - $spreadsheet->getActiveSheet()->setTitle($worksheetName, false); + $spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); } // Go through every child of table element diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index a7fe48e4..45798fbe 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -808,7 +808,7 @@ class Xls extends BaseReader implements IReader // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet // name in line with the formula, not the reverse - $this->phpSheet->setTitle($sheet['name'], false); + $this->phpSheet->setTitle($sheet['name'], false, false); $this->phpSheet->setSheetState($sheet['sheetState']); $this->pos = $sheet['offset']; diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 3d39016d..57af0a58 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -697,7 +697,7 @@ class Xlsx extends BaseReader implements IReader // references in formula cells... during the load, all formulae should be correct, // and we're simply bringing the worksheet name in line with the formula, not the // reverse - $docSheet->setTitle((string) $eleSheet['name'], false); + $docSheet->setTitle((string) $eleSheet['name'], false, false); $fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')]; $xmlSheet = simplexml_load_string( //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" @@ -766,7 +766,7 @@ class Xlsx extends BaseReader implements IReader } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) { - $docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName']); + $docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName'], false); } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index d7aff065..7c445fee 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -552,7 +552,7 @@ class Xml extends BaseReader implements IReader // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // formula cells... during the load, all formulae should be correct, and we're simply bringing // the worksheet name in line with the formula, not the reverse - $spreadsheet->getActiveSheet()->setTitle($worksheetName, false); + $spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false); } $columnID = 'A'; diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index b2278e7d..8cca3606 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -825,52 +825,54 @@ class Worksheet implements IComparable * Set title. * * @param string $pValue String containing the dimension of this worksheet - * @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should + * @param bool $updateFormulaCellReferences Flag indicating whether cell references in formulae should * be updated to reflect the new sheet name. * This should be left as the default true, unless you are * certain that no formula cells on any worksheet contain * references to this worksheet + * @param bool $validate False to skip validation of new title. WARNING: This should only be set + * at parse time (by Readers), where titles can be assumed to be valid. * * @return Worksheet */ - public function setTitle($pValue, $updateFormulaCellReferences = true) + public function setTitle($pValue, $updateFormulaCellReferences = true, $validate = true) { // Is this a 'rename' or not? if ($this->getTitle() == $pValue) { return $this; } - // Syntax check - self::checkSheetTitle($pValue); - // Old title $oldTitle = $this->getTitle(); - if ($this->parent) { - // Is there already such sheet name? - if ($this->parent->sheetNameExists($pValue)) { - // Use name, but append with lowest possible integer + if ($validate) { + // Syntax check + self::checkSheetTitle($pValue); - if (Shared\StringHelper::countCharacters($pValue) > 29) { - $pValue = Shared\StringHelper::substring($pValue, 0, 29); - } - $i = 1; - while ($this->parent->sheetNameExists($pValue . ' ' . $i)) { - ++$i; - if ($i == 10) { - if (Shared\StringHelper::countCharacters($pValue) > 28) { - $pValue = Shared\StringHelper::substring($pValue, 0, 28); - } - } elseif ($i == 100) { - if (Shared\StringHelper::countCharacters($pValue) > 27) { - $pValue = Shared\StringHelper::substring($pValue, 0, 27); + if ($this->parent) { + // Is there already such sheet name? + if ($this->parent->sheetNameExists($pValue)) { + // Use name, but append with lowest possible integer + + if (Shared\StringHelper::countCharacters($pValue) > 29) { + $pValue = Shared\StringHelper::substring($pValue, 0, 29); + } + $i = 1; + while ($this->parent->sheetNameExists($pValue . ' ' . $i)) { + ++$i; + if ($i == 10) { + if (Shared\StringHelper::countCharacters($pValue) > 28) { + $pValue = Shared\StringHelper::substring($pValue, 0, 28); + } + } elseif ($i == 100) { + if (Shared\StringHelper::countCharacters($pValue) > 27) { + $pValue = Shared\StringHelper::substring($pValue, 0, 27); + } } } + + $pValue .= " $i"; } - - $altTitle = $pValue . ' ' . $i; - - return $this->setTitle($altTitle, $updateFormulaCellReferences); } } @@ -2976,51 +2978,55 @@ class Worksheet implements IComparable /** * Define the code name of the sheet. * - * @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore) - * @param null|mixed $pValue + * @param string $pValue Same rule as Title minus space not allowed (but, like Excel, change + * silently space to underscore) + * @param bool $validate False to skip validation of new title. WARNING: This should only be set + * at parse time (by Readers), where titles can be assumed to be valid. * * @throws Exception * * @return objWorksheet */ - public function setCodeName($pValue) + public function setCodeName($pValue, $validate = true) { // Is this a 'rename' or not? if ($this->getCodeName() == $pValue) { return $this; } - $pValue = str_replace(' ', '_', $pValue); //Excel does this automatically without flinching, we are doing the same - // Syntax check - // throw an exception if not valid - self::checkSheetCodeName($pValue); - // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' + if ($validate) { + $pValue = str_replace(' ', '_', $pValue); //Excel does this automatically without flinching, we are doing the same - if ($this->getParent()) { - // Is there already such sheet name? - if ($this->getParent()->sheetCodeNameExists($pValue)) { - // Use name, but append with lowest possible integer + // Syntax check + // throw an exception if not valid + self::checkSheetCodeName($pValue); - if (Shared\StringHelper::countCharacters($pValue) > 29) { - $pValue = Shared\StringHelper::substring($pValue, 0, 29); - } - $i = 1; - while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) { - ++$i; - if ($i == 10) { - if (Shared\StringHelper::countCharacters($pValue) > 28) { - $pValue = Shared\StringHelper::substring($pValue, 0, 28); - } - } elseif ($i == 100) { - if (Shared\StringHelper::countCharacters($pValue) > 27) { - $pValue = Shared\StringHelper::substring($pValue, 0, 27); + // We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_' + + if ($this->getParent()) { + // Is there already such sheet name? + if ($this->getParent()->sheetCodeNameExists($pValue)) { + // Use name, but append with lowest possible integer + + if (Shared\StringHelper::countCharacters($pValue) > 29) { + $pValue = Shared\StringHelper::substring($pValue, 0, 29); + } + $i = 1; + while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) { + ++$i; + if ($i == 10) { + if (Shared\StringHelper::countCharacters($pValue) > 28) { + $pValue = Shared\StringHelper::substring($pValue, 0, 28); + } + } elseif ($i == 100) { + if (Shared\StringHelper::countCharacters($pValue) > 27) { + $pValue = Shared\StringHelper::substring($pValue, 0, 27); + } } } - } - $pValue = $pValue . '_' . $i; // ok, we have a valid name - //codeName is'nt used in formula : no need to call for an update - //return $this->setTitle($altTitle, $updateFormulaCellReferences); + $pValue = $pValue . '_' . $i; // ok, we have a valid name + } } } diff --git a/tests/PhpSpreadsheetTests/WorksheetTest.php b/tests/PhpSpreadsheetTests/WorksheetTest.php new file mode 100644 index 00000000..1a7389b0 --- /dev/null +++ b/tests/PhpSpreadsheetTests/WorksheetTest.php @@ -0,0 +1,126 @@ +setTitle($testTitle); + $this->assertSame($testTitle, $worksheet->getTitle()); + } + + public function setTitleInvalidProvider() + { + return [ + [str_repeat('a', 32), 'Maximum 31 characters allowed in sheet title.'], + ['invalid*title', 'Invalid character found in sheet title'], + ]; + } + + /** + * @param string $title + * @param string $expectMessage + * @dataProvider setTitleInvalidProvider + */ + public function testSetTitleInvalid($title, $expectMessage) + { + // First, test setting title with validation disabled -- should be successful + $worksheet = new Worksheet(); + $worksheet->setTitle($title, true, false); + + // Next, test again with validation enabled -- this time we should fail + $worksheet = new Worksheet(); + $this->expectException(\Exception::class); + $this->expectExceptionMessage($expectMessage); + $worksheet->setTitle($title); + } + + public function testSetTitleDuplicate() + { + // Create a Spreadsheet with three Worksheets (the first is created automatically) + $spreadsheet = new Spreadsheet(); + $spreadsheet->createSheet(); + $spreadsheet->createSheet(); + + // Set unique title -- should be unchanged + $sheet = $spreadsheet->getSheet(0); + $sheet->setTitle('Test Title'); + $this->assertSame('Test Title', $sheet->getTitle()); + + // Set duplicate title -- should have numeric suffix appended + $sheet = $spreadsheet->getSheet(1); + $sheet->setTitle('Test Title'); + $this->assertSame('Test Title 1', $sheet->getTitle()); + + // Set duplicate title with validation disabled -- should be unchanged + $sheet = $spreadsheet->getSheet(2); + $sheet->setTitle('Test Title', true, false); + $this->assertSame('Test Title', $sheet->getTitle()); + } + + public function testSetCodeName() + { + $testCodeName = str_repeat('a', 31); + + $worksheet = new Worksheet(); + $worksheet->setCodeName($testCodeName); + $this->assertSame($testCodeName, $worksheet->getCodeName()); + } + + public function setCodeNameInvalidProvider() + { + return [ + [str_repeat('a', 32), 'Maximum 31 characters allowed in sheet code name.'], + ['invalid*code*name', 'Invalid character found in sheet code name'], + ]; + } + + /** + * @param string $codeName + * @param string $expectMessage + * @dataProvider setCodeNameInvalidProvider + */ + public function testSetCodeNameInvalid($codeName, $expectMessage) + { + // First, test setting code name with validation disabled -- should be successful + $worksheet = new Worksheet(); + $worksheet->setCodeName($codeName, false); + + // Next, test again with validation enabled -- this time we should fail + $worksheet = new Worksheet(); + $this->expectException(\Exception::class); + $this->expectExceptionMessage($expectMessage); + $worksheet->setCodeName($codeName); + } + + public function testSetCodeNameDuplicate() + { + // Create a Spreadsheet with three Worksheets (the first is created automatically) + $spreadsheet = new Spreadsheet(); + $spreadsheet->createSheet(); + $spreadsheet->createSheet(); + + // Set unique code name -- should be massaged to Snake_Case + $sheet = $spreadsheet->getSheet(0); + $sheet->setCodeName('Test Code Name'); + $this->assertSame('Test_Code_Name', $sheet->getCodeName()); + + // Set duplicate code name -- should be massaged and have numeric suffix appended + $sheet = $spreadsheet->getSheet(1); + $sheet->setCodeName('Test Code Name'); + $this->assertSame('Test_Code_Name_1', $sheet->getCodeName()); + + // Set duplicate code name with validation disabled -- should be unchanged, and unmassaged + $sheet = $spreadsheet->getSheet(2); + $sheet->setCodeName('Test Code Name', false); + $this->assertSame('Test Code Name', $sheet->getCodeName()); + } +} From 0b035713945bd8eeb83f2ea82a9c481c1f1ec9be Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 17 Jul 2017 16:07:17 +0200 Subject: [PATCH 11/31] removed wrong parameter hint (#187) --- src/PhpSpreadsheet/Worksheet.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 8cca3606..32bcf2ca 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -1163,7 +1163,6 @@ class Worksheet implements IComparable * @param int $pRow Numeric row coordinate of the cell * @param mixed $pValue Value of the cell * @param string $pDataType Explicit data type, see Cell\DataType::TYPE_* - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) * * @return Worksheet */ From 54c8e063d285833e408641fd707e22ba30e1bc92 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 20 Jul 2017 16:25:40 +0200 Subject: [PATCH 12/31] Fix wrong return type Closes https://github.com/PHPOffice/PHPExcel/pull/1262 --- src/PhpSpreadsheet/Style/Borders.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index bc599235..5f9f8486 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -78,21 +78,21 @@ class Borders extends Supervisor implements IComparable protected $diagonalDirection; /** - * All borders psedo-border. Only applies to supervisor. + * All borders pseudo-border. Only applies to supervisor. * * @var Border */ protected $allBorders; /** - * Outline psedo-border. Only applies to supervisor. + * Outline pseudo-border. Only applies to supervisor. * * @var Border */ protected $outline; /** - * Inside psedo-border. Only applies to supervisor. + * Inside pseudo-border. Only applies to supervisor. * * @var Border */ @@ -325,7 +325,7 @@ class Borders extends Supervisor implements IComparable * * @throws PhpSpreadsheetException * - * @return bool + * @return Border */ public function getOutline() { @@ -341,7 +341,7 @@ class Borders extends Supervisor implements IComparable * * @throws PhpSpreadsheetException * - * @return bool + * @return Border */ public function getInside() { From ce1e83428b644bfd61b1aa0a6150f143fb3f8156 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 30 Jul 2017 16:22:28 +0200 Subject: [PATCH 13/31] Keep documentation in a single place and link to it Fixes #191 Closes #192 --- CONTRIBUTING.md | 10 ++++++++++ README.md | 35 ++++------------------------------- docs/index.md | 19 +++++++++++++++++++ samples/Header.php | 2 +- samples/index.php | 2 +- 5 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..736a1075 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Want to contribute? + +If you would like to contribute, here are some notes and guidelines: + + - All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code + - The master branch only contains tagged releases + - If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number + - Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`) + - [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository") + - [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests") diff --git a/README.md b/README.md index e4a978c7..3419b4a9 100644 --- a/README.md +++ b/README.md @@ -16,41 +16,14 @@ Develop: PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc. -## File formats supported +## Documentation -|Format |Reading|Writing| -|--------------------------------------------|:-----:|:-----:| -|Open Document Format/OASIS (.ods) | ✓ | ✓ | -|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ | -|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ | -|BIFF 5 (.xls) Excel 95 | ✓ | | -|SpreadsheetML (.xml) Excel 2003 | ✓ | | -|Gnumeric | ✓ | | -|HTML | ✓ | ✓ | -|SYLK | ✓ | | -|CSV | ✓ | ✓ | -|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ | +Read more about it, including install instructions, in the official documentation, either at the online version: -## Requirements +https://phpspreadsheet.readthedocs.io - * PHP version 5.6 or higher - * PHP extension php_zip enabled - * PHP extension php_xml enabled - * PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation) +Or directly in this repository in the folder `docs/`. -## PHP version support - -Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version - -## Want to contribute? - -If you would like to contribute, here are some notes and guidelines: - - All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code - - The master branch only contains tagged releases - - If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number - - Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`) - - [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository") - - [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests") ## PHPExcel vs PhpSpreadsheet ? diff --git a/docs/index.md b/docs/index.md index 30043595..402059b6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,6 +6,21 @@ PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc. +## File formats supported + +|Format |Reading|Writing| +|--------------------------------------------|:-----:|:-----:| +|Open Document Format/OASIS (.ods) | ✓ | ✓ | +|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ | +|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ | +|BIFF 5 (.xls) Excel 95 | ✓ | | +|SpreadsheetML (.xml) Excel 2003 | ✓ | | +|Gnumeric | ✓ | | +|HTML | ✓ | ✓ | +|SYLK | ✓ | | +|CSV | ✓ | ✓ | +|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ | + # Getting started ## Software requirements @@ -17,6 +32,10 @@ The following software is required to develop using PhpSpreadsheet: - PHP extension php\_xml enabled - PHP extension php\_gd2 enabled (if not compiled in) +### PHP version support + +Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version + ## Installation Use [composer](https://getcomposer.org/) to install PhpSpreadsheet into your project: diff --git a/samples/Header.php b/samples/Header.php index e9ada9f7..759ff1a8 100644 --- a/samples/Header.php +++ b/samples/Header.php @@ -54,7 +54,7 @@ if ($helper->isCli()) { diff --git a/samples/index.php b/samples/index.php index 4b7dbe7a..6dc6fd6c 100644 --- a/samples/index.php +++ b/samples/index.php @@ -19,7 +19,7 @@ if (!$helper->isCli()) {

 

Fork us on Github! - Read the Docs + Read the Docs

Date: Thu, 20 Jul 2017 16:25:40 +0200 Subject: [PATCH 14/31] Fix wrong return type Closes https://github.com/PHPOffice/PHPExcel/pull/1262 --- src/PhpSpreadsheet/Style/Borders.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index bc599235..5f9f8486 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -78,21 +78,21 @@ class Borders extends Supervisor implements IComparable protected $diagonalDirection; /** - * All borders psedo-border. Only applies to supervisor. + * All borders pseudo-border. Only applies to supervisor. * * @var Border */ protected $allBorders; /** - * Outline psedo-border. Only applies to supervisor. + * Outline pseudo-border. Only applies to supervisor. * * @var Border */ protected $outline; /** - * Inside psedo-border. Only applies to supervisor. + * Inside pseudo-border. Only applies to supervisor. * * @var Border */ @@ -325,7 +325,7 @@ class Borders extends Supervisor implements IComparable * * @throws PhpSpreadsheetException * - * @return bool + * @return Border */ public function getOutline() { @@ -341,7 +341,7 @@ class Borders extends Supervisor implements IComparable * * @throws PhpSpreadsheetException * - * @return bool + * @return Border */ public function getInside() { From 2e59885895a7e3e78bb76b0f97d35888c8823a3d Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 30 Jul 2017 16:22:28 +0200 Subject: [PATCH 15/31] Keep documentation in a single place and link to it Fixes #191 Closes #192 --- CONTRIBUTING.md | 10 ++++++++++ README.md | 35 ++++------------------------------- docs/index.md | 19 +++++++++++++++++++ samples/Header.php | 2 +- samples/index.php | 2 +- 5 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..736a1075 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Want to contribute? + +If you would like to contribute, here are some notes and guidelines: + + - All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code + - The master branch only contains tagged releases + - If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number + - Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`) + - [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository") + - [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests") diff --git a/README.md b/README.md index e4a978c7..3419b4a9 100644 --- a/README.md +++ b/README.md @@ -16,41 +16,14 @@ Develop: PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc. -## File formats supported +## Documentation -|Format |Reading|Writing| -|--------------------------------------------|:-----:|:-----:| -|Open Document Format/OASIS (.ods) | ✓ | ✓ | -|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ | -|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ | -|BIFF 5 (.xls) Excel 95 | ✓ | | -|SpreadsheetML (.xml) Excel 2003 | ✓ | | -|Gnumeric | ✓ | | -|HTML | ✓ | ✓ | -|SYLK | ✓ | | -|CSV | ✓ | ✓ | -|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ | +Read more about it, including install instructions, in the official documentation, either at the online version: -## Requirements +https://phpspreadsheet.readthedocs.io - * PHP version 5.6 or higher - * PHP extension php_zip enabled - * PHP extension php_xml enabled - * PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation) +Or directly in this repository in the folder `docs/`. -## PHP version support - -Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version - -## Want to contribute? - -If you would like to contribute, here are some notes and guidelines: - - All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code - - The master branch only contains tagged releases - - If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number - - Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`) - - [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository") - - [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests") ## PHPExcel vs PhpSpreadsheet ? diff --git a/docs/index.md b/docs/index.md index 30043595..402059b6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,6 +6,21 @@ PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc. +## File formats supported + +|Format |Reading|Writing| +|--------------------------------------------|:-----:|:-----:| +|Open Document Format/OASIS (.ods) | ✓ | ✓ | +|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ | +|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ | +|BIFF 5 (.xls) Excel 95 | ✓ | | +|SpreadsheetML (.xml) Excel 2003 | ✓ | | +|Gnumeric | ✓ | | +|HTML | ✓ | ✓ | +|SYLK | ✓ | | +|CSV | ✓ | ✓ | +|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ | + # Getting started ## Software requirements @@ -17,6 +32,10 @@ The following software is required to develop using PhpSpreadsheet: - PHP extension php\_xml enabled - PHP extension php\_gd2 enabled (if not compiled in) +### PHP version support + +Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version + ## Installation Use [composer](https://getcomposer.org/) to install PhpSpreadsheet into your project: diff --git a/samples/Header.php b/samples/Header.php index e9ada9f7..759ff1a8 100644 --- a/samples/Header.php +++ b/samples/Header.php @@ -54,7 +54,7 @@ if ($helper->isCli()) { diff --git a/samples/index.php b/samples/index.php index 4b7dbe7a..6dc6fd6c 100644 --- a/samples/index.php +++ b/samples/index.php @@ -19,7 +19,7 @@ if (!$helper->isCli()) {

 

Fork us on Github! - Read the Docs + Read the Docs

Date: Sun, 30 Jul 2017 22:25:24 +0200 Subject: [PATCH 16/31] Clarify documentation about `DateTime` Closes #164 --- docs/topics/calculation-engine.md | 140 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index 1480e13f..94fa3a10 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -90,7 +90,7 @@ calculated values, or force recalculation in Excel2003. ### Excel functions that return a Date and Time value Any of the Date and Time functions that return a date value in Excel can -return either an Excel timestamp or a PHP timestamp or date object. +return either an Excel timestamp or a PHP timestamp or `DateTime` object. It is possible for scripts to change the data type used for returning date values by calling the @@ -103,9 +103,9 @@ method: where the following constants can be used for `$returnDateType`: -- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC` -- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_OBJECT` -- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL` +- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC` +- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_OBJECT` +- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL` The method will return a Boolean True on success, False on failure (e.g. if an invalid value is passed in for the return date type). @@ -117,11 +117,11 @@ method can be used to determine the current value of this setting: $returnDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(); ``` -The default is RETURNDATE\_PHP\_NUMERIC. +The default is `RETURNDATE_PHP_NUMERIC`. #### PHP Timestamps -If RETURNDATE\_PHP\_NUMERIC is set for the Return Date Type, then any +If `RETURNDATE_PHP_NUMERIC` is set for the Return Date Type, then any date value returned to the calling script by any access to the Date and Time functions in Excel will be an integer value that represents the number of seconds from the PHP/Unix base date. The PHP/Unix base date @@ -131,15 +131,15 @@ while a value of +3600 would be 01:00 hrs on 1st January 1970. This gives PHP a date range of between 14th December 1901 and 19th January 2038. -#### PHP DateTime Objects +#### PHP `DateTime` Objects -If the Return Date Type is set for RETURNDATE\_PHP\_NUMERIC, then any +If the Return Date Type is set for `RETURNDATE_PHP_OBJECT`, then any date value returned to the calling script by any access to the Date and -Time functions in Excel will be a PHP date/time object. +Time functions in Excel will be a PHP `DateTime` object. #### Excel Timestamps -If RETURNDATE\_EXCEL is set for the Return Date Type, then the returned +If `RETURNDATE_EXCEL` is set for the Return Date Type, then the returned date value by any access to the Date and Time functions in Excel will be a floating point value that represents a number of days from the Excel base date. The Excel base date is determined by which calendar Excel @@ -157,8 +157,8 @@ Excel date values by calling the where the following constants can be used for `$baseDate`: -- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_WINDOWS\_1900 -- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_MAC\_1904 +- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900` +- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904` The method will return a Boolean True on success, False on failure (e.g. if an invalid value is passed in). @@ -170,31 +170,31 @@ be used to determine the current value of this setting: $baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); ``` -The default is CALENDAR\_WINDOWS\_1900. +The default is `CALENDAR_WINDOWS_1900`. #### Functions that return a Date/Time Value -- DATE -- DATEVALUE -- EDATE -- EOMONTH -- NOW -- TIME -- TIMEVALUE -- TODAY +- DATE +- DATEVALUE +- EDATE +- EOMONTH +- NOW +- TIME +- TIMEVALUE +- TODAY ### Excel functions that accept Date and Time values as parameters Date values passed in as parameters to a function can be an Excel -timestamp or a PHP timestamp; or date object; or a string containing a +timestamp or a PHP timestamp; or `DateTime` object; or a string containing a date value (e.g. '1-Jan-2009'). PhpSpreadsheet will attempt to identify their type based on the PHP datatype: An integer numeric value will be treated as a PHP/Unix timestamp. A real (floating point) numeric value will be treated as an Excel -date/timestamp. Any PHP DateTime object will be treated as a DateTime +date/timestamp. Any PHP `DateTime` object will be treated as a `DateTime` object. Any string value (even one containing straight numeric data) -will be converted to a date/time object for validation as a date value +will be converted to a `DateTime` object for validation as a date value based on the server locale settings, so passing through an ambiguous value of '07/08/2008' will be treated as 7th August 2008 if your server settings are UK, but as 8th July 2008 if your server settings are US. @@ -202,7 +202,7 @@ However, if you pass through a value such as '31/12/2008' that would be considered an error by a US-based server, but which is not ambiguous, then PhpSpreadsheet will attempt to correct this to 31st December 2008. If the content of the string doesn’t match any of the formats recognised -by the php date/time object implementation of `strtotime()` (which can +by the php `DateTime` object implementation of `strtotime()` (which can handle a wider range of formats than the normal `strtotime()` function), then the function will return a `#VALUE` error. However, Excel recommends that you should always use date/timestamps for your date @@ -213,28 +213,28 @@ The same principle applies when data is being written to Excel. Cells containing date actual values (rather than Excel functions that return a date value) are always written as Excel dates, converting where necessary. If a cell formatted as a date contains an integer or -date/time object value, then it is converted to an Excel value for +`DateTime` object value, then it is converted to an Excel value for writing: if a cell formatted as a date contains a real value, then no conversion is required. Note that string values are written as strings rather than converted to Excel date timestamp values. #### Functions that expect a Date/Time Value -- DATEDIF -- DAY -- DAYS360 -- EDATE -- EOMONTH -- HOUR -- MINUTE -- MONTH -- NETWORKDAYS -- SECOND -- WEEKDAY -- WEEKNUM -- WORKDAY -- YEAR -- YEARFRAC +- DATEDIF +- DAY +- DAYS360 +- EDATE +- EOMONTH +- HOUR +- MINUTE +- MONTH +- NETWORKDAYS +- SECOND +- WEEKDAY +- WEEKNUM +- WORKDAY +- YEAR +- YEARFRAC ### Helper Methods @@ -243,7 +243,7 @@ number of other methods are available in the \PhpOffice\PhpSpreadsheet\Shared\Date class that can help when working with dates: -#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHP($excelDate) +#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDate) Converts a date/time from an Excel date timestamp to return a PHP serialized date/timestamp. @@ -251,17 +251,17 @@ serialized date/timestamp. Note that this method does not trap for Excel dates that fall outside of the valid range for a PHP date timestamp. -#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHPObject($excelDate) +#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDate) -Converts a date from an Excel date/timestamp to return a PHP DateTime +Converts a date from an Excel date/timestamp to return a PHP `DateTime` object. #### \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDate) -Converts a PHP serialized date/timestamp or a PHP DateTime object to +Converts a PHP serialized date/timestamp or a PHP `DateTime` object to return an Excel date timestamp. -#### \PhpOffice\PhpSpreadsheet\Shared\Date::FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) +#### \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) Takes year, month and day values (and optional hour, minute and second values) and returns an Excel date timestamp value. @@ -979,7 +979,7 @@ Excel and in PHP. #### DATE -The DATE function returns an Excel timestamp or a PHP timestamp or date +The DATE function returns an Excel timestamp or a PHP timestamp or `DateTime` object representing the date that is referenced by the parameters. ##### Syntax @@ -1025,7 +1025,7 @@ February 27, 2008. **mixed** A date/time stamp that corresponds to the given date. -This could be a PHP timestamp value (integer), a PHP date/time object, +This could be a PHP timestamp value (integer), a PHP `DateTime` object, or an Excel timestamp value (real), depending on the value of \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(). @@ -1093,12 +1093,12 @@ variety of different intervals, such number of years, months, or days. **date1** First Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **date2** Second Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **unit** The interval type to use for the calculation @@ -1230,7 +1230,7 @@ A string, representing a date value. **mixed** A date/time stamp that corresponds to the given date. -This could be a PHP timestamp value (integer), a PHP date/time object, +This could be a PHP timestamp value (integer), a PHP `DateTime` object, or an Excel timestamp value (real), depending on the value of \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(). @@ -1290,7 +1290,7 @@ $retVal = call_user_func_array( ##### Notes -DATEVALUE uses the php date/time object implementation of `strtotime()` +DATEVALUE uses the php `DateTime` object implementation of `strtotime()` (which can handle a wider range of formats than the normal `strtotime()` function), and it is also called for any date parameter passed to other date functions (such as DATEDIF) when the parameter value is a string. @@ -1317,7 +1317,7 @@ integer ranging from 1 to 31. **datetime** Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. ##### Return Value @@ -1371,12 +1371,12 @@ accounting systems. **date1** First Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **date2** Second Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **method** A boolean flag (TRUE or FALSE) @@ -1453,7 +1453,7 @@ Excel `TRUE()` and `FALSE()` functions are used instead. #### EDATE -The EDATE function returns an Excel timestamp or a PHP timestamp or date +The EDATE function returns an Excel timestamp or a PHP timestamp or `DateTime` object representing the date that is the indicated number of months before or after a specified date (the start\_date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the @@ -1467,7 +1467,7 @@ month as the date of issue. **baseDate** Start Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **months** Number of months to add. @@ -1480,7 +1480,7 @@ value yields a past date. **mixed** A date/time stamp that corresponds to the basedate + months. -This could be a PHP timestamp value (integer), a PHP date/time object, +This could be a PHP timestamp value (integer), a PHP `DateTime` object, or an Excel timestamp value (real), depending on the value of \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(). @@ -1526,7 +1526,7 @@ the Analysis ToolPak. #### EOMONTH The EOMONTH function returns an Excel timestamp or a PHP timestamp or -date object representing the date of the last day of the month that is +`DateTime` object representing the date of the last day of the month that is the indicated number of months before or after a specified date (the start\_date). Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. @@ -1539,7 +1539,7 @@ fall on the last day of the month. **baseDate** Start Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **months** Number of months to add. @@ -1553,7 +1553,7 @@ value yields a past date. **mixed** A date/time stamp that corresponds to the last day of basedate + months. -This could be a PHP timestamp value (integer), a PHP date/time object, +This could be a PHP timestamp value (integer), a PHP `DateTime` object, or an Excel timestamp value (real), depending on the value of \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(). @@ -1607,7 +1607,7 @@ an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). **datetime** Time. -An Excel date/time value, PHP date timestamp, PHP date object, or a +An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a date/time represented as a string. ##### Return Value @@ -1665,7 +1665,7 @@ given as an integer, ranging from 0 to 59. **datetime** Time. -An Excel date/time value, PHP date timestamp, PHP date object, or a +An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a date/time represented as a string. ##### Return Value @@ -1723,7 +1723,7 @@ integer ranging from 1 to 12. **datetime** Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. ##### Return Value @@ -1779,12 +1779,12 @@ a specific term. **startDate** Start Date of the period. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **endDate** End Date of the period. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **holidays** Optional array of Holiday dates. @@ -1831,7 +1831,7 @@ There are no parameters for the `NOW()` function. **mixed** A date/time stamp that corresponds to the current date and time. -This could be a PHP timestamp value (integer), a PHP date/time object, +This could be a PHP timestamp value (integer), a PHP `DateTime` object, or an Excel timestamp value (real), depending on the value of \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType(). @@ -1862,7 +1862,7 @@ given as an integer, ranging from 0 to 59. **datetime** Time. -An Excel date/time value, PHP date timestamp, PHP date object, or a +An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a date/time represented as a string. ##### Return Value @@ -1934,7 +1934,7 @@ modified to return a value between 0 and 6. **datetime** Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. **method** An integer flag (values 0, 1 or 2) @@ -2012,7 +2012,7 @@ The YEAR function returns the year of a date. **datetime** Date. -An Excel date value, PHP date timestamp, PHP date object, or a date +An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date represented as a string. ##### Return Value From 31daed0048f2004628038771af1055fbf69ab767 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 2 Aug 2017 23:13:08 +0200 Subject: [PATCH 17/31] Fix class name case --- tests/PhpSpreadsheetTests/Reader/HTMLTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/PhpSpreadsheetTests/Reader/HTMLTest.php b/tests/PhpSpreadsheetTests/Reader/HTMLTest.php index b1b51a59..ca85be9c 100644 --- a/tests/PhpSpreadsheetTests/Reader/HTMLTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HTMLTest.php @@ -10,11 +10,7 @@ class HTMLTest extends PHPUnit_Framework_TestCase public function testCsvWithAngleBracket() { $filename = __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv'; - $this->assertFalse($this->getInstance()->canRead($filename)); - } - - private function getInstance() - { - return new HTML(); + $reader = new Html(); + $this->assertFalse($reader->canRead($filename)); } } From 4a47a3295392c13863fe4a4813507b8016f12010 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 3 Aug 2017 12:03:24 +0200 Subject: [PATCH 18/31] Code style partially according to Scrutinizer --- .../Calculations/Database/DAVERAGE.php | 101 ++++++----- .../Examples/Calculations/Database/DCOUNT.php | 101 ++++++----- docs/Examples/Calculations/Database/DGET.php | 95 +++++------ docs/Examples/Calculations/Database/DMAX.php | 99 ++++++----- docs/Examples/Calculations/Database/DMIN.php | 99 ++++++----- .../Calculations/Database/DPRODUCT.php | 95 +++++------ .../Examples/Calculations/Database/DSTDEV.php | 101 ++++++----- .../Calculations/Database/DSTDEVP.php | 101 ++++++----- docs/Examples/Calculations/Database/DVAR.php | 101 ++++++----- docs/Examples/Calculations/Database/DVARP.php | 101 ++++++----- docs/Examples/Calculations/DateTime/DATE.php | 116 +++++++------ .../Calculations/DateTime/DATEVALUE.php | 102 ++++++----- docs/Examples/Calculations/DateTime/TIME.php | 112 ++++++------- .../Calculations/DateTime/TIMEVALUE.php | 94 +++++------ docs/Examples/Calculations/index.php | 54 +++--- docs/Examples/Reader/exampleReader01.php | 37 ++-- docs/Examples/Reader/exampleReader02.php | 43 ++--- docs/Examples/Reader/exampleReader03.php | 47 +++--- docs/Examples/Reader/exampleReader04.php | 43 +++-- docs/Examples/Reader/exampleReader05.php | 49 +++--- docs/Examples/Reader/exampleReader06.php | 55 +++--- docs/Examples/Reader/exampleReader07.php | 57 +++---- docs/Examples/Reader/exampleReader08.php | 57 +++---- docs/Examples/Reader/exampleReader09.php | 80 ++++----- docs/Examples/Reader/exampleReader10.php | 101 ++++++----- docs/Examples/Reader/exampleReader11.php | 122 +++++++------- docs/Examples/Reader/exampleReader12.php | 126 +++++++------- docs/Examples/Reader/exampleReader13.php | 71 ++++---- docs/Examples/Reader/exampleReader14.php | 158 +++++++++--------- docs/Examples/Reader/exampleReader15.php | 93 +++++------ docs/Examples/Reader/exampleReader16.php | 45 +++-- docs/Examples/Reader/exampleReader17.php | 51 +++--- docs/Examples/Reader/exampleReader18.php | 51 +++--- docs/Examples/Reader/exampleReader19.php | 57 +++---- .../exampleWorkBookReader01.php | 117 +++++++------ .../exampleWorkBookReader02.php | 51 +++--- .../exampleWorkBookReader03.php | 103 ++++++------ .../exampleWorkBookReader04.php | 59 ++++--- docs/Examples/index.php | 54 +++--- src/PhpSpreadsheet/Calculation.php | 3 - .../Shared/JAMA/EigenvalueDecomposition.php | 2 +- .../JAMA/SingularValueDecomposition.php | 2 - src/PhpSpreadsheet/Writer/Xls/Font.php | 10 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 16 +- src/PhpSpreadsheet/Writer/Xlsx.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 2 - 46 files changed, 1532 insertions(+), 1706 deletions(-) diff --git a/docs/Examples/Calculations/Database/DAVERAGE.php b/docs/Examples/Calculations/Database/DAVERAGE.php index c2d31a6a..be87d3ef 100644 --- a/docs/Examples/Calculations/Database/DAVERAGE.php +++ b/docs/Examples/Calculations/Database/DAVERAGE.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DAVERAGE

-

Returns the average of selected database entries.

-DAVERAGE +

Returns the average of selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$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 '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index d7bf2045..4387d8fa 100644 --- a/docs/Examples/Calculations/Database/DCOUNT.php +++ b/docs/Examples/Calculations/Database/DCOUNT.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DCOUNT

-

Counts the cells that contain numbers in a database.

-DCOUNT +

Counts the cells that contain numbers in a database.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard'); -$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 819120cb..59dd9529 100644 --- a/docs/Examples/Calculations/Database/DGET.php +++ b/docs/Examples/Calculations/Database/DGET.php @@ -6,72 +6,69 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DGET

-

Extracts a single value from a column of a list or database that matches conditions that you specify.

-DGET +

Extracts a single value from a column of a list or database that matches conditions that you specify.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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)'); -$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 '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + echo 'ALL' . '

'; -echo 'ALL' . '

'; + echo $worksheet->getCell('A12')->getValue() . '
'; + echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; -echo $worksheet->getCell('A12')->getValue() . '
'; -echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 4fe13da6..bc0af306 100644 --- a/docs/Examples/Calculations/Database/DMAX.php +++ b/docs/Examples/Calculations/Database/DMAX.php @@ -6,75 +6,72 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DMAX

-

Returns the maximum value from selected database entries.

-DMAX +

Returns the maximum value from selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard'); -$worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + echo 'ALL' . '

'; -echo 'ALL' . '

'; + echo $worksheet->getCell('A12')->getValue() . '
'; + echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; -echo $worksheet->getCell('A12')->getValue() . '
'; -echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index b765c061..9f36786a 100644 --- a/docs/Examples/Calculations/Database/DMIN.php +++ b/docs/Examples/Calculations/Database/DMIN.php @@ -6,75 +6,72 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DMIN

-

Returns the minimum value from selected database entries.

-DMIN +

Returns the minimum value from selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard'); -$worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + echo 'ALL' . '

'; -echo 'ALL' . '

'; + echo $worksheet->getCell('A12')->getValue() . '
'; + echo 'DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; -echo $worksheet->getCell('A12')->getValue() . '
'; -echo 'DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 4cf234d3..92efcf08 100644 --- a/docs/Examples/Calculations/Database/DPRODUCT.php +++ b/docs/Examples/Calculations/Database/DPRODUCT.php @@ -6,72 +6,69 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DPRODUCT

-

Multiplies the values in a column of a list or database that match conditions that you specify.

-DPRODUCT +

Multiplies the values in a column of a list or database that match conditions that you specify.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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)'); -$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 '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + echo 'ALL' . '

'; -echo 'ALL' . '

'; + echo $worksheet->getCell('A12')->getValue() . '
'; + echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; -echo $worksheet->getCell('A12')->getValue() . '
'; -echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 8aeaf2d8..8eaf133e 100644 --- a/docs/Examples/Calculations/Database/DSTDEV.php +++ b/docs/Examples/Calculations/Database/DSTDEV.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DSTDEV

-

Estimates the standard deviation based on a sample of selected database entries.

-DSTDEV +

Estimates the standard deviation based on a sample of selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$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 '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 0a562c65..ea9a5345 100644 --- a/docs/Examples/Calculations/Database/DSTDEVP.php +++ b/docs/Examples/Calculations/Database/DSTDEVP.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DSTDEVP

-

Calculates the standard deviation based on the entire population of selected database entries.

-DSTDEVP +

Calculates the standard deviation based on the entire population of selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees'); -$worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index b49020bf..2349845e 100644 --- a/docs/Examples/Calculations/Database/DVAR.php +++ b/docs/Examples/Calculations/Database/DVAR.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DVAR

-

Estimates variance based on a sample from selected database entries.

-DVAR +

Estimates variance based on a sample from selected database entries.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees'); -$worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 83d06fba..a9b053a5 100644 --- a/docs/Examples/Calculations/Database/DVARP.php +++ b/docs/Examples/Calculations/Database/DVARP.php @@ -6,76 +6,73 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DVARP

-

Calculates variance based on the entire population of selected database entries,

-DVARP +

Calculates variance based on the entire population of selected database entries,

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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], + ]; -// 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->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('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)'); -$worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees'); -$worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)'); + echo '
'; -echo '
'; + echo '

Database

'; -echo '

Database

'; + $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); + var_dump($databaseData); -$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true); -var_dump($databaseData); + echo '
'; -echo '
'; + // Test the formulae + echo '

Criteria

'; -// Test the formulae -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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 $worksheet->getCell('A12')->getValue() . '
'; -echo 'DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '

'; + echo '

Criteria

'; -echo '

Criteria

'; + $criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true); + var_dump($criteriaData); -$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(); - -?> - + 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 index 5b0a8717..33330c97 100644 --- a/docs/Examples/Calculations/DateTime/DATE.php +++ b/docs/Examples/Calculations/DateTime/DATE.php @@ -6,74 +6,72 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DATE

-

Returns the serial number of a particular date.

-DATE +

Returns the serial number of a particular date.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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); -// 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); -$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'); -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 '
'; -echo '
'; - -// Test the formulae -?> - - - - - - - - - - - - - '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - ?> -
Date ValueFormulaExcel DateStampFormatted DateStamp
YearMonthDay
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '', $worksheet->getCell('D' . $row)->getValue(), '', $worksheet->getCell('D' . $row)->getFormattedValue(), '', $worksheet->getCell('E' . $row)->getFormattedValue(), '
- + // Test the formulae + ?> + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Date ValueFormulaExcel DateStampFormatted DateStamp
YearMonthDay
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '', $worksheet->getCell('D' . $row)->getValue(), '', $worksheet->getCell('D' . $row)->getFormattedValue(), '', $worksheet->getCell('E' . $row)->getFormattedValue(), '
+ \ No newline at end of file diff --git a/docs/Examples/Calculations/DateTime/DATEVALUE.php b/docs/Examples/Calculations/DateTime/DATEVALUE.php index 437b6aa8..535fdcce 100644 --- a/docs/Examples/Calculations/DateTime/DATEVALUE.php +++ b/docs/Examples/Calculations/DateTime/DATEVALUE.php @@ -6,67 +6,65 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

DATEVALUE

-

Converts a date in the form of text to a serial number.

-DATEVALUE +

Converts a date in the form of text to a serial number.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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); -// 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); + } -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'); -$worksheet->getStyle('C1:C' . $testDateCount) - ->getNumberFormat() - ->setFormatCode('yyyy-mmm-dd'); + echo '
'; -echo '
'; - -// Test the formulae -?> -

Warning: The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.

- - - - - - - - '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - ?> -
Date StringFormulaExcel DateStampFormatted DateStamp
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '
- + // Test the formulae + ?> +

Warning: The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.

+ + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Date StringFormulaExcel DateStampFormatted DateStamp
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '
+ \ No newline at end of file diff --git a/docs/Examples/Calculations/DateTime/TIME.php b/docs/Examples/Calculations/DateTime/TIME.php index 588eadf9..09641074 100644 --- a/docs/Examples/Calculations/DateTime/TIME.php +++ b/docs/Examples/Calculations/DateTime/TIME.php @@ -6,72 +6,70 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

TIME

-

Returns the serial number of a particular time.

-TIME +

Returns the serial number of a particular time.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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); -// 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); -$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'); -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 '
'; -echo '
'; - -// Test the formulae -?> - - - - - - - - - - - - - '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - ?> -
Date ValueFormulaExcel TimeStampFormatted TimeStamp
HourMinuteSecond
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '', $worksheet->getCell('D' . $row)->getValue(), '', $worksheet->getCell('D' . $row)->getFormattedValue(), '', $worksheet->getCell('E' . $row)->getFormattedValue(), '
- + // Test the formulae + ?> + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Date ValueFormulaExcel TimeStampFormatted TimeStamp
HourMinuteSecond
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '', $worksheet->getCell('D' . $row)->getValue(), '', $worksheet->getCell('D' . $row)->getFormattedValue(), '', $worksheet->getCell('E' . $row)->getFormattedValue(), '
+ \ No newline at end of file diff --git a/docs/Examples/Calculations/DateTime/TIMEVALUE.php b/docs/Examples/Calculations/DateTime/TIMEVALUE.php index 26996b61..4cf27c81 100644 --- a/docs/Examples/Calculations/DateTime/TIMEVALUE.php +++ b/docs/Examples/Calculations/DateTime/TIMEVALUE.php @@ -6,63 +6,61 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Calculation Examples + PhpSpreadsheet Calculation Examples - - + + -

TIMEVALUE

-

Converts a time in the form of text to a serial number.

-TIMEVALUE +

Converts a time in the form of text to a serial number.

+ getActiveSheet(); -// Create new PhpSpreadsheet object -$spreadsheet = new Spreadsheet(); -$worksheet = $spreadsheet->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); -// 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); + } -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'); -$worksheet->getStyle('C1:C' . $testDateCount) - ->getNumberFormat() - ->setFormatCode('hh:mm:ss'); + echo '
'; -echo '
'; - -// Test the formulae -?> - - - - - - - - '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - ?> -
Time StringFormulaExcel TimeStampFormatted TimeStamp
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '
- + // Test the formulae + ?> + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Time StringFormulaExcel TimeStampFormatted TimeStamp
', $worksheet->getCell('A' . $row)->getFormattedValue(), '', $worksheet->getCell('B' . $row)->getValue(), '', $worksheet->getCell('B' . $row)->getFormattedValue(), '', $worksheet->getCell('C' . $row)->getFormattedValue(), '
+ \ No newline at end of file diff --git a/docs/Examples/Calculations/index.php b/docs/Examples/Calculations/index.php index 5990ca23..ad03fe8e 100644 --- a/docs/Examples/Calculations/index.php +++ b/docs/Examples/Calculations/index.php @@ -1,49 +1,45 @@ - - + + -PhpSpreadsheet Calculation Function Examples + PhpSpreadsheet Calculation Function Examples - - + + -PhpSpreadsheet Calculation Function Examples'; -echo '

PhpSpreadsheet Calculation Function Examples

'; + $exampleTypeList = glob('./*', GLOB_ONLYDIR); -$exampleTypeList = glob('./*', GLOB_ONLYDIR); + foreach ($exampleTypeList as $exampleType) { + echo '

' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Function Examples

'; -foreach ($exampleTypeList as $exampleType) { - echo '

' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Function Examples

'; + $exampleList = glob('./' . $exampleType . '/*.php'); - $exampleList = glob('./' . $exampleType . '/*.php'); + foreach ($exampleList as $exampleFile) { + $fileData = file_get_contents($exampleFile); - foreach ($exampleList as $exampleFile) { - $fileData = file_get_contents($exampleFile); + $h1Pattern = '#

(.*?)

#'; + $h2Pattern = '#

(.*?)

#'; - $h1Pattern = '#

(.*?)

#'; - $h2Pattern = '#

(.*?)

#'; + if (preg_match($h1Pattern, $fileData, $out)) { + $h1Text = $out[1]; + $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; - if (preg_match($h1Pattern, $fileData, $out)) { - $h1Text = $out[1]; - $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; - - echo '',$h1Text,'
'; - if ($h2Text > '') { - echo $h2Text,'
'; + 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 index d20207a2..1e343e5d 100644 --- a/docs/Examples/Reader/exampleReader01.php +++ b/docs/Examples/Reader/exampleReader01.php @@ -6,32 +6,29 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #01 + PhpSpreadsheet Reader Example #01 - - + + -

PhpSpreadsheet Reader Example #01

-

Simple File Reader using IOFactory::load()

-PhpSpreadsheet Reader Example #01 +

Simple File Reader using IOFactory::load()

+ '; + $spreadsheet = IOFactory::load($inputFileName); -$inputFileName = './sampleData/example1.xls'; -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format
'; -$spreadsheet = IOFactory::load($inputFileName); + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index 9d301f69..c29e7993 100644 --- a/docs/Examples/Reader/exampleReader02.php +++ b/docs/Examples/Reader/exampleReader02.php @@ -8,38 +8,29 @@ set_time_limit(0); date_default_timezone_set('Europe/London'); require_once __DIR__ . '/../../../src/Bootstrap.php'; - ?> - - + + -PhpSpreadsheet Reader Example #02 + PhpSpreadsheet Reader Example #02 - - + + -

PhpSpreadsheet Reader Example #02

-

Simple File Reader using a Specified Reader

-PhpSpreadsheet Reader Example #02 +

Simple File Reader using a Specified Reader

+ '; + $reader = new Xls(); + $spreadsheet = $reader->load($inputFileName); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using \PhpOffice\PhpSpreadsheet\Reader\Xls
'; -$reader = new Xls(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Slk(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Gnumeric(); -// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index 07dfa7ae..750d52c2 100644 --- a/docs/Examples/Reader/exampleReader03.php +++ b/docs/Examples/Reader/exampleReader03.php @@ -6,41 +6,32 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #03 + PhpSpreadsheet Reader Example #03 - - + + -

PhpSpreadsheet Reader Example #03

-

Simple File Reader using the IOFactory to Return a Reader

-PhpSpreadsheet Reader Example #03 +

Simple File Reader using the IOFactory to Return a Reader

+ '; + $reader = IOFactory::createReader($inputFileType); + $spreadsheet = $reader->load($inputFileName); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -$reader = IOFactory::createReader($inputFileType); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index d26d6525..7b8065d5 100644 --- a/docs/Examples/Reader/exampleReader04.php +++ b/docs/Examples/Reader/exampleReader04.php @@ -6,37 +6,34 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #04 + PhpSpreadsheet Reader Example #04 - - + + -

PhpSpreadsheet Reader Example #04

-

Simple File Reader using the IOFactory to Identify a Reader to Use

-PhpSpreadsheet Reader Example #04 +

Simple File Reader using the IOFactory to Identify a Reader to Use

+ '; -$inputFileType = IOFactory::identify($inputFileName); -echo 'File ',pathinfo($inputFileName, PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file
'; + echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with the identified reader type
'; + $reader = IOFactory::createReader($inputFileType); + $spreadsheet = $reader->load($inputFileName); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with the identified reader type
'; -$reader = IOFactory::createReader($inputFileType); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index ff72be92..2b06e8ac 100644 --- a/docs/Examples/Reader/exampleReader05.php +++ b/docs/Examples/Reader/exampleReader05.php @@ -6,41 +6,34 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #05 + PhpSpreadsheet Reader Example #05 - - + + -

PhpSpreadsheet Reader Example #05

-

Simple File Reader using the "Read Data Only" Option

-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 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -$reader = IOFactory::createReader($inputFileType); -echo 'Turning Formatting off for Load
'; -$reader->setReadDataOnly(true); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index ccc59373..04e6b94e 100644 --- a/docs/Examples/Reader/exampleReader06.php +++ b/docs/Examples/Reader/exampleReader06.php @@ -6,44 +6,37 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #06 + PhpSpreadsheet Reader Example #06 - - + + -

PhpSpreadsheet Reader Example #06

-

Simple File Reader Loading All WorkSheets

-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 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -$reader = IOFactory::createReader($inputFileType); -echo 'Loading all WorkSheets
'; -$reader->setLoadAllSheets(); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded

'; -$loadedSheetNames = $spreadsheet->getSheetNames(); -foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { - echo $sheetIndex, ' -> ', $loadedSheetName, '
'; -} - -?> - + 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 index cde1c409..7beabc82 100644 --- a/docs/Examples/Reader/exampleReader07.php +++ b/docs/Examples/Reader/exampleReader07.php @@ -6,45 +6,38 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #07 + PhpSpreadsheet Reader Example #07 - - + + -

PhpSpreadsheet Reader Example #07

-

Simple File Reader Loading a Single Named WorkSheet

-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 '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); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded

'; -$loadedSheetNames = $spreadsheet->getSheetNames(); -foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { - echo $sheetIndex,' -> ',$loadedSheetName,'
'; -} - -?> - + 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 index 0a739f75..c9e574b9 100644 --- a/docs/Examples/Reader/exampleReader08.php +++ b/docs/Examples/Reader/exampleReader08.php @@ -6,45 +6,38 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #08 + PhpSpreadsheet Reader Example #08 - - + + -

PhpSpreadsheet Reader Example #08

-

Simple File Reader Loading Several Named WorkSheets

-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 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -$reader = IOFactory::createReader($inputFileType); -echo 'Loading Sheet',((count($sheetnames) == 1) ? '' : 's'),' "',implode('" and "', $sheetnames),'" only
'; -$reader->setLoadSheetsOnly($sheetnames); -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; - -echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded

'; -$loadedSheetNames = $spreadsheet->getSheetNames(); -foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { - echo $sheetIndex,' -> ',$loadedSheetName,'
'; -} - -?> - + 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 index 8dde497c..1c5c4147 100644 --- a/docs/Examples/Reader/exampleReader09.php +++ b/docs/Examples/Reader/exampleReader09.php @@ -7,61 +7,55 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #09 + PhpSpreadsheet Reader Example #09 - - + + -

PhpSpreadsheet Reader Example #09

-

Simple File Reader Using a Read Filter

-PhpSpreadsheet Reader Example #09 +

Simple File Reader Using a Read Filter

+ = 1 && $row <= 7) { + if (in_array($column, range('A', 'E'))) { + return true; + } + } -class MyReadFilter implements IReadFilter -{ - public function readCell($column, $row, $worksheetName = '') - { - // Read rows 1 to 7 and columns A to E only - if ($row >= 1 && $row <= 7) { - if (in_array($column, range('A', 'E'))) { - return true; + return false; } + } - return false; - } -} + $filterSubset = new MyReadFilter(); -$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 '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 '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index f62c98d93..6d4517eb 100644 --- a/docs/Examples/Reader/exampleReader10.php +++ b/docs/Examples/Reader/exampleReader10.php @@ -7,73 +7,66 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #10 + PhpSpreadsheet Reader Example #10 - - + + -

PhpSpreadsheet Reader Example #10

-

Simple File Reader Using a Configurable Read Filter

-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; + public function __construct($startRow, $endRow, $columns) + { + $this->_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; + } + } - return false; - } -} + $filterSubset = new MyReadFilter(9, 15, range('G', 'K')); -$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 '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 '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index 2b7225a9..67c9ec4d 100644 --- a/docs/Examples/Reader/exampleReader11.php +++ b/docs/Examples/Reader/exampleReader11.php @@ -7,86 +7,80 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #11 + PhpSpreadsheet Reader Example #11 - - + + -

PhpSpreadsheet Reader Example #11

-

Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)

-PhpSpreadsheet Reader Example #11 +

Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)

+ _startRow = $startRow; + $this->_endRow = $startRow + $chunkSize; + } - /** - * We expect a list of the rows that we want to read to be passed into the constructor. - * - * @param mixed $startRow - * @param mixed $chunkSize - */ - public function __construct($startRow, $chunkSize) - { - $this->_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; + } - 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 '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 '
'; -echo '
'; + /* Define how many rows we want for each "chunk" * */ + $chunkSize = 20; -/* 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); -/* 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 - // Do some processing here - - $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); - var_dump($sheetData); - echo '

'; -} - -?> - + $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 index 50580f2a..f9055ae1 100644 --- a/docs/Examples/Reader/exampleReader12.php +++ b/docs/Examples/Reader/exampleReader12.php @@ -7,89 +7,83 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #12 + PhpSpreadsheet Reader Example #12 - - + + -

PhpSpreadsheet Reader Example #12

-

Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)

-PhpSpreadsheet Reader Example #12 +

Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)

+ _startRow = $startRow; + $this->_endRow = $startRow + $chunkSize; + } - /** - * Set the list of rows that we want to read. - * - * @param mixed $startRow - * @param mixed $chunkSize - */ - public function setRows($startRow, $chunkSize) - { - $this->_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; + } - 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 '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 '
'; -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(); -/* 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); -/* 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); -/* 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 - // Do some processing here - - $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); - var_dump($sheetData); - echo '

'; -} - -?> - + $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 index c5107c87..e13f1801 100644 --- a/docs/Examples/Reader/exampleReader13.php +++ b/docs/Examples/Reader/exampleReader13.php @@ -6,50 +6,47 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #13 + PhpSpreadsheet Reader Example #13 - - + + -

PhpSpreadsheet Reader Example #13

-

Simple File Reader for Multiple CSV Files

-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)); + } -$reader = IOFactory::createReader($inputFileType); -$inputFileName = array_shift($inputFileNames); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'
'; -$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 '
'; - -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 '

'; -} - -?> - + 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 index aad066dc..98ab0b65 100644 --- a/docs/Examples/Reader/exampleReader14.php +++ b/docs/Examples/Reader/exampleReader14.php @@ -8,105 +8,103 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #14 + PhpSpreadsheet Reader Example #14 - - + + -

PhpSpreadsheet Reader Example #14

-

Reading a Large CSV file in "Chunks" to split across multiple Worksheets

-PhpSpreadsheet Reader Example #14 +

Reading a Large CSV file in "Chunks" to split across multiple Worksheets

+ _startRow = $startRow; + $this->_endRow = $startRow + $chunkSize; + } - /** - * Set the list of rows that we want to read. - * - * @param mixed $startRow - * @param mixed $chunkSize - */ - public function setRows($startRow, $chunkSize) - { - $this->_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; + } - 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 '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 '
'; -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(); -/* 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); -/* 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(); -/* 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); -/* 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)); + } - /* 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 '
'; - -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 '
'; -} - -?> - + 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 index fdf38b05..be913444 100644 --- a/docs/Examples/Reader/exampleReader15.php +++ b/docs/Examples/Reader/exampleReader15.php @@ -7,66 +7,63 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #15 + PhpSpreadsheet Reader Example #15 - - + + -

PhpSpreadsheet Reader Example #15

-

Simple File Reader for Tab-Separated Value File using the Advanced Value Binder

-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)); -$reader = IOFactory::createReader($inputFileType); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'
'; -$reader->setDelimiter("\t"); -$spreadsheet = $reader->load($inputFileName); -$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); + echo '
'; -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 $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 '
'; -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 '
'; + } -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 '
'; -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 '
'; -} - -?> - + 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 index 9436bd2e..aa4bc469 100644 --- a/docs/Examples/Reader/exampleReader16.php +++ b/docs/Examples/Reader/exampleReader16.php @@ -7,36 +7,33 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #16 + PhpSpreadsheet Reader Example #16 - - + + -

PhpSpreadsheet Reader Example #16

-

Handling Loader Exceptions using Try/Catch

-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()); + } -$inputFileName = './sampleData/example_1.xls'; -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format
'; -try { - $spreadsheet = IOFactory::load($inputFileName); -} catch (InvalidArgumentException $e) { - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); -} + echo '
'; -echo '
'; - -$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); -var_dump($sheetData); - -?> - + $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 index 763805ac..3c6ebf30 100644 --- a/docs/Examples/Reader/exampleReader17.php +++ b/docs/Examples/Reader/exampleReader17.php @@ -6,42 +6,35 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #17 + PhpSpreadsheet Reader Example #17 - - + + -

PhpSpreadsheet Reader Example #17

-

Simple File Reader Loading Several Named WorkSheets

-PhpSpreadsheet Reader Example #17 +

Simple File Reader Loading Several Named WorkSheets

+ '; + $reader = IOFactory::createReader($inputFileType); -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -$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); -/* 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,'
'; -} - -?> - + 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 index 9822b209..68a478bb 100644 --- a/docs/Examples/Reader/exampleReader18.php +++ b/docs/Examples/Reader/exampleReader18.php @@ -6,42 +6,35 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #18 + PhpSpreadsheet Reader Example #18 - - + + -

PhpSpreadsheet Reader Example #18

-

Reading list of WorkSheets without loading entire file

-PhpSpreadsheet Reader Example #18 +

Reading list of WorkSheets without loading entire file

+ '; -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' information using IOFactory with a defined reader type of ',$inputFileType,'
'; + $reader = IOFactory::createReader($inputFileType); + $worksheetNames = $reader->listWorksheetNames($inputFileName); -$reader = IOFactory::createReader($inputFileType); -$worksheetNames = $reader->listWorksheetNames($inputFileName); - -echo '

Worksheet Names

'; -echo '
    '; -foreach ($worksheetNames as $worksheetName) { - echo '
  1. ', $worksheetName, '
  2. '; -} -echo '
'; - -?> - + echo '

Worksheet Names

'; + echo '
    '; + foreach ($worksheetNames as $worksheetName) { + echo '
  1. ', $worksheetName, '
  2. '; + } + echo '
'; + ?> + \ No newline at end of file diff --git a/docs/Examples/Reader/exampleReader19.php b/docs/Examples/Reader/exampleReader19.php index 5749d1b6..dea2dd06 100644 --- a/docs/Examples/Reader/exampleReader19.php +++ b/docs/Examples/Reader/exampleReader19.php @@ -6,45 +6,38 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reader Example #19 + PhpSpreadsheet Reader Example #19 - - + + -

PhpSpreadsheet Reader Example #19

-

Reading WorkSheet information without loading entire file

-PhpSpreadsheet Reader Example #19 +

Reading WorkSheet information without loading entire file

+ '; -echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' information using IOFactory with a defined reader type of ',$inputFileType,'
'; + $reader = IOFactory::createReader($inputFileType); + $worksheetData = $reader->listWorksheetInfo($inputFileName); -$reader = IOFactory::createReader($inputFileType); -$worksheetData = $reader->listWorksheetInfo($inputFileName); - -echo '

Worksheet Information

'; -echo '
    '; -foreach ($worksheetData as $worksheet) { - echo '
  1. ', $worksheet['worksheetName'], '
    '; - echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '
    '; - echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows']; - echo '
  2. '; -} -echo '
'; - -?> - + echo '

Worksheet Information

'; + echo '
    '; + foreach ($worksheetData as $worksheet) { + echo '
  1. ', $worksheet['worksheetName'], '
    '; + echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '
    '; + echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows']; + echo '
  2. '; + } + 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 index 8a6b4726..9085b394 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader01.php @@ -6,83 +6,80 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reading WorkBook Data Example #01 + PhpSpreadsheet Reading WorkBook Data Example #01 - - + + -

PhpSpreadsheet Reading WorkBook Data Example #01

-

Read the WorkBook Properties

-PhpSpreadsheet Reading WorkBook Data Example #01 +

Read the WorkBook Properties

+ load($inputFileName); -/* Create a new Reader of the type defined in $inputFileType **/ -$reader = IOFactory::createReader($inputFileType); -/* Load $inputFileName to a PhpSpreadsheet Object **/ -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; + /* Read the document's creator property * */ + $creator = $spreadsheet->getProperties()->getCreator(); + echo 'Document Creator: ', $creator, '
'; -/* 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 F Y', $creationDatestamp); + $creationTime = date('g:i A', $creationDatestamp); + echo 'Created On: ', $creationDate, ' at ', $creationTime, '
'; -/* 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 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 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 F Y', $modifiedDatestamp); + $modifiedTime = date('g:i A', $modifiedDatestamp); + echo 'Last Modified On: ', $modifiedDate, ' at ', $modifiedTime, '
'; -/* 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 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 title property **/ -$workbookTitle = $spreadsheet->getProperties()->getTitle(); -echo 'Title: ',$workbookTitle,'
'; + /* Read the workbook description property * */ + $description = $spreadsheet->getProperties()->getDescription(); + echo 'Description: ', $description, '
'; -/* 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 subject property **/ -$subject = $spreadsheet->getProperties()->getSubject(); -echo 'Subject: ',$subject,'
'; + /* Read the workbook keywords property * */ + $keywords = $spreadsheet->getProperties()->getKeywords(); + echo 'Keywords: ', $keywords, '
'; -/* 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 category property **/ -$category = $spreadsheet->getProperties()->getCategory(); -echo 'Category: ',$category,'
'; + /* Read the workbook company property * */ + $company = $spreadsheet->getProperties()->getCompany(); + echo 'Company: ', $company, '
'; -/* Read the workbook company property **/ -$company = $spreadsheet->getProperties()->getCompany(); -echo 'Company: ',$company,'
'; - -/* Read the workbook manager property **/ -$manager = $spreadsheet->getProperties()->getManager(); -echo 'Manager: ',$manager,'
'; - -?> - + /* 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 index b9cfc196..b643f74b 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader02.php @@ -6,41 +6,38 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reading WorkBook Data Example #02 + PhpSpreadsheet Reading WorkBook Data Example #02 - - + + -

PhpSpreadsheet Reading WorkBook Data Example #02

-

Read a list of Custom Properties for a WorkBook

-PhpSpreadsheet Reading WorkBook Data Example #02 +

Read a list of Custom Properties for a WorkBook

+ load($inputFileName); -/* Create a new Reader of the type defined in $inputFileType **/ -$reader = IOFactory::createReader($inputFileType); -/* Load $inputFileName to a PhpSpreadsheet Object **/ -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; + /* Read an array list of any custom properties for this document * */ + $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); -/* 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, '
'; -} - -?> - + 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 index 81327481..432099aa 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader03.php @@ -6,69 +6,66 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reading WorkBook Data Example #03 + PhpSpreadsheet Reading WorkBook Data Example #03 - - + + -

PhpSpreadsheet Reading WorkBook Data Example #03

-

Read Custom Property Values for a WorkBook

-PhpSpreadsheet Reading WorkBook Data Example #03 +

Read Custom Property Values for a WorkBook

+ load($inputFileName); -/* Create a new Reader of the type defined in $inputFileType **/ -$reader = IOFactory::createReader($inputFileType); -/* Load $inputFileName to a PhpSpreadsheet Object **/ -$spreadsheet = $reader->load($inputFileName); + echo '
'; -echo '
'; + /* Read an array list of any custom properties for this document * */ + $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); -/* 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); -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 F Y g:i A', $propertyValue); + $propertyType = 'date'; + break; + case 'b': // boolean + $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; + $propertyType = 'boolean'; + break; + } - /* 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 F Y g:i A', $propertyValue); - $propertyType = 'date'; - break; - case 'b': // boolean - $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; - $propertyType = 'boolean'; - break; - } - - echo $propertyValue, ' (', $propertyType, ')
'; -} - -?> - + echo $propertyValue, ' (', $propertyType, ')
'; + } + ?> + diff --git a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php index e3a71d34..7299e783 100644 --- a/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php +++ b/docs/Examples/Reading WorkBook Data/exampleWorkBookReader04.php @@ -6,45 +6,42 @@ error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); - ?> - - + + -PhpSpreadsheet Reading WorkBook Data Example #04 + PhpSpreadsheet Reading WorkBook Data Example #04 - - + + -

PhpSpreadsheet Reading WorkBook Data Example #04

-

Get a List of the Worksheets in a WorkBook

-PhpSpreadsheet Reading WorkBook Data Example #04 +

Get a List of the Worksheets in a WorkBook

+ load($inputFileName); -/* Create a new Reader of the type defined in $inputFileType **/ -$reader = IOFactory::createReader($inputFileType); -/* Load $inputFileName to a PhpSpreadsheet Object **/ -$spreadsheet = $reader->load($inputFileName); + echo '
'; -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 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,'"
'; -} - -?> - + 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 index a2c51879..9ff0929d 100644 --- a/docs/Examples/index.php +++ b/docs/Examples/index.php @@ -1,48 +1,44 @@ - - + + -PhpSpreadsheet Examples + PhpSpreadsheet Examples - - + + -PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples'; -foreach ($exampleTypeList as $exampleType) { - echo '

PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples

'; + $exampleList = glob('./' . $exampleType . '/*.php'); - $exampleList = glob('./' . $exampleType . '/*.php'); + foreach ($exampleList as $exampleFile) { + $fileData = file_get_contents($exampleFile); - foreach ($exampleList as $exampleFile) { - $fileData = file_get_contents($exampleFile); + $h1Pattern = '#

(.*?)

#'; + $h2Pattern = '#

(.*?)

#'; - $h1Pattern = '#

(.*?)

#'; - $h2Pattern = '#

(.*?)

#'; + if (preg_match($h1Pattern, $fileData, $out)) { + $h1Text = $out[1]; + $h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : ''; - 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, '
'; + echo '', $h1Text, '
'; + if (($h2Text > '') && + (pathinfo($exampleType, PATHINFO_BASENAME) != 'Calculations')) { + echo $h2Text, '
'; + } + } } } - } -} - -?> - + ?> + \ No newline at end of file diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index 17556270..d84932bc 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -3770,9 +3770,6 @@ class Calculation $output = $stack->pop(); $output = $output['value']; -// if ((is_array($output)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) { -// return array_shift(Calculation\Functions::flattenArray($output)); -// } return $output; } diff --git a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php index 094ded83..93e9fd58 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php @@ -778,7 +778,7 @@ class EigenvalueDecomposition } } - // end hqr2 + // end hqr2 /** * Constructor: Check for symmetry, then construct the eigenvalue decomposition. diff --git a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php index cfd20113..9d383202 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php @@ -436,8 +436,6 @@ class SingularValueDecomposition } // end while } - // end constructor - /** * Return the left singular vectors. * diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index 84b21981..d076fdcd 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -84,9 +84,9 @@ class Font $bFamily = 0; // Font family $bCharSet = \PhpOffice\PhpSpreadsheet\Shared\Font::getCharsetFromFontName($this->font->getName()); // Character set - $record = 0x31; // Record identifier - $reserved = 0x00; // Reserved - $grbit = 0x00; // Font attributes + $record = 0x31; // Record identifier + $reserved = 0x00; // Reserved + $grbit = 0x00; // Font attributes if ($this->font->getItalic()) { $grbit |= 0x02; } @@ -134,10 +134,10 @@ class Font private static function mapBold($bold) { if ($bold) { - return 0x2BC; // 700 = Bold font weight + return 0x2BC; // 700 = Bold font weight } - return 0x190; // 400 = Normal font weight + return 0x190; // 400 = Normal font weight } /** diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 939b0f50..5f539650 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -1190,14 +1190,14 @@ class Worksheet extends BIFFwriter // Pack the main data stream $data = pack('vvvv', $row1, $row2, $col1, $col2) . - $unknown1 . - $link_type . - $unknown2 . - $up_count . - $dir_short_len . - $dir_short . - $unknown3 . - $stream_len; /*. + $unknown1 . + $link_type . + $unknown2 . + $up_count . + $dir_short_len . + $dir_short . + $unknown3 . + $stream_len; /*. $dir_long_len . $unknown4 . $dir_long . diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 93ea21db..7bcb0b33 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -159,8 +159,8 @@ class Xlsx extends BaseWriter implements IWriter } $hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable', - 'bordersHashTable', 'numFmtHashTable', 'drawingHashTable', - 'styleHashTable', + 'bordersHashTable', 'numFmtHashTable', 'drawingHashTable', + 'styleHashTable', ]; // Set HashTable variables diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index f5bf2bf7..a2e1058c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -306,7 +306,6 @@ class Worksheet extends WriterPart } // Selection -// if ($pane != '') { // Only need to write selection element if we have a split pane // We cheat a little by over-riding the active cell selection, setting it to the split cell $objWriter->startElement('selection'); @@ -316,7 +315,6 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('activeCell', $activeCell); $objWriter->writeAttribute('sqref', $activeCell); $objWriter->endElement(); -// } $objWriter->endElement(); From cf2c0e51f463a3f65ce816db5be2db2ab9f052c6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 3 Aug 2017 12:59:52 +0200 Subject: [PATCH 19/31] Fix variadic docblocks --- src/PhpSpreadsheet/Calculation.php | 52 ++++++++++++++++--- .../Calculation/Engineering.php | 4 +- src/PhpSpreadsheet/Calculation/Logical.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 14 ++--- .../Calculation/Statistical.php | 50 +++++++++--------- 5 files changed, 80 insertions(+), 42 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index d84932bc..062e2174 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -13,6 +13,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; use PhpOffice\PhpSpreadsheet\Calculation\Statistical; use PhpOffice\PhpSpreadsheet\Calculation\TextData; +use PhpOffice\PhpSpreadsheet\Calculation\Token\Stack; /** * Copyright (c) 2006 - 2016 PhpSpreadsheet. @@ -2059,8 +2060,6 @@ class Calculation /** * Unset an instance of this class. - * - * @param Spreadsheet $spreadsheet Injected spreadsheet identifying the instance to unset */ public function __destruct() { @@ -2314,6 +2313,14 @@ class Calculation return false; } + /** + * @param string $fromSeparator + * @param string $toSeparator + * @param string $formula + * @param bool $inBraces + * + * @return string + */ public static function translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces) { $strlen = mb_strlen($formula); @@ -2657,6 +2664,12 @@ class Calculation return $result; } + /** + * @param string $cellReference + * @param mixed $cellValue + * + * @return bool + */ public function getValueFromCache($cellReference, &$cellValue) { // Is calculation cacheing enabled? @@ -2985,6 +2998,11 @@ class Calculation } } + /** + * @param string $formula + * + * @return string + */ private function convertMatrixReferences($formula) { static $matrixReplaceFrom = ['{', ';', '}']; @@ -3073,6 +3091,13 @@ class Calculation ]; // Convert infix to postfix notation + + /** + * @param string $formula + * @param Cell|null $pCell + * + * @return bool + */ private function _parseFormula($formula, Cell $pCell = null) { if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { @@ -3094,7 +3119,7 @@ class Calculation // Start with initialisation $index = 0; - $stack = new Calculation\Token\Stack(); + $stack = new Stack(); $output = []; $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a // - is a negation or + is a positive operator rather than an operation @@ -3401,8 +3426,11 @@ class Calculation // evaluate postfix notation /** - * @param string $cellID * @param mixed $tokens + * @param string|null $cellID + * @param Cell|null $pCell + * + * @return bool */ private function processTokenStack($tokens, $cellID = null, Cell $pCell = null) { @@ -3414,7 +3442,7 @@ class Calculation // so we store the parent cell collection so that we can re-attach it when necessary $pCellWorksheet = ($pCell !== null) ? $pCell->getWorksheet() : null; $pCellParent = ($pCell !== null) ? $pCell->getParent() : null; - $stack = new Calculation\Token\Stack(); + $stack = new Stack(); // Loop through each token in turn foreach ($tokens as $tokenData) { @@ -3811,7 +3839,17 @@ class Calculation return true; } - private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false) + /** + * @param string|null $cellID + * @param mixed $operand1 + * @param mixed $operand2 + * @param string $operation + * @param Stack $stack + * @param bool $recursingArrays + * + * @return bool + */ + private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, Stack &$stack, $recursingArrays = false) { // If we're dealing with matrix operations, we want a matrix result if ((is_array($operand1)) || (is_array($operand2))) { @@ -3951,7 +3989,7 @@ class Calculation /** * @param string $matrixFunction - * @param mixed $cellID + * @param string|null $cellID * @param mixed $operand1 * @param mixed $operand2 * @param mixed $operation diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 582c6cbd..8136fe68 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -2293,7 +2293,7 @@ class Engineering * Excel Function: * IMSUM(complexNumber[,complexNumber[,...]]) * - * @param string $complexNumbers Series of complex numbers to add + * @param string ...$complexNumbers Series of complex numbers to add * * @return string */ @@ -2333,7 +2333,7 @@ class Engineering * Excel Function: * IMPRODUCT(complexNumber[,complexNumber[,...]]) * - * @param string $complexNumbers Series of complex numbers to multiply + * @param string ...$complexNumbers Series of complex numbers to multiply * * @return string */ diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 5492cc6e..4db10945 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -80,7 +80,7 @@ class Logical * * @category Logical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return string|bool the logical AND of the arguments */ diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 25200205..f3bcaedb 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -347,7 +347,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return int Greatest Common Divisor */ @@ -456,7 +456,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return int Lowest Common Multiplier */ @@ -859,7 +859,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -899,7 +899,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1185,7 +1185,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1306,7 +1306,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1351,7 +1351,7 @@ class MathTrig * * @category Mathematical and Trigonometric Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index fc5cdbb3..954dfe3c 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -720,7 +720,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -771,7 +771,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -814,7 +814,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1207,7 +1207,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return int */ @@ -1241,7 +1241,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return int */ @@ -1271,7 +1271,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return int */ @@ -1491,7 +1491,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1785,7 +1785,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1851,7 +1851,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -1967,7 +1967,7 @@ class Statistical * kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a * relatively flat distribution. * - * @param array Data Series + * @param array ...$args Data Series * * @return float */ @@ -2249,7 +2249,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -2285,7 +2285,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -2368,7 +2368,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -2412,7 +2412,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -2448,7 +2448,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -2568,7 +2568,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3016,7 +3016,7 @@ class Statistical * asymmetric tail extending toward more positive values. Negative skewness indicates a * distribution with an asymmetric tail extending toward more negative values. * - * @param array Data Series + * @param array ...$args Data Series * * @return float */ @@ -3161,7 +3161,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3210,7 +3210,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3262,7 +3262,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3309,7 +3309,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3599,7 +3599,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3643,7 +3643,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3696,7 +3696,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ @@ -3741,7 +3741,7 @@ class Statistical * * @category Statistical Functions * - * @param mixed $args Data values + * @param mixed ...$args Data values * * @return float */ From c8089f97d88baa685efef18342aafe9277482ddb Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 17 Aug 2017 12:55:27 +0200 Subject: [PATCH 20/31] Prevent notice when no rules Closes https://github.com/PHPOffice/PHPExcel/pull/1287 --- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 88042565..c3d783da 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -629,6 +629,7 @@ class AutoFilter $rules = $filterColumn->getRules(); switch ($filterColumn->getFilterType()) { case AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER: + $ruleType = null; $ruleValues = []; // Build a list of the filter value selections foreach ($rules as $rule) { @@ -700,7 +701,6 @@ class AutoFilter $ruleValues = []; // Build a list of the filter value selections foreach ($rules as $rule) { - $ruleType = $rule->getRuleType(); $ruleValue = $rule->getValue(); if (!is_numeric($ruleValue)) { // Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards From 7d4dc74fc6219739f1b6e0a7a2f87fdbf33c6ca5 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 17 Aug 2017 15:17:23 +0200 Subject: [PATCH 21/31] Release 1.0.0-beta --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1f8773..f7179613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +### Changed + +### Fixed + + +## [1.0.0-beta] - 2017-08-17 + +### Added + - Initial implementation of SUMIFS() function - Additional codepages - MemoryDrawing not working in HTML writer [#808](https://github.com/PHPOffice/PHPExcel/issues/808) @@ -18,7 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Start following [SemVer](http://semver.org) properly. -### Bugfixes +### Fixed - Fix to getCell() method when cell reference includes a worksheet reference - @MarkBaker - Ignore inlineStr type if formula element exists - @ncrypthic [#570](https://github.com/PHPOffice/PHPExcel/issues/570) From 004a1929221f759be2737d14f0138a0dd34a362f Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Thu, 7 Sep 2017 19:11:48 +0200 Subject: [PATCH 22/31] SCA with Php Inspections (EA Extended) Closes #208 --- src/PhpSpreadsheet/Calculation/DateTime.php | 6 +++--- src/PhpSpreadsheet/Calculation/FormulaParser.php | 6 +++--- src/PhpSpreadsheet/Calculation/LookupRef.php | 2 +- src/PhpSpreadsheet/Reader/Ods.php | 8 ++++---- src/PhpSpreadsheet/Reader/Xls.php | 2 +- src/PhpSpreadsheet/Spreadsheet.php | 2 +- src/PhpSpreadsheet/Style/NumberFormat.php | 2 +- src/PhpSpreadsheet/Writer/Html.php | 9 ++------- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 1 - src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 2 +- 10 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index d8a1d000..1c9317b8 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -493,7 +493,7 @@ class DateTime // Strip any ordinals because they're allowed in Excel (English only) $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue); // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany) - $dateValue = str_replace(['/', '.', '-', ' '], [' ', ' ', ' ', ' '], $dateValue); + $dateValue = str_replace(['/', '.', '-', ' '], ' ', $dateValue); $yearFound = false; $t1 = explode(' ', $dateValue); @@ -520,7 +520,7 @@ class DateTime $t1[1] += 1900; array_unshift($t1, 1); } else { - array_push($t1, date('Y')); + $t1[] = date('Y'); } } } @@ -621,7 +621,7 @@ class DateTime public static function TIMEVALUE($timeValue) { $timeValue = trim(Functions::flattenSingleValue($timeValue), '"'); - $timeValue = str_replace(['/', '.'], ['-', '-'], $timeValue); + $timeValue = str_replace(['/', '.'], '-', $timeValue); $arraySplit = preg_split('/[\/:\-\s]/', $timeValue); if ((count($arraySplit) == 2 || count($arraySplit) == 3) && $arraySplit[0] > 24) { diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index f37c4716..dbb94f29 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -253,7 +253,7 @@ class FormulaParser // establish state-dependent character evaluations if ($this->formula[$index] == self::QUOTE_DOUBLE) { - if (strlen($value > 0)) { + if (strlen($value) > 0) { // unexpected $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN); $value = ''; @@ -593,7 +593,7 @@ class FormulaParser if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) { if (!is_numeric($token->getValue())) { - if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue() == 'FALSE')) { + if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL); } else { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_RANGE); @@ -607,7 +607,7 @@ class FormulaParser } if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) { - if (strlen($token->getValue() > 0)) { + if (strlen($token->getValue()) > 0) { if (substr($token->getValue(), 0, 1) == '@') { $token->setValue(substr($token->getValue(), 1)); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 010aea93..9672a6da 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -201,7 +201,7 @@ class LookupRef if (is_array($cellAddress)) { foreach ($cellAddress as $columnKey => $rowValue) { foreach ($rowValue as $rowKey => $cellValue) { - return (int) preg_replace('/[^0-9]/i', '', $rowKey); + return (int) preg_replace('/[^0-9]/', '', $rowKey); } } } else { diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index d454a86d..31ff4aa2 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -650,16 +650,16 @@ class Ods extends BaseReader implements IReader // Only replace in alternate array entries (i.e. non-quoted blocks) if ($tKey = !$tKey) { // Cell range reference in another sheet - $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); + $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/U', '$1!$2:$3', $value); // Cell reference in another sheet - $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); + $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/U', '$1!$2', $value); // Cell range reference - $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); + $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/U', '$1:$2', $value); // Simple cell reference - $value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); + $value = preg_replace('/\[\.([^\.]+)\]/U', '$1', $value); $value = Calculation::translateSeparator(';', ',', $value, $inBraces); } diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 45798fbe..b8a9f60c 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -7073,7 +7073,7 @@ class Xls extends BaseReader implements IReader // todo: check if we have identified the whole set of special characters // it seems that the following characters are not accepted for sheet names // and we may assume that they are not present: []*/:\? - if (preg_match("/[ !\"@#£$%&{()}<>=+'|^,;-]/", $sheetRange)) { + if (preg_match("/[ !\"@#£$%&{()}<>=+'|^,;-]/u", $sheetRange)) { $sheetRange = "'$sheetRange'"; } diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 2724286b..f78d94d9 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -371,7 +371,7 @@ class Spreadsheet */ public function __construct() { - $this->uniqueID = uniqid(); + $this->uniqueID = uniqid('', true); $this->calculationEngine = new Calculation($this); // Initialise worksheet collection and add one worksheet diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 21aaf40e..2d5bb178 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -507,7 +507,7 @@ class NumberFormat extends Supervisor implements IComparable if ($format === self::FORMAT_PERCENTAGE) { $value = round((100 * $value), 0) . '%'; } else { - if (preg_match('/\.[#0]+/i', $format, $m)) { + if (preg_match('/\.[#0]+/', $format, $m)) { $s = substr($m[0], 0, 1) . (strlen($m[0]) - 1); $format = str_replace($m[0], $s, $format); } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 0a08bc0b..cadf20ba 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -739,7 +739,7 @@ class Html extends BaseWriter implements IWriter if ($chart instanceof Chart) { $chartCoordinates = $chart->getTopLeftPosition(); if ($chartCoordinates['cell'] == $coordinates) { - $chartFileName = File::sysGetTempDir() . '/' . uniqid() . '.png'; + $chartFileName = File::sysGetTempDir() . '/' . uniqid('', true) . '.png'; if (!$chart->render($chartFileName)) { return; } @@ -978,9 +978,6 @@ class Html extends BaseWriter implements IWriter */ private function createCSSStyle(Style $pStyle) { - // Construct CSS - $css = ''; - // Create CSS $css = array_merge( $this->createCSSStyleAlignment($pStyle->getAlignment()), @@ -1235,7 +1232,6 @@ class Html extends BaseWriter implements IWriter $cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : ''; $coordinate = Cell::stringFromColumnIndex($colNum) . ($pRow + 1); if (!$this->useInlineCss) { - $cssClass = ''; $cssClass = 'column' . $colNum; } else { $cssClass = []; @@ -1541,8 +1537,7 @@ class Html extends BaseWriter implements IWriter $color_regex = '/^\\[[a-zA-Z]+\\]/'; if (preg_match($color_regex, $pFormat, $matches)) { - $color = str_replace('[', '', $matches[0]); - $color = str_replace(']', '', $color); + $color = str_replace(['[', ']'], '', $matches[0]); $color = strtolower($color); } diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 5f539650..93423002 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -1438,7 +1438,6 @@ class Worksheet extends BIFFwriter private function writeSelection() { // look up the selected cell range - $selectedCells = $this->phpSheet->getSelectedCells(); $selectedCells = Cell::splitRange($this->phpSheet->getSelectedCells()); $selectedCells = $selectedCells[0]; if (count($selectedCells) == 2) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index a2e1058c..a1a97865 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -790,7 +790,7 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('ref', str_replace('$', '', $range)); $columns = $pSheet->getAutoFilter()->getColumns(); - if (count($columns > 0)) { + if (count($columns) > 0) { foreach ($columns as $columnID => $column) { $rules = $column->getRules(); if (count($rules) > 0) { From 2761773b3dddf62b9ccfb3919b7b7c935935408a Mon Sep 17 00:00:00 2001 From: Bill Blume Date: Mon, 31 Jul 2017 11:36:54 -0700 Subject: [PATCH 23/31] Merge data-validation collections to reduce the final file size Closes #131 Closes #193 --- CHANGELOG.md | 2 + src/PhpSpreadsheet/Cell.php | 80 ++++++++++++++++++++ src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 1 + tests/PhpSpreadsheetTests/CellTest.php | 16 ++++ tests/data/CellMergeRangesInCollection.php | 58 ++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 tests/data/CellMergeRangesInCollection.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f7179613..94204fa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- Merge data-validations to reduce written worksheet size - @billblume [#131](https://github.com/PHPOffice/PhpSpreadSheet/issues/131) + ### Fixed diff --git a/src/PhpSpreadsheet/Cell.php b/src/PhpSpreadsheet/Cell.php index 0263853d..2ed9b47f 100644 --- a/src/PhpSpreadsheet/Cell.php +++ b/src/PhpSpreadsheet/Cell.php @@ -948,6 +948,86 @@ class Cell return array_values($sortKeys); } + /** + * Convert an associative array of single cell coordinates to values to an associative array + * of cell ranges to values. Only adjacent cell coordinates with the same + * value will be merged. If the value is an object, it must implement the method getHashCode(). + * + * For example, this function converts: + * + * [ 'A1' => 'x', 'A2' => 'x', 'A3' => 'x', 'A4' => 'y' ] + * + * to: + * + * [ 'A1:A3' => 'x', 'A4' => 'y' ] + * + * @param array $pCoordCollection associative array mapping coordinates to values + * + * @return array associative array mapping coordinate ranges to valuea + */ + public static function mergeRangesInCollection(array $pCoordCollection) + { + $hashedValues = []; + + foreach ($pCoordCollection as $coord => $value) { + list($column, $row) = self::coordinateFromString($coord); + $row = (int) (ltrim($row, '$')); + $hashCode = $column . '-' . (is_object($value) ? $value->getHashCode() : $value); + + if (!isset($hashedValues[$hashCode])) { + $hashedValues[$hashCode] = (object) [ + 'value' => $value, + 'col' => $column, + 'rows' => [$row], + ]; + } else { + $hashedValues[$hashCode]->rows[] = $row; + } + } + + $mergedCoordCollection = []; + ksort($hashedValues); + + foreach ($hashedValues as $hashedValue) { + sort($hashedValue->rows); + $rowStart = null; + $rowEnd = null; + $ranges = []; + + foreach ($hashedValue->rows as $row) { + if ($rowStart === null) { + $rowStart = $row; + $rowEnd = $row; + } elseif ($rowEnd === $row - 1) { + $rowEnd = $row; + } else { + if ($rowStart == $rowEnd) { + $ranges[] = $hashedValue->col . $rowStart; + } else { + $ranges[] = $hashedValue->col . $rowStart . ':' . $hashedValue->col . $rowEnd; + } + + $rowStart = $row; + $rowEnd = $row; + } + } + + if ($rowStart !== null) { + if ($rowStart == $rowEnd) { + $ranges[] = $hashedValue->col . $rowStart; + } else { + $ranges[] = $hashedValue->col . $rowStart . ':' . $hashedValue->col . $rowEnd; + } + } + + foreach ($ranges as $range) { + $mergedCoordCollection[$range] = $hashedValue->value; + } + } + + return $mergedCoordCollection; + } + /** * Compare 2 cells. * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index a1a97865..dfaea5a0 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -565,6 +565,7 @@ class Worksheet extends WriterPart // Write data validations? if (!empty($dataValidationCollection)) { + $dataValidationCollection = Cell::mergeRangesInCollection($dataValidationCollection); $objWriter->startElement('dataValidations'); $objWriter->writeAttribute('count', count($dataValidationCollection)); diff --git a/tests/PhpSpreadsheetTests/CellTest.php b/tests/PhpSpreadsheetTests/CellTest.php index 118978f9..3a7d429e 100644 --- a/tests/PhpSpreadsheetTests/CellTest.php +++ b/tests/PhpSpreadsheetTests/CellTest.php @@ -300,4 +300,20 @@ class CellTest extends PHPUnit_Framework_TestCase { return require 'data/CellExtractAllCellReferencesInRange.php'; } + + /** + * @dataProvider providerMergeRangesInCollection + * + * @param mixed $expectedResult + */ + public function testMergeRangesInCollection($expectedResult, ...$args) + { + $result = Cell::mergeRangesInCollection(...$args); + $this->assertEquals($expectedResult, $result); + } + + public function providerMergeRangesInCollection() + { + return require 'data/CellMergeRangesInCollection.php'; + } } diff --git a/tests/data/CellMergeRangesInCollection.php b/tests/data/CellMergeRangesInCollection.php new file mode 100644 index 00000000..9cb71125 --- /dev/null +++ b/tests/data/CellMergeRangesInCollection.php @@ -0,0 +1,58 @@ + 'x', + 'A4' => 'y', + ], + [ + 'A1' => 'x', + 'A2' => 'x', + 'A3' => 'x', + 'A4' => 'y', + ], + ], + [ + [ + 'A1:A4' => 'x', + 'A6:A7' => 'x', + 'A9' => 'x', + ], + [ + 'A7' => 'x', + 'A1' => 'x', + 'A4' => 'x', + 'A6' => 'x', + 'A2' => 'x', + 'A9' => 'x', + 'A3' => 'x', + ], + ], + [ + [ + 'A1:A3' => 'x', + 'B1:B3' => 'x', + ], + [ + 'A1' => 'x', + 'B3' => 'x', + 'A2' => 'x', + 'B2' => 'x', + 'A3' => 'x', + 'B1' => 'x', + ], + ], + [ + [ + 'A1' => 'x', + 'A2' => 'y', + 'A3' => 'z', + ], + [ + 'A1' => 'x', + 'A2' => 'y', + 'A3' => 'z', + ], + ], +]; From e6c95bf9b0400b2af07372dde2914c01b7880542 Mon Sep 17 00:00:00 2001 From: CrazyBite Date: Wed, 3 May 2017 15:53:07 +0300 Subject: [PATCH 24/31] Added fillColor for chart plot series For now it is only to write to Xlsx Closes #158 --- CHANGELOG.md | 2 + src/PhpSpreadsheet/Chart/DataSeriesValues.php | 39 ++++++++++++++++++- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 14 +++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94204fa6..28c6adcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Support for chart fill color - @CrazyBite [#158](https://github.com/PHPOffice/PhpSpreadsheet/pull/158) + ### Changed - Merge data-validations to reduce written worksheet size - @billblume [#131](https://github.com/PHPOffice/PhpSpreadSheet/issues/131) diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 4fee7c28..76c86793 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -81,17 +81,26 @@ class DataSeriesValues */ private $dataValues = []; + /** + * Fill color. + * + * @var string + */ + private $fillColor; + /** * Create a new DataSeriesValues object. * + * * @param mixed $dataType * @param string $dataSource * @param null|mixed $formatCode * @param mixed $pointCount * @param mixed $dataValues * @param null|mixed $marker + * @param null|string $fillColor */ - public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null) + public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $fillColor = null) { $this->setDataType($dataType); $this->dataSource = $dataSource; @@ -99,6 +108,7 @@ class DataSeriesValues $this->pointCount = $pointCount; $this->dataValues = $dataValues; $this->pointMarker = $marker; + $this->fillColor = $fillColor; } /** @@ -217,6 +227,33 @@ class DataSeriesValues return $this->pointCount; } + /** + * Get fill color. + * + * @return string HEX color + */ + public function getFillColor() + { + return $this->fillColor; + } + + /** + * Set fill color for series. + * + * @param string $color HEX color + * + * @return DataSeriesValues + */ + public function setFillColor($color) + { + if (!preg_match('/^[a-f0-9]{6}$/i', $color)) { + throw new Exception('Invalid hex color for chart series'); + } + $this->fillColor = $color; + + return $this; + } + /** * Identify if the Data Series is a multi-level or a simple series. * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index a86b1a88..6f7f58d5 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -1098,6 +1098,20 @@ class Chart extends WriterPart foreach ($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) { $objWriter->startElement('c:ser'); + $plotLabel = $plotGroup->getPlotLabelByIndex($plotSeriesIdx); + if ($plotLabel) { + $fillColor = $plotLabel->getFillColor(); + if ($fillColor !== null) { + $objWriter->startElement('c:spPr'); + $objWriter->startElement('a:solidFill'); + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', $fillColor); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + $objWriter->startElement('c:idx'); $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx); $objWriter->endElement(); From 1c5db4e17052f19cd8bbed00d20f9ee394d04cd5 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Sep 2017 02:56:23 +0900 Subject: [PATCH 25/31] Standardize keys used for styling Array keys used for styling have been standardized for a more coherent experience. It now uses the same wording and casing as the getter and setter methods. Closes #189 --- CHANGELOG.md | 6 +- docs/topics/migration-from-PHPExcel.md | 71 +++++++++++++++ docs/topics/recipes.md | 40 ++++----- samples/22_Heavily_formatted.php | 8 +- samples/23_Sharedstyles.php | 12 +-- samples/templates/sampleSpreadsheet.php | 16 ++-- src/PhpSpreadsheet/Helper/Html.php | 4 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 88 +++++++++---------- src/PhpSpreadsheet/Reader/Html.php | 6 +- src/PhpSpreadsheet/Reader/Slk.php | 18 ++-- src/PhpSpreadsheet/Reader/Xls.php | 14 +-- src/PhpSpreadsheet/Reader/Xlsx.php | 10 +-- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 4 +- src/PhpSpreadsheet/Reader/Xml.php | 8 +- src/PhpSpreadsheet/Style.php | 18 ++-- src/PhpSpreadsheet/Style/Alignment.php | 36 ++++---- src/PhpSpreadsheet/Style/Border.php | 25 ++---- src/PhpSpreadsheet/Style/Borders.php | 24 ++--- src/PhpSpreadsheet/Style/Color.php | 14 +-- src/PhpSpreadsheet/Style/Fill.php | 20 ++--- src/PhpSpreadsheet/Style/Font.php | 62 ++++++------- src/PhpSpreadsheet/Style/NumberFormat.php | 12 +-- src/PhpSpreadsheet/Writer/Html.php | 12 +-- src/PhpSpreadsheet/Writer/Xls/Font.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 8 +- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 2 +- .../Writer/Xlsx/StringTable.php | 6 +- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 10 +-- .../PhpSpreadsheetTests/Style/BorderTest.php | 26 ++++++ 29 files changed, 329 insertions(+), 255 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Style/BorderTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c6adcf..e7dfefca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) @@ -16,6 +17,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +### BREAKING CHANGE + +- Standardization of array keys used for style, see the [migration guide](./docs/topics/migration-from-PHPExcel.md). ## [1.0.0-beta] - 2017-08-17 @@ -50,7 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Introduction of namespaces for all classes, eg: `PHPExcel_Calculation_Functions` becomes `PhpOffice\PhpSpreadsheet\Calculation\Functions` - Some classes were renamed for clarity and/or consistency: -For a comprehensive list of all class changes, and a semi-automated migration path, read the [migration guide](./docs/Migration-from-PHPExcel.md). +For a comprehensive list of all class changes, and a semi-automated migration path, read the [migration guide](./docs/topics/migration-from-PHPExcel.md). - Dropped `PHPExcel_Calculation_Functions::VERSION()`. Composer or git should be used to know the version. - Dropped `PHPExcel_Settings::setPdfRenderer()` and `PHPExcel_Settings::setPdfRenderer()`. Composer should be used to autoload PDF libs. diff --git a/docs/topics/migration-from-PHPExcel.md b/docs/topics/migration-from-PHPExcel.md index c34fba7f..04374959 100644 --- a/docs/topics/migration-from-PHPExcel.md +++ b/docs/topics/migration-from-PHPExcel.md @@ -192,3 +192,74 @@ $cell = $worksheet->setCellValue('A1', 'value', true); // After $cell = $worksheet->getCell('A1')->setValue('value'); ``` + +## Standardized keys for styling + +Array keys used for styling have been standardized for a more coherent experience. +It now uses the same wording and casing as the getter and setter: + +```php +// Before +$style = [ + 'numberformat' => [ + 'code' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE, + ], + 'font' => [ + 'strike' => true, + 'superScript' => true, + 'subScript' => true, + ], + 'alignment' => [ + 'rotation' => 90, + 'readorder' => Alignment::READORDER_RTL, + 'wrap' => true, + ], + 'borders' => [ + 'diagonaldirection' => Borders::DIAGONAL_BOTH, + 'allborders' => [ + 'style' => Border::BORDER_THIN, + ], + ], + 'fill' => [ + 'type' => Fill::FILL_GRADIENT_LINEAR, + 'startcolor' => [ + 'argb' => 'FFA0A0A0', + ], + 'endcolor' => [ + 'argb' => 'FFFFFFFF', + ], + ], +]; + +// After +$style = [ + 'numberFormat' => [ + 'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE, + ], + 'font' => [ + 'strikethrough' => true, + 'superscript' => true, + 'subscript' => true, + ], + 'alignment' => [ + 'textRotation' => 90, + 'readOrder' => Alignment::READORDER_RTL, + 'wrapText' => true, + ], + 'borders' => [ + 'diagonalDirection' => Borders::DIAGONAL_BOTH, + 'allBorders' => [ + 'borderStyle' => Border::BORDER_THIN, + ], + ], + 'fill' => [ + 'fillType' => Fill::FILL_GRADIENT_LINEAR, + 'startColor' => [ + 'argb' => 'FFA0A0A0', + ], + 'endColor' => [ + 'argb' => 'FFFFFFFF', + ], + ], +]; +``` diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index db2fa417..a7823f6a 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -558,16 +558,16 @@ $styleArray = array( ), 'borders' => array( 'top' => array( - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, ), ), 'fill' => array( - 'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR, + 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, - 'startcolor' => array( + 'startColor' => array( 'argb' => 'FFA0A0A0', ), - 'endcolor' => array( + 'endColor' => array( 'argb' => 'FFFFFFFF', ), ), @@ -693,7 +693,7 @@ B2:G8. $styleArray = array( 'borders' => array( 'outline' => array( - 'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK, + 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK, 'color' => array('argb' => 'FFFF0000'), ), ), @@ -721,7 +721,7 @@ operating on a single cell at a time: Additional shortcut borders come in handy like in the example above. These are the shortcut borders available: -- allborders +- allBorders - outline - inside - vertical @@ -731,10 +731,10 @@ An overview of all border shortcuts can be seen in the following image: ![08-styling-border-options.png](./images/08-styling-border-options.png) -If you simultaneously set e.g. allborders and vertical, then we have +If you simultaneously set e.g. allBorders and vertical, then we have "overlapping" borders, and one of the components has to win over the other where there is border overlap. In PhpSpreadsheet, from weakest to -strongest borders, the list is as follows: allborders, outline/inside, +strongest borders, the list is as follows: allBorders, outline/inside, vertical/horizontal, left/right/top/bottom/diagonal. This border hierarchy can be utilized to achieve various effects in an @@ -757,17 +757,17 @@ fill | getFill() font | getFont() borders | getBorders() alignment | getAlignment() -numberformat | getNumberFormat() +numberFormat | getNumberFormat() protection | getProtection() **\PhpOffice\PhpSpreadsheet\Style\Fill** Array key | Maps to property -----------|------------------- -type | setFillType() +fillType | setFillType() rotation | setRotation() -startcolor | getStartColor() -endcolor | getEndColor() +startColor | getStartColor() +endColor | getEndColor() color | getStartColor() @@ -779,17 +779,17 @@ name | setName() bold | setBold() italic | setItalic() underline | setUnderline() -strike | setStrikethrough() +strikethrough | setStrikethrough() color | getColor() size | setSize() -superScript | setSuperScript() -subScript | setSubScript() +superscript | setSuperscript() +subscript | setSubscript() **\PhpOffice\PhpSpreadsheet\Style\Borders** Array key | Maps to property ------------------|------------------- -allborders | getLeft(); getRight(); getTop(); getBottom() +allBorders | getLeft(); getRight(); getTop(); getBottom() left | getLeft() right | getRight() top | getTop() @@ -797,7 +797,7 @@ bottom | getBottom() diagonal | getDiagonal() vertical | getVertical() horizontal | getHorizontal() -diagonaldirection | setDiagonalDirection() +diagonalDirection | setDiagonalDirection() outline | setOutline() **\PhpOffice\PhpSpreadsheet\Style\Border** @@ -813,8 +813,8 @@ Array key | Maps to property ------------|------------------- horizontal | setHorizontal() vertical | setVertical() -rotation | setTextRotation() -wrap | setWrapText() +textRotation| setTextRotation() +wrapText | setWrapText() shrinkToFit | setShrinkToFit() indent | setIndent() @@ -822,7 +822,7 @@ indent | setIndent() Array key | Maps to property ----------|------------------- -code | setFormatCode() +formatCode | setFormatCode() **\PhpOffice\PhpSpreadsheet\Style\Protection** diff --git a/samples/22_Heavily_formatted.php b/samples/22_Heavily_formatted.php index ea4cd804..feb2d957 100644 --- a/samples/22_Heavily_formatted.php +++ b/samples/22_Heavily_formatted.php @@ -26,19 +26,19 @@ $spreadsheet->setActiveSheetIndex(0); $spreadsheet->getActiveSheet()->getStyle('A1:T100')->applyFromArray( ['fill' => [ - 'type' => Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFCCFFCC'], ], 'borders' => [ - 'bottom' => ['style' => Border::BORDER_THIN], - 'right' => ['style' => Border::BORDER_MEDIUM], + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], ], ] ); $spreadsheet->getActiveSheet()->getStyle('C5:R95')->applyFromArray( ['fill' => [ - 'type' => Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFFFFF00'], ], ] diff --git a/samples/23_Sharedstyles.php b/samples/23_Sharedstyles.php index 74e3d8d6..1405431c 100644 --- a/samples/23_Sharedstyles.php +++ b/samples/23_Sharedstyles.php @@ -30,24 +30,24 @@ $sharedStyle2 = new Style(); $sharedStyle1->applyFromArray( ['fill' => [ - 'type' => Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFCCFFCC'], ], 'borders' => [ - 'bottom' => ['style' => Border::BORDER_THIN], - 'right' => ['style' => Border::BORDER_MEDIUM], + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], ], ] ); $sharedStyle2->applyFromArray( ['fill' => [ - 'type' => Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'color' => ['argb' => 'FFFFFF00'], ], 'borders' => [ - 'bottom' => ['style' => Border::BORDER_THIN], - 'right' => ['style' => Border::BORDER_MEDIUM], + 'bottom' => ['borderStyle' => Border::BORDER_THIN], + 'right' => ['borderStyle' => Border::BORDER_MEDIUM], ], ] ); diff --git a/samples/templates/sampleSpreadsheet.php b/samples/templates/sampleSpreadsheet.php index 0ab6ebc1..3a6c02d8 100644 --- a/samples/templates/sampleSpreadsheet.php +++ b/samples/templates/sampleSpreadsheet.php @@ -156,7 +156,7 @@ $helper->log('Set thin black border outline around column'); $styleThinBlackBorderOutline = [ 'borders' => [ 'outline' => [ - 'style' => Border::BORDER_THIN, + 'borderStyle' => Border::BORDER_THIN, 'color' => ['argb' => 'FF000000'], ], ], @@ -168,7 +168,7 @@ $helper->log('Set thick brown border outline around Total'); $styleThickBrownBorderOutline = [ 'borders' => [ 'outline' => [ - 'style' => Border::BORDER_THICK, + 'borderStyle' => Border::BORDER_THICK, 'color' => ['argb' => 'FF993300'], ], ], @@ -192,16 +192,16 @@ $spreadsheet->getActiveSheet()->getStyle('A3:E3')->applyFromArray( ], 'borders' => [ 'top' => [ - 'style' => Border::BORDER_THIN, + 'borderStyle' => Border::BORDER_THIN, ], ], 'fill' => [ - 'type' => Fill::FILL_GRADIENT_LINEAR, + 'fillType' => Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, - 'startcolor' => [ + 'startColor' => [ 'argb' => 'FFA0A0A0', ], - 'endcolor' => [ + 'endColor' => [ 'argb' => 'FFFFFFFF', ], ], @@ -215,7 +215,7 @@ $spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray( ], 'borders' => [ 'left' => [ - 'style' => Border::BORDER_THIN, + 'borderStyle' => Border::BORDER_THIN, ], ], ] @@ -233,7 +233,7 @@ $spreadsheet->getActiveSheet()->getStyle('E3')->applyFromArray( [ 'borders' => [ 'right' => [ - 'style' => Border::BORDER_THIN, + 'borderStyle' => Border::BORDER_THIN, ], ], ] diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index a968a931..a78be230 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -678,10 +678,10 @@ class Html $richtextRun->getFont()->setUnderline(Font::UNDERLINE_SINGLE); } if ($this->superscript) { - $richtextRun->getFont()->setSuperScript(true); + $richtextRun->getFont()->setSuperscript(true); } if ($this->subscript) { - $richtextRun->getFont()->setSubScript(true); + $richtextRun->getFont()->setSubscript(true); } if ($this->strikethrough) { $richtextRun->getFont()->setStrikethrough(true); diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index e1bef14f..a153e0c7 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -486,7 +486,7 @@ class Gnumeric extends BaseReader implements IReader if ((!$this->readDataOnly) || (Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { $styleArray = []; - $styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; + $styleArray['numberFormat']['formatCode'] = (string) $styleAttributes['Format']; // If readDataOnly is false, we set all formatting information if (!$this->readDataOnly) { switch ($styleAttributes['HAlign']) { @@ -526,7 +526,7 @@ class Gnumeric extends BaseReader implements IReader break; } - $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false; + $styleArray['alignment']['wrapText'] = ($styleAttributes['WrapText'] == '1') ? true : false; $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0; @@ -535,69 +535,69 @@ class Gnumeric extends BaseReader implements IReader $RGB = self::parseGnumericColour($styleAttributes['Back']); $shade = $styleAttributes['Shade']; if (($RGB != '000000') || ($shade != '0')) { - $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB; + $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startColor']['rgb'] = $RGB; $RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']); - $styleArray['fill']['endcolor']['rgb'] = $RGB2; + $styleArray['fill']['endColor']['rgb'] = $RGB2; switch ($shade) { case '1': - $styleArray['fill']['type'] = Fill::FILL_SOLID; + $styleArray['fill']['fillType'] = Fill::FILL_SOLID; break; case '2': - $styleArray['fill']['type'] = Fill::FILL_GRADIENT_LINEAR; + $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_LINEAR; break; case '3': - $styleArray['fill']['type'] = Fill::FILL_GRADIENT_PATH; + $styleArray['fill']['fillType'] = Fill::FILL_GRADIENT_PATH; break; case '4': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKDOWN; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKDOWN; break; case '5': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKGRAY; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRAY; break; case '6': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKGRID; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKGRID; break; case '7': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKHORIZONTAL; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKHORIZONTAL; break; case '8': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKTRELLIS; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKTRELLIS; break; case '9': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKUP; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKUP; break; case '10': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_DARKVERTICAL; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_DARKVERTICAL; break; case '11': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_GRAY0625; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY0625; break; case '12': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_GRAY125; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125; break; case '13': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTDOWN; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTDOWN; break; case '14': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTGRAY; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRAY; break; case '15': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTGRID; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTGRID; break; case '16': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTHORIZONTAL; break; case '17': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTTRELLIS; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTTRELLIS; break; case '18': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTUP; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTUP; break; case '19': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_LIGHTVERTICAL; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_LIGHTVERTICAL; break; case '20': - $styleArray['fill']['type'] = Fill::FILL_PATTERN_MEDIUMGRAY; + $styleArray['fill']['fillType'] = Fill::FILL_PATTERN_MEDIUMGRAY; break; } } @@ -607,7 +607,7 @@ class Gnumeric extends BaseReader implements IReader $styleArray['font']['size'] = (int) ($fontAttributes['Unit']); $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false; $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false; - $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; + $styleArray['font']['strikethrough'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; switch ($fontAttributes['Underline']) { case '1': $styleArray['font']['underline'] = Font::UNDERLINE_SINGLE; @@ -627,10 +627,10 @@ class Gnumeric extends BaseReader implements IReader } switch ($fontAttributes['Script']) { case '1': - $styleArray['font']['superScript'] = true; + $styleArray['font']['superscript'] = true; break; case '-1': - $styleArray['font']['subScript'] = true; + $styleArray['font']['subscript'] = true; break; } @@ -649,13 +649,13 @@ class Gnumeric extends BaseReader implements IReader } if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_BOTH; + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_BOTH; } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); - $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_UP; + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_UP; } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) { $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes()); - $styleArray['borders']['diagonaldirection'] = Borders::DIAGONAL_DOWN; + $styleArray['borders']['diagonalDirection'] = Borders::DIAGONAL_DOWN; } } if (isset($styleRegion->Style->HyperLink)) { @@ -770,46 +770,46 @@ class Gnumeric extends BaseReader implements IReader switch ($borderAttributes['Style']) { case '0': - $styleArray['style'] = Border::BORDER_NONE; + $styleArray['borderStyle'] = Border::BORDER_NONE; break; case '1': - $styleArray['style'] = Border::BORDER_THIN; + $styleArray['borderStyle'] = Border::BORDER_THIN; break; case '2': - $styleArray['style'] = Border::BORDER_MEDIUM; + $styleArray['borderStyle'] = Border::BORDER_MEDIUM; break; case '3': - $styleArray['style'] = Border::BORDER_SLANTDASHDOT; + $styleArray['borderStyle'] = Border::BORDER_SLANTDASHDOT; break; case '4': - $styleArray['style'] = Border::BORDER_DASHED; + $styleArray['borderStyle'] = Border::BORDER_DASHED; break; case '5': - $styleArray['style'] = Border::BORDER_THICK; + $styleArray['borderStyle'] = Border::BORDER_THICK; break; case '6': - $styleArray['style'] = Border::BORDER_DOUBLE; + $styleArray['borderStyle'] = Border::BORDER_DOUBLE; break; case '7': - $styleArray['style'] = Border::BORDER_DOTTED; + $styleArray['borderStyle'] = Border::BORDER_DOTTED; break; case '8': - $styleArray['style'] = Border::BORDER_MEDIUMDASHED; + $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHED; break; case '9': - $styleArray['style'] = Border::BORDER_DASHDOT; + $styleArray['borderStyle'] = Border::BORDER_DASHDOT; break; case '10': - $styleArray['style'] = Border::BORDER_MEDIUMDASHDOT; + $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOT; break; case '11': - $styleArray['style'] = Border::BORDER_DASHDOTDOT; + $styleArray['borderStyle'] = Border::BORDER_DASHDOTDOT; break; case '12': - $styleArray['style'] = Border::BORDER_MEDIUMDASHDOTDOT; + $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; break; case '13': - $styleArray['style'] = Border::BORDER_MEDIUMDASHDOTDOT; + $styleArray['borderStyle'] = Border::BORDER_MEDIUMDASHDOTDOT; break; } diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 67dfa184..6136ad4c 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -110,7 +110,7 @@ class Html extends BaseReader implements IReader 'hr' => [ 'borders' => [ 'bottom' => [ - 'style' => Border::BORDER_THIN, + 'borderStyle' => Border::BORDER_THIN, 'color' => [ Color::COLOR_BLACK, ], @@ -482,7 +482,7 @@ class Html extends BaseReader implements IReader $sheet->getStyle($column . $row)->applyFromArray( [ 'fill' => [ - 'type' => Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => $attributeArray['bgcolor']], ], ] @@ -631,7 +631,7 @@ class Html extends BaseReader implements IReader switch (trim($value[0])) { case 'background-color': - $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['type' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); + $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); break; case 'color': $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]); diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 5a0950a6..6ed4839b 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -260,7 +260,7 @@ class Slk extends BaseReader implements IReader foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { case 'P': - $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); + $formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); break; case 'E': case 'F': @@ -280,16 +280,16 @@ class Slk extends BaseReader implements IReader $formatArray['font']['bold'] = true; break; case 'T': - $formatArray['borders']['top']['style'] = Border::BORDER_THIN; + $formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN; break; case 'B': - $formatArray['borders']['bottom']['style'] = Border::BORDER_THIN; + $formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; break; case 'L': - $formatArray['borders']['left']['style'] = Border::BORDER_THIN; + $formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN; break; case 'R': - $formatArray['borders']['right']['style'] = Border::BORDER_THIN; + $formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN; break; } } @@ -401,16 +401,16 @@ class Slk extends BaseReader implements IReader $styleData['font']['bold'] = true; break; case 'T': - $styleData['borders']['top']['style'] = Border::BORDER_THIN; + $styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN; break; case 'B': - $styleData['borders']['bottom']['style'] = Border::BORDER_THIN; + $styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN; break; case 'L': - $styleData['borders']['left']['style'] = Border::BORDER_THIN; + $styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN; break; case 'R': - $styleData['borders']['right']['style'] = Border::BORDER_THIN; + $styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN; break; } } diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index b8a9f60c..24c46f66 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1942,7 +1942,7 @@ class Xls extends BaseReader implements IReader } // bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8) - // bit: 3; mask 0x0008; strike + // bit: 3; mask 0x0008; strikethrough $isStrike = (0x0008 & self::getInt2d($recordData, 2)) >> 3; if ($isStrike) { $objFont->setStrikethrough(true); @@ -1964,10 +1964,10 @@ class Xls extends BaseReader implements IReader $escapement = self::getInt2d($recordData, 8); switch ($escapement) { case 0x0001: - $objFont->setSuperScript(true); + $objFont->setSuperscript(true); break; case 0x0002: - $objFont->setSubScript(true); + $objFont->setSubscript(true); break; } @@ -2081,15 +2081,15 @@ class Xls extends BaseReader implements IReader $numberFormatIndex = self::getInt2d($recordData, 2); if (isset($this->formats[$numberFormatIndex])) { // then we have user-defined format code - $numberformat = ['code' => $this->formats[$numberFormatIndex]]; + $numberFormat = ['formatCode' => $this->formats[$numberFormatIndex]]; } elseif (($code = NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') { // then we have built-in format code - $numberformat = ['code' => $code]; + $numberFormat = ['formatCode' => $code]; } else { // we set the general format code - $numberformat = ['code' => 'General']; + $numberFormat = ['formatCode' => 'General']; } - $objStyle->getNumberFormat()->setFormatCode($numberformat['code']); + $objStyle->getNumberFormat()->setFormatCode($numberFormat['formatCode']); // offset: 4; size: 2; XF type, cell protection, and parent style XF // bit 2-0; mask 0x0007; XF_TYPE_PROT diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 57af0a58..5b4b3e92 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1918,10 +1918,10 @@ class Xlsx extends BaseReader implements IReader if (isset($style->font->vertAlign) && isset($style->font->vertAlign['val'])) { $vertAlign = strtolower((string) $style->font->vertAlign['val']); if ($vertAlign == 'superscript') { - $docStyle->getFont()->setSuperScript(true); + $docStyle->getFont()->setSuperscript(true); } if ($vertAlign == 'subscript') { - $docStyle->getFont()->setSubScript(true); + $docStyle->getFont()->setSubscript(true); } } } @@ -1988,7 +1988,7 @@ class Xlsx extends BaseReader implements IReader $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment['wrapText'])); $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment['shrinkToFit'])); $docStyle->getAlignment()->setIndent((int) ((string) $style->alignment['indent']) > 0 ? (int) ((string) $style->alignment['indent']) : 0); - $docStyle->getAlignment()->setReadorder((int) ((string) $style->alignment['readingOrder']) > 0 ? (int) ((string) $style->alignment['readingOrder']) : 0); + $docStyle->getAlignment()->setReadOrder((int) ((string) $style->alignment['readingOrder']) > 0 ? (int) ((string) $style->alignment['readingOrder']) : 0); } // protection @@ -2069,10 +2069,10 @@ class Xlsx extends BaseReader implements IReader if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign['val'])) { $vertAlign = strtolower((string) $run->rPr->vertAlign['val']); if ($vertAlign == 'superscript') { - $objText->getFont()->setSuperScript(true); + $objText->getFont()->setSuperscript(true); } if ($vertAlign == 'subscript') { - $objText->getFont()->setSubScript(true); + $objText->getFont()->setSubscript(true); } } if (isset($run->rPr->u) && !isset($run->rPr->u['val'])) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 2e6c1d84..6e9e1df0 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -445,9 +445,9 @@ class Chart $baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer'); if (!is_null($baseline)) { if ($baseline > 0) { - $objText->getFont()->setSuperScript(true); + $objText->getFont()->setSuperscript(true); } elseif ($baseline < 0) { - $objText->getFont()->setSubScript(true); + $objText->getFont()->setSubscript(true); } } diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 7c445fee..d9368d02 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -441,7 +441,7 @@ class Xml extends BaseReader implements IReader } break; case 'WrapText': - $this->styles[$styleID]['alignment']['wrap'] = true; + $this->styles[$styleID]['alignment']['wrapText'] = true; break; } } @@ -453,7 +453,7 @@ class Xml extends BaseReader implements IReader foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { switch ($borderStyleKey) { case 'LineStyle': - $thisBorder['style'] = Border::BORDER_MEDIUM; + $thisBorder['borderStyle'] = Border::BORDER_MEDIUM; break; case 'Weight': break; @@ -507,7 +507,7 @@ class Xml extends BaseReader implements IReader $this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1); break; case 'Pattern': - $this->styles[$styleID]['fill']['type'] = strtolower($styleAttributeValue); + $this->styles[$styleID]['fill']['fillType'] = strtolower($styleAttributeValue); break; } } @@ -521,7 +521,7 @@ class Xml extends BaseReader implements IReader break; } if ($styleAttributeValue > '') { - $this->styles[$styleID]['numberformat']['code'] = $styleAttributeValue; + $this->styles[$styleID]['numberFormat']['formatCode'] = $styleAttributeValue; } } break; diff --git a/src/PhpSpreadsheet/Style.php b/src/PhpSpreadsheet/Style.php index 8f7f9407..235d4a15 100644 --- a/src/PhpSpreadsheet/Style.php +++ b/src/PhpSpreadsheet/Style.php @@ -177,20 +177,20 @@ class Style extends Style\Supervisor implements IComparable * 'bold' => true, * 'italic' => false, * 'underline' => \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE, - * 'strike' => false, + * 'strikethrough' => false, * 'color' => array( * 'rgb' => '808080' * ) * ), * 'borders' => array( * 'bottom' => array( - * 'style' => Border::BORDER_DASHDOT, + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) * ), * 'top' => array( - * 'style' => Border::BORDER_DASHDOT, + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -241,15 +241,15 @@ class Style extends Style\Supervisor implements IComparable // ADVANCED MODE: if ($pAdvanced && isset($pStyles['borders'])) { - // 'allborders' is a shorthand property for 'outline' and 'inside' and + // 'allBorders' is a shorthand property for 'outline' and 'inside' and // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['allborders'])) { + if (isset($pStyles['borders']['allBorders'])) { foreach (['outline', 'inside'] as $component) { if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['allborders']; + $pStyles['borders'][$component] = $pStyles['borders']['allBorders']; } } - unset($pStyles['borders']['allborders']); // not needed any more + unset($pStyles['borders']['allBorders']); // not needed any more } // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' // it applies to components that have not been set explicitly @@ -452,8 +452,8 @@ class Style extends Style\Supervisor implements IComparable if (isset($pStyles['alignment'])) { $this->getAlignment()->applyFromArray($pStyles['alignment']); } - if (isset($pStyles['numberformat'])) { - $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); + if (isset($pStyles['numberFormat'])) { + $this->getNumberFormat()->applyFromArray($pStyles['numberFormat']); } if (isset($pStyles['protection'])) { $this->getProtection()->applyFromArray($pStyles['protection']); diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 6ea74462..7f6c171c 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -98,7 +98,7 @@ class Alignment extends Supervisor implements IComparable * * @var int */ - protected $readorder = 0; + protected $readOrder = 0; /** * Create a new Alignment. @@ -152,8 +152,8 @@ class Alignment extends Supervisor implements IComparable * array( * 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, * 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, - * 'rotation' => 0, - * 'wrap' => TRUE + * 'textRotation' => 0, + * 'wrapText' => TRUE * ) * ); * . @@ -176,11 +176,11 @@ class Alignment extends Supervisor implements IComparable if (isset($pStyles['vertical'])) { $this->setVertical($pStyles['vertical']); } - if (isset($pStyles['rotation'])) { - $this->setTextRotation($pStyles['rotation']); + if (isset($pStyles['textRotation'])) { + $this->setTextRotation($pStyles['textRotation']); } - if (isset($pStyles['wrap'])) { - $this->setWrapText($pStyles['wrap']); + if (isset($pStyles['wrapText'])) { + $this->setWrapText($pStyles['wrapText']); } if (isset($pStyles['shrinkToFit'])) { $this->setShrinkToFit($pStyles['shrinkToFit']); @@ -188,8 +188,8 @@ class Alignment extends Supervisor implements IComparable if (isset($pStyles['indent'])) { $this->setIndent($pStyles['indent']); } - if (isset($pStyles['readorder'])) { - $this->setReadorder($pStyles['readorder']); + if (isset($pStyles['readOrder'])) { + $this->setReadOrder($pStyles['readOrder']); } } @@ -303,7 +303,7 @@ class Alignment extends Supervisor implements IComparable // Set rotation if (($pValue >= -90 && $pValue <= 90) || $pValue == -165) { if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['rotation' => $pValue]); + $styleArray = $this->getStyleArray(['textRotation' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->textRotation = $pValue; @@ -342,7 +342,7 @@ class Alignment extends Supervisor implements IComparable $pValue = false; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['wrap' => $pValue]); + $styleArray = $this->getStyleArray(['wrapText' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->wrapText = $pValue; @@ -432,13 +432,13 @@ class Alignment extends Supervisor implements IComparable * * @return int */ - public function getReadorder() + public function getReadOrder() { if ($this->isSupervisor) { - return $this->getSharedComponent()->getReadorder(); + return $this->getSharedComponent()->getReadOrder(); } - return $this->readorder; + return $this->readOrder; } /** @@ -448,16 +448,16 @@ class Alignment extends Supervisor implements IComparable * * @return Alignment */ - public function setReadorder($pValue) + public function setReadOrder($pValue) { if ($pValue < 0 || $pValue > 2) { $pValue = 0; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['readorder' => $pValue]); + $styleArray = $this->getStyleArray(['readOrder' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { - $this->readorder = $pValue; + $this->readOrder = $pValue; } return $this; @@ -481,7 +481,7 @@ class Alignment extends Supervisor implements IComparable ($this->wrapText ? 't' : 'f') . ($this->shrinkToFit ? 't' : 'f') . $this->indent . - $this->readorder . + $this->readOrder . __CLASS__ ); } diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 38246d47..b5169897 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -146,22 +146,7 @@ class Border extends Supervisor implements IComparable */ public function getStyleArray($array) { - switch ($this->parentPropertyName) { - case 'allborders': - case 'bottom': - case 'diagonal': - case 'horizontal': - case 'inside': - case 'left': - case 'outline': - case 'right': - case 'top': - case 'vertical': - $key = strtolower($this->parentPropertyName); - break; - } - - return $this->parent->getStyleArray([$key => $array]); + return $this->parent->getStyleArray([$this->parentPropertyName => $array]); } /** @@ -170,7 +155,7 @@ class Border extends Supervisor implements IComparable * * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray( * array( - * 'style' => Border::BORDER_DASHDOT, + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -189,8 +174,8 @@ class Border extends Supervisor implements IComparable if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (isset($pStyles['style'])) { - $this->setBorderStyle($pStyles['style']); + if (isset($pStyles['borderStyle'])) { + $this->setBorderStyle($pStyles['borderStyle']); } if (isset($pStyles['color'])) { $this->getColor()->applyFromArray($pStyles['color']); @@ -231,7 +216,7 @@ class Border extends Supervisor implements IComparable $pValue = self::BORDER_MEDIUM; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['style' => $pValue]); + $styleArray = $this->getStyleArray(['borderStyle' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->borderStyle = $pValue; diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 5f9f8486..a23bfb92 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -187,13 +187,13 @@ class Borders extends Supervisor implements IComparable * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( * array( * 'bottom' => array( - * 'style' => Border::BORDER_DASHDOT, + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) * ), * 'top' => array( - * 'style' => Border::BORDER_DASHDOT, + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -204,8 +204,8 @@ class Borders extends Supervisor implements IComparable * * $spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( * array( - * 'allborders' => array( - * 'style' => Border::BORDER_DASHDOT, + * 'allBorders' => array( + * 'borderStyle' => Border::BORDER_DASHDOT, * 'color' => array( * 'rgb' => '808080' * ) @@ -240,14 +240,14 @@ class Borders extends Supervisor implements IComparable if (isset($pStyles['diagonal'])) { $this->getDiagonal()->applyFromArray($pStyles['diagonal']); } - if (isset($pStyles['diagonaldirection'])) { - $this->setDiagonalDirection($pStyles['diagonaldirection']); + if (isset($pStyles['diagonalDirection'])) { + $this->setDiagonalDirection($pStyles['diagonalDirection']); } - if (isset($pStyles['allborders'])) { - $this->getLeft()->applyFromArray($pStyles['allborders']); - $this->getRight()->applyFromArray($pStyles['allborders']); - $this->getTop()->applyFromArray($pStyles['allborders']); - $this->getBottom()->applyFromArray($pStyles['allborders']); + if (isset($pStyles['allBorders'])) { + $this->getLeft()->applyFromArray($pStyles['allBorders']); + $this->getRight()->applyFromArray($pStyles['allBorders']); + $this->getTop()->applyFromArray($pStyles['allBorders']); + $this->getBottom()->applyFromArray($pStyles['allBorders']); } } @@ -411,7 +411,7 @@ class Borders extends Supervisor implements IComparable $pValue = self::DIAGONAL_NONE; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['diagonaldirection' => $pValue]); + $styleArray = $this->getStyleArray(['diagonalDirection' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->diagonalDirection = $pValue; diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index ec5e6ffb..59578791 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -127,19 +127,7 @@ class Color extends Supervisor implements IComparable */ public function getStyleArray($array) { - switch ($this->parentPropertyName) { - case 'endColor': - $key = 'endcolor'; - break; - case 'color': - $key = 'color'; - break; - case 'startColor': - $key = 'startcolor'; - break; - } - - return $this->parent->getStyleArray([$key => $array]); + return $this->parent->getStyleArray([$this->parentPropertyName => $array]); } /** diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index dca4ea8d..a9a3111a 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -137,12 +137,12 @@ class Fill extends Supervisor implements IComparable * * $spreadsheet->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray( * array( - * 'type' => Fill::FILL_GRADIENT_LINEAR, + * 'fillType' => Fill::FILL_GRADIENT_LINEAR, * 'rotation' => 0, - * 'startcolor' => array( + * 'startColor' => array( * 'rgb' => '000000' * ), - * 'endcolor' => array( + * 'endColor' => array( * 'argb' => 'FFFFFFFF' * ) * ) @@ -160,17 +160,17 @@ class Fill extends Supervisor implements IComparable if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (isset($pStyles['type'])) { - $this->setFillType($pStyles['type']); + if (isset($pStyles['fillType'])) { + $this->setFillType($pStyles['fillType']); } if (isset($pStyles['rotation'])) { $this->setRotation($pStyles['rotation']); } - if (isset($pStyles['startcolor'])) { - $this->getStartColor()->applyFromArray($pStyles['startcolor']); + if (isset($pStyles['startColor'])) { + $this->getStartColor()->applyFromArray($pStyles['startColor']); } - if (isset($pStyles['endcolor'])) { - $this->getEndColor()->applyFromArray($pStyles['endcolor']); + if (isset($pStyles['endColor'])) { + $this->getEndColor()->applyFromArray($pStyles['endColor']); } if (isset($pStyles['color'])) { $this->getStartColor()->applyFromArray($pStyles['color']); @@ -205,7 +205,7 @@ class Fill extends Supervisor implements IComparable public function setFillType($pValue) { if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['type' => $pValue]); + $styleArray = $this->getStyleArray(['fillType' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->fillType = $pValue; diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index c51a945c..d13b3172 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -69,14 +69,14 @@ class Font extends Supervisor implements IComparable * * @var bool */ - protected $superScript = false; + protected $superscript = false; /** * Subscript. * * @var bool */ - protected $subScript = false; + protected $subscript = false; /** * Underline. @@ -120,8 +120,8 @@ class Font extends Supervisor implements IComparable $this->size = null; $this->bold = null; $this->italic = null; - $this->superScript = null; - $this->subScript = null; + $this->superscript = null; + $this->subscript = null; $this->underline = null; $this->strikethrough = null; $this->color = new Color(Color::COLOR_BLACK, $isSupervisor, $isConditional); @@ -166,7 +166,7 @@ class Font extends Supervisor implements IComparable * 'bold' => TRUE, * 'italic' => FALSE, * 'underline' => \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE, - * 'strike' => FALSE, + * 'strikethrough' => FALSE, * 'color' => array( * 'rgb' => '808080' * ) @@ -194,17 +194,17 @@ class Font extends Supervisor implements IComparable if (isset($pStyles['italic'])) { $this->setItalic($pStyles['italic']); } - if (isset($pStyles['superScript'])) { - $this->setSuperScript($pStyles['superScript']); + if (isset($pStyles['superscript'])) { + $this->setSuperscript($pStyles['superscript']); } - if (isset($pStyles['subScript'])) { - $this->setSubScript($pStyles['subScript']); + if (isset($pStyles['subscript'])) { + $this->setSubscript($pStyles['subscript']); } if (isset($pStyles['underline'])) { $this->setUnderline($pStyles['underline']); } - if (isset($pStyles['strike'])) { - $this->setStrikethrough($pStyles['strike']); + if (isset($pStyles['strikethrough'])) { + $this->setStrikethrough($pStyles['strikethrough']); } if (isset($pStyles['color'])) { $this->getColor()->applyFromArray($pStyles['color']); @@ -362,74 +362,74 @@ class Font extends Supervisor implements IComparable } /** - * Get SuperScript. + * Get Superscript. * * @return bool */ - public function getSuperScript() + public function getSuperscript() { if ($this->isSupervisor) { - return $this->getSharedComponent()->getSuperScript(); + return $this->getSharedComponent()->getSuperscript(); } - return $this->superScript; + return $this->superscript; } /** - * Set SuperScript. + * Set Superscript. * * @param bool $pValue * * @return Font */ - public function setSuperScript($pValue) + public function setSuperscript($pValue) { if ($pValue == '') { $pValue = false; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['superScript' => $pValue]); + $styleArray = $this->getStyleArray(['superscript' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { - $this->superScript = $pValue; - $this->subScript = !$pValue; + $this->superscript = $pValue; + $this->subscript = !$pValue; } return $this; } /** - * Get SubScript. + * Get Subscript. * * @return bool */ - public function getSubScript() + public function getSubscript() { if ($this->isSupervisor) { - return $this->getSharedComponent()->getSubScript(); + return $this->getSharedComponent()->getSubscript(); } - return $this->subScript; + return $this->subscript; } /** - * Set SubScript. + * Set Subscript. * * @param bool $pValue * * @return Font */ - public function setSubScript($pValue) + public function setSubscript($pValue) { if ($pValue == '') { $pValue = false; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['subScript' => $pValue]); + $styleArray = $this->getStyleArray(['subscript' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { - $this->subScript = $pValue; - $this->superScript = !$pValue; + $this->subscript = $pValue; + $this->superscript = !$pValue; } return $this; @@ -561,8 +561,8 @@ class Font extends Supervisor implements IComparable $this->size . ($this->bold ? 't' : 'f') . ($this->italic ? 't' : 'f') . - ($this->superScript ? 't' : 'f') . - ($this->subScript ? 't' : 'f') . + ($this->superscript ? 't' : 'f') . + ($this->subscript ? 't' : 'f') . $this->underline . ($this->strikethrough ? 't' : 'f') . $this->color->getHashCode() . diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 2d5bb178..ecd5778a 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -141,7 +141,7 @@ class NumberFormat extends Supervisor implements IComparable */ public function getStyleArray($array) { - return ['numberformat' => $array]; + return ['numberFormat' => $array]; } /** @@ -149,7 +149,7 @@ class NumberFormat extends Supervisor implements IComparable * * $spreadsheet->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray( * array( - * 'code' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE + * 'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE * ) * ); * . @@ -165,8 +165,8 @@ class NumberFormat extends Supervisor implements IComparable if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (isset($pStyles['code'])) { - $this->setFormatCode($pStyles['code']); + if (isset($pStyles['formatCode'])) { + $this->setFormatCode($pStyles['formatCode']); } } @@ -203,7 +203,7 @@ class NumberFormat extends Supervisor implements IComparable $pValue = self::FORMAT_GENERAL; } if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['code' => $pValue]); + $styleArray = $this->getStyleArray(['formatCode' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->formatCode = $pValue; @@ -237,7 +237,7 @@ class NumberFormat extends Supervisor implements IComparable public function setBuiltInFormatCode($pValue) { if ($this->isSupervisor) { - $styleArray = $this->getStyleArray(['code' => self::builtInFormatCode($pValue)]); + $styleArray = $this->getStyleArray(['formatCode' => self::builtInFormatCode($pValue)]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->builtInFormatCode = $pValue; diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index cadf20ba..46aace25 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1266,9 +1266,9 @@ class Html extends BaseWriter implements IWriter if ($element instanceof RichText\Run) { $cellData .= ''; - if ($element->getFont()->getSuperScript()) { + if ($element->getFont()->getSuperscript()) { $cellData .= ''; - } elseif ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubscript()) { $cellData .= ''; } } @@ -1278,9 +1278,9 @@ class Html extends BaseWriter implements IWriter $cellData .= htmlspecialchars($cellText); if ($element instanceof RichText\Run) { - if ($element->getFont()->getSuperScript()) { + if ($element->getFont()->getSuperscript()) { $cellData .= ''; - } elseif ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubscript()) { $cellData .= ''; } @@ -1302,9 +1302,9 @@ class Html extends BaseWriter implements IWriter ); } $cellData = htmlspecialchars($cellData); - if ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperScript()) { + if ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperscript()) { $cellData = '' . $cellData . ''; - } elseif ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSubScript()) { + } elseif ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSubscript()) { $cellData = '' . $cellData . ''; } } diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index d076fdcd..127bd331 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -74,9 +74,9 @@ class Font $font_shadow = 0; $icv = $this->colorIndex; // Index to color palette - if ($this->font->getSuperScript()) { + if ($this->font->getSuperscript()) { $sss = 1; - } elseif ($this->font->getSubScript()) { + } elseif ($this->font->getSubscript()) { $sss = 2; } else { $sss = 0; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 93423002..419d1121 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -3160,8 +3160,8 @@ class Worksheet extends BIFFwriter || $conditional->getStyle()->getFont()->getSize() != null || $conditional->getStyle()->getFont()->getBold() != null || $conditional->getStyle()->getFont()->getItalic() != null - || $conditional->getStyle()->getFont()->getSuperScript() != null - || $conditional->getStyle()->getFont()->getSubScript() != null + || $conditional->getStyle()->getFont()->getSuperscript() != null + || $conditional->getStyle()->getFont()->getSubscript() != null || $conditional->getStyle()->getFont()->getUnderline() != null || $conditional->getStyle()->getFont()->getStrikethrough() != null || $conditional->getStyle()->getFont()->getColor()->getARGB() != null) { @@ -3233,10 +3233,10 @@ class Worksheet extends BIFFwriter $dataBlockFont .= pack('v', 0x0190); } // Escapement type - if ($conditional->getStyle()->getFont()->getSubScript() == true) { + if ($conditional->getStyle()->getFont()->getSubscript() == true) { $dataBlockFont .= pack('v', 0x02); $fontEscapement = 0; - } elseif ($conditional->getStyle()->getFont()->getSuperScript() == true) { + } elseif ($conditional->getStyle()->getFont()->getSuperscript() == true) { $dataBlockFont .= pack('v', 0x01); $fontEscapement = 0; } else { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 41092f55..ca1272ae 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -477,7 +477,7 @@ class Drawing extends WriterPart // o:lock $objWriter->startElement('o:lock'); $objWriter->writeAttribute('v:ext', 'edit'); - $objWriter->writeAttribute('rotation', 't'); + $objWriter->writeAttribute('textRotation', 't'); $objWriter->endElement(); $objWriter->endElement(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 8b141e1b..aaa07e82 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -175,11 +175,11 @@ class StringTable extends WriterPart $objWriter->endElement(); // Superscript / subscript - if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) { + if ($element->getFont()->getSuperscript() || $element->getFont()->getSubscript()) { $objWriter->startElement($prefix . 'vertAlign'); - if ($element->getFont()->getSuperScript()) { + if ($element->getFont()->getSuperscript()) { $objWriter->writeAttribute('val', 'superscript'); - } elseif ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubscript()) { $objWriter->writeAttribute('val', 'subscript'); } $objWriter->endElement(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index da49970d..96779f3b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -320,11 +320,11 @@ class Style extends WriterPart } // Superscript / subscript - if ($pFont->getSuperScript() === true || $pFont->getSubScript() === true) { + if ($pFont->getSuperscript() === true || $pFont->getSubscript() === true) { $objWriter->startElement('vertAlign'); - if ($pFont->getSuperScript() === true) { + if ($pFont->getSuperscript() === true) { $objWriter->writeAttribute('val', 'superscript'); - } elseif ($pFont->getSubScript() === true) { + } elseif ($pFont->getSubscript() === true) { $objWriter->writeAttribute('val', 'subscript'); } $objWriter->endElement(); @@ -448,8 +448,8 @@ class Style extends WriterPart if ($pStyle->getAlignment()->getIndent() > 0) { $objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent()); } - if ($pStyle->getAlignment()->getReadorder() > 0) { - $objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder()); + if ($pStyle->getAlignment()->getReadOrder() > 0) { + $objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadOrder()); } $objWriter->endElement(); diff --git a/tests/PhpSpreadsheetTests/Style/BorderTest.php b/tests/PhpSpreadsheetTests/Style/BorderTest.php new file mode 100644 index 00000000..4055c870 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Style/BorderTest.php @@ -0,0 +1,26 @@ +getActiveSheet()->getStyle('A1')->getBorders(); + $allBorders = $borders->getAllBorders(); + $bottom = $borders->getBottom(); + + $actual = $bottom->getBorderStyle(); + $this->assertSame(Border::BORDER_NONE, $actual, 'should default to none'); + + $allBorders->setBorderStyle(Border::BORDER_THIN); + + $actual = $bottom->getBorderStyle(); + $this->assertSame(Border::BORDER_THIN, $actual, 'should have been set via allBorders'); + } +} From 5e15abc60af0a6a44f2781bb06e9ed2a49813f65 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Sep 2017 03:16:47 +0900 Subject: [PATCH 26/31] Clarify doc about security --- docs/topics/recipes.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index a7823f6a..e094e2c5 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -910,15 +910,18 @@ practice... ## Setting security on a spreadsheet -Excel offers 3 levels of "protection": document security, sheet security -and cell security. +Excel offers 3 levels of "protection": -Document security allows you to set a password on a complete +- Document: allows you to set a password on a complete spreadsheet, allowing changes to be made only when that password is -entered.Worksheet security offers other security options: you can -disallow inserting rows on a specific sheet, disallow sorting, ... Cell -security offers the option to lock/unlock a cell as well as show/hide -the internal formulaAn example on setting document security: +entered. +- Worksheet: offers other security options: you can +disallow inserting rows on a specific sheet, disallow sorting, ... +- Cell: offers the option to lock/unlock a cell as well as show/hide +the internal formula. + + +An example on setting document security: ``` php $spreadsheet->getSecurity()->setLockWindows(true); From 5dd18586a2c908230a5e54a9cfecc9ba86f03b5b Mon Sep 17 00:00:00 2001 From: Adrien Cohen Date: Mon, 4 Sep 2017 11:23:11 +0200 Subject: [PATCH 27/31] Fix colIndex read as signed int16 for relative ref As described in http://interoperability.blob.core.windows.net/files/MS-XLS/[MS-XLS].pdf a relative column reference can be between -255 +255 and not -127 + 127, the column index should be read as a signed int16. References: - 2.2.2.2.1 Value Class / page 81 - 2.5.198.88 PtgRefN / page 815 - 2.5.198.111 RgceLocRel / page 828 Fixes #211 Closes #214 --- src/PhpSpreadsheet/Reader/Xls.php | 642 ++++++++++++----------- src/PhpSpreadsheet/Reader/Xls/Escher.php | 40 +- 2 files changed, 353 insertions(+), 329 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 24c46f66..8e0f6ae8 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -485,7 +485,7 @@ class Xls extends BaseReader implements IReader // Parse Workbook Global Substream while ($this->pos < $this->dataSize) { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); switch ($code) { case self::XLS_TYPE_BOF: @@ -540,7 +540,7 @@ class Xls extends BaseReader implements IReader // Parse Workbook Global Substream while ($this->pos < $this->dataSize) { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); switch ($code) { case self::XLS_TYPE_BOF: @@ -577,7 +577,7 @@ class Xls extends BaseReader implements IReader $this->pos = $sheet['offset']; while ($this->pos <= $this->dataSize - 4) { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); switch ($code) { case self::XLS_TYPE_RK: @@ -586,14 +586,14 @@ class Xls extends BaseReader implements IReader case self::XLS_TYPE_FORMULA: case self::XLS_TYPE_BOOLERR: case self::XLS_TYPE_LABEL: - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; - $rowIndex = self::getInt2d($recordData, 0) + 1; - $columnIndex = self::getInt2d($recordData, 2); + $rowIndex = self::getUInt2d($recordData, 0) + 1; + $columnIndex = self::getUInt2d($recordData, 2); $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex); $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); @@ -668,7 +668,7 @@ class Xls extends BaseReader implements IReader // Parse Workbook Global Substream while ($this->pos < $this->dataSize) { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); switch ($code) { case self::XLS_TYPE_BOF: @@ -836,7 +836,7 @@ class Xls extends BaseReader implements IReader $this->textObjRef = -1; while ($this->pos <= $this->dataSize - 4) { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); switch ($code) { case self::XLS_TYPE_BOF: @@ -1347,7 +1347,7 @@ class Xls extends BaseReader implements IReader // extract property value based on property type switch ($type) { case 0x02: // 2 byte signed integer - $value = self::getInt2d($this->summaryInformation, $secOffset + 4 + $offset); + $value = self::getUInt2d($this->summaryInformation, $secOffset + 4 + $offset); break; case 0x03: // 4 byte signed integer $value = self::getInt4d($this->summaryInformation, $secOffset + 4 + $offset); @@ -1481,13 +1481,13 @@ class Xls extends BaseReader implements IReader // extract property value based on property type switch ($type) { case 0x02: // 2 byte signed integer - $value = self::getInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset); + $value = self::getUInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset); break; case 0x03: // 4 byte signed integer $value = self::getInt4d($this->documentSummaryInformation, $secOffset + 4 + $offset); break; case 0x0B: // Boolean - $value = self::getInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset); + $value = self::getUInt2d($this->documentSummaryInformation, $secOffset + 4 + $offset); $value = ($value == 0 ? false : true); break; case 0x13: // 4 byte unsigned integer @@ -1566,7 +1566,7 @@ class Xls extends BaseReader implements IReader */ private function readDefault() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); // move stream pointer to next record $this->pos += 4 + $length; @@ -1578,7 +1578,7 @@ class Xls extends BaseReader implements IReader */ private function readNote() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -1590,7 +1590,7 @@ class Xls extends BaseReader implements IReader $cellAddress = $this->readBIFF8CellAddress(substr($recordData, 0, 4)); if ($this->version == self::XLS_BIFF8) { - $noteObjID = self::getInt2d($recordData, 6); + $noteObjID = self::getUInt2d($recordData, 6); $noteAuthor = self::readUnicodeStringLong(substr($recordData, 8)); $noteAuthor = $noteAuthor['value']; $this->cellNotes[$noteObjID] = [ @@ -1604,13 +1604,13 @@ class Xls extends BaseReader implements IReader // If the address row is -1 and the column is 0, (which translates as $B$65536) then this is a continuation // note from the previous cell annotation. We're not yet handling this, so annotations longer than the // max 2048 bytes will probably throw a wobbly. - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); $extension = true; $cellAddress = array_pop(array_keys($this->phpSheet->getComments())); } $cellAddress = str_replace('$', '', $cellAddress); - $noteLength = self::getInt2d($recordData, 4); + $noteLength = self::getUInt2d($recordData, 4); $noteText = trim(substr($recordData, 6)); if ($extension) { @@ -1631,7 +1631,7 @@ class Xls extends BaseReader implements IReader */ private function readTextObject() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -1647,10 +1647,10 @@ class Xls extends BaseReader implements IReader // cchText: 2 bytes; length of the text (in the first continue record) // cbRuns: 2 bytes; length of the formatting (in the second continue record) // followed by the continuation records containing the actual text and formatting - $grbitOpts = self::getInt2d($recordData, 0); - $rot = self::getInt2d($recordData, 2); - $cchText = self::getInt2d($recordData, 10); - $cbRuns = self::getInt2d($recordData, 12); + $grbitOpts = self::getUInt2d($recordData, 0); + $rot = self::getUInt2d($recordData, 2); + $cchText = self::getUInt2d($recordData, 10); + $cbRuns = self::getUInt2d($recordData, 12); $text = $this->getSplicedRecordData(); $textByte = $text['spliceOffsets'][1] - $text['spliceOffsets'][0] - 1; @@ -1678,18 +1678,18 @@ class Xls extends BaseReader implements IReader */ private function readBof() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = substr($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 2; size: 2; type of the following data - $substreamType = self::getInt2d($recordData, 2); + $substreamType = self::getUInt2d($recordData, 2); switch ($substreamType) { case self::XLS_WORKBOOKGLOBALS: - $version = self::getInt2d($recordData, 0); + $version = self::getUInt2d($recordData, 0); if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) { throw new Exception('Cannot read this Excel file. Version is too old.'); } @@ -1703,7 +1703,7 @@ class Xls extends BaseReader implements IReader // substream, e.g. chart // just skip the entire substream do { - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); $this->readDefault(); } while ($code != self::XLS_TYPE_EOF && $this->pos < $this->dataSize); break; @@ -1727,7 +1727,7 @@ class Xls extends BaseReader implements IReader */ private function readFilepass() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); if ($length != 54) { throw new Exception('Unexpected file pass record length'); @@ -1745,7 +1745,7 @@ class Xls extends BaseReader implements IReader $this->encryption = self::MS_BIFF_CRYPTO_RC4; // Decryption required from the record after next onwards - $this->encryptionStartPos = $this->pos + self::getInt2d($this->data, $this->pos + 2); + $this->encryptionStartPos = $this->pos + self::getUInt2d($this->data, $this->pos + 2); } /** @@ -1876,14 +1876,14 @@ class Xls extends BaseReader implements IReader */ private function readCodepage() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; code page identifier - $codepage = self::getInt2d($recordData, 0); + $codepage = self::getUInt2d($recordData, 0); $this->codepage = CodePage::numberToName($codepage); } @@ -1902,7 +1902,7 @@ class Xls extends BaseReader implements IReader */ private function readDateMode() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -1920,7 +1920,7 @@ class Xls extends BaseReader implements IReader */ private function readFont() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -1930,30 +1930,30 @@ class Xls extends BaseReader implements IReader $objFont = new Font(); // offset: 0; size: 2; height of the font (in twips = 1/20 of a point) - $size = self::getInt2d($recordData, 0); + $size = self::getUInt2d($recordData, 0); $objFont->setSize($size / 20); // offset: 2; size: 2; option flags // bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8) // bit: 1; mask 0x0002; italic - $isItalic = (0x0002 & self::getInt2d($recordData, 2)) >> 1; + $isItalic = (0x0002 & self::getUInt2d($recordData, 2)) >> 1; if ($isItalic) { $objFont->setItalic(true); } // bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8) // bit: 3; mask 0x0008; strikethrough - $isStrike = (0x0008 & self::getInt2d($recordData, 2)) >> 3; + $isStrike = (0x0008 & self::getUInt2d($recordData, 2)) >> 3; if ($isStrike) { $objFont->setStrikethrough(true); } // offset: 4; size: 2; colour index - $colorIndex = self::getInt2d($recordData, 4); + $colorIndex = self::getUInt2d($recordData, 4); $objFont->colorIndex = $colorIndex; // offset: 6; size: 2; font weight - $weight = self::getInt2d($recordData, 6); + $weight = self::getUInt2d($recordData, 6); switch ($weight) { case 0x02BC: $objFont->setBold(true); @@ -1961,7 +1961,7 @@ class Xls extends BaseReader implements IReader } // offset: 8; size: 2; escapement type - $escapement = self::getInt2d($recordData, 8); + $escapement = self::getUInt2d($recordData, 8); switch ($escapement) { case 0x0001: $objFont->setSuperscript(true); @@ -2021,14 +2021,14 @@ class Xls extends BaseReader implements IReader */ private function readFormat() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; if (!$this->readDataOnly) { - $indexCode = self::getInt2d($recordData, 0); + $indexCode = self::getUInt2d($recordData, 0); if ($this->version == self::XLS_BIFF8) { $string = self::readUnicodeStringLong(substr($recordData, 2)); @@ -2058,7 +2058,7 @@ class Xls extends BaseReader implements IReader */ private function readXf() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2068,17 +2068,17 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; Index to FONT record - if (self::getInt2d($recordData, 0) < 4) { - $fontIndex = self::getInt2d($recordData, 0); + if (self::getUInt2d($recordData, 0) < 4) { + $fontIndex = self::getUInt2d($recordData, 0); } else { // this has to do with that index 4 is omitted in all BIFF versions for some strange reason // check the OpenOffice documentation of the FONT record - $fontIndex = self::getInt2d($recordData, 0) - 1; + $fontIndex = self::getUInt2d($recordData, 0) - 1; } $objStyle->setFont($this->objFonts[$fontIndex]); // offset: 2; size: 2; Index to FORMAT record - $numberFormatIndex = self::getInt2d($recordData, 2); + $numberFormatIndex = self::getUInt2d($recordData, 2); if (isset($this->formats[$numberFormatIndex])) { // then we have user-defined format code $numberFormat = ['formatCode' => $this->formats[$numberFormatIndex]]; @@ -2093,7 +2093,7 @@ class Xls extends BaseReader implements IReader // offset: 4; size: 2; XF type, cell protection, and parent style XF // bit 2-0; mask 0x0007; XF_TYPE_PROT - $xfTypeProt = self::getInt2d($recordData, 4); + $xfTypeProt = self::getUInt2d($recordData, 4); // bit 0; mask 0x01; 1 = cell is locked $isLocked = (0x01 & $xfTypeProt) >> 0; $objStyle->getProtection()->setLocked($isLocked ? Protection::PROTECTION_INHERIT : Protection::PROTECTION_UNPROTECTED); @@ -2249,10 +2249,10 @@ class Xls extends BaseReader implements IReader } // offset: 18; size: 2; pattern and background colour // bit: 6-0; mask: 0x007F; color index for pattern color - $objStyle->getFill()->startcolorIndex = (0x007F & self::getInt2d($recordData, 18)) >> 0; + $objStyle->getFill()->startcolorIndex = (0x007F & self::getUInt2d($recordData, 18)) >> 0; // bit: 13-7; mask: 0x3F80; color index for pattern background - $objStyle->getFill()->endcolorIndex = (0x3F80 & self::getInt2d($recordData, 18)) >> 7; + $objStyle->getFill()->endcolorIndex = (0x3F80 & self::getUInt2d($recordData, 18)) >> 7; } else { // BIFF5 @@ -2336,7 +2336,7 @@ class Xls extends BaseReader implements IReader private function readXfExt() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2352,28 +2352,28 @@ class Xls extends BaseReader implements IReader // offset: 12; size: 2; record version // offset: 14; size: 2; index to XF record which this record modifies - $ixfe = self::getInt2d($recordData, 14); + $ixfe = self::getUInt2d($recordData, 14); // offset: 16; size: 2; not used // offset: 18; size: 2; number of extension properties that follow - $cexts = self::getInt2d($recordData, 18); + $cexts = self::getUInt2d($recordData, 18); // start reading the actual extension data $offset = 20; while ($offset < $length) { // extension type - $extType = self::getInt2d($recordData, $offset); + $extType = self::getUInt2d($recordData, $offset); // extension length - $cb = self::getInt2d($recordData, $offset + 2); + $cb = self::getUInt2d($recordData, $offset + 2); // extension data $extData = substr($recordData, $offset + 4, $cb); switch ($extType) { case 4: // fill start color - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2388,7 +2388,7 @@ class Xls extends BaseReader implements IReader } break; case 5: // fill end color - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2403,7 +2403,7 @@ class Xls extends BaseReader implements IReader } break; case 7: // border color top - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2418,7 +2418,7 @@ class Xls extends BaseReader implements IReader } break; case 8: // border color bottom - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2433,7 +2433,7 @@ class Xls extends BaseReader implements IReader } break; case 9: // border color left - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2448,7 +2448,7 @@ class Xls extends BaseReader implements IReader } break; case 10: // border color right - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2463,7 +2463,7 @@ class Xls extends BaseReader implements IReader } break; case 11: // border color diagonal - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2478,7 +2478,7 @@ class Xls extends BaseReader implements IReader } break; case 13: // font color - $xclfType = self::getInt2d($extData, 0); // color type + $xclfType = self::getUInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) if ($xclfType == 2) { @@ -2504,7 +2504,7 @@ class Xls extends BaseReader implements IReader */ private function readStyle() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2512,7 +2512,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; index to XF record and flag for built-in style - $ixfe = self::getInt2d($recordData, 0); + $ixfe = self::getUInt2d($recordData, 0); // bit: 11-0; mask 0x0FFF; index to XF record $xfIndex = (0x0FFF & $ixfe) >> 0; @@ -2541,7 +2541,7 @@ class Xls extends BaseReader implements IReader */ private function readPalette() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2549,7 +2549,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; number of following colors - $nm = self::getInt2d($recordData, 0); + $nm = self::getUInt2d($recordData, 0); // list of RGB colors for ($i = 0; $i < $nm; ++$i) { @@ -2573,7 +2573,7 @@ class Xls extends BaseReader implements IReader */ private function readSheet() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // offset: 0; size: 4; absolute stream position of the BOF record of the sheet @@ -2624,7 +2624,7 @@ class Xls extends BaseReader implements IReader */ private function readExternalBook() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2637,7 +2637,7 @@ class Xls extends BaseReader implements IReader if (strlen($recordData) > 4) { // external reference // offset: 0; size: 2; number of sheet names ($nm) - $nm = self::getInt2d($recordData, 0); + $nm = self::getUInt2d($recordData, 0); $offset += 2; // offset: 2; size: var; encoded URL without sheet name (Unicode string, 16-bit length) @@ -2686,7 +2686,7 @@ class Xls extends BaseReader implements IReader */ private function readExternName() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2695,7 +2695,7 @@ class Xls extends BaseReader implements IReader // external sheet references provided for named cells if ($this->version == self::XLS_BIFF8) { // offset: 0; size: 2; options - $options = self::getInt2d($recordData, 0); + $options = self::getUInt2d($recordData, 0); // offset: 2; size: 2; @@ -2720,7 +2720,7 @@ class Xls extends BaseReader implements IReader */ private function readExternSheet() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2729,15 +2729,15 @@ class Xls extends BaseReader implements IReader // external sheet references provided for named cells if ($this->version == self::XLS_BIFF8) { // offset: 0; size: 2; number of following ref structures - $nm = self::getInt2d($recordData, 0); + $nm = self::getUInt2d($recordData, 0); for ($i = 0; $i < $nm; ++$i) { $this->ref[] = [ // offset: 2 + 6 * $i; index to EXTERNALBOOK record - 'externalBookIndex' => self::getInt2d($recordData, 2 + 6 * $i), + 'externalBookIndex' => self::getUInt2d($recordData, 2 + 6 * $i), // offset: 4 + 6 * $i; index to first sheet in EXTERNALBOOK record - 'firstSheetIndex' => self::getInt2d($recordData, 4 + 6 * $i), + 'firstSheetIndex' => self::getUInt2d($recordData, 4 + 6 * $i), // offset: 6 + 6 * $i; index to last sheet in EXTERNALBOOK record - 'lastSheetIndex' => self::getInt2d($recordData, 6 + 6 * $i), + 'lastSheetIndex' => self::getUInt2d($recordData, 6 + 6 * $i), ]; } } @@ -2756,7 +2756,7 @@ class Xls extends BaseReader implements IReader */ private function readDefinedName() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -2766,7 +2766,7 @@ class Xls extends BaseReader implements IReader // retrieves named cells // offset: 0; size: 2; option flags - $opts = self::getInt2d($recordData, 0); + $opts = self::getUInt2d($recordData, 0); // bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name $isBuiltInName = (0x0020 & $opts) >> 5; @@ -2778,10 +2778,10 @@ class Xls extends BaseReader implements IReader // offset: 4; size: 2; size of the formula data (it can happen that this is zero) // note: there can also be additional data, this is not included in $flen - $flen = self::getInt2d($recordData, 4); + $flen = self::getUInt2d($recordData, 4); // offset: 8; size: 2; 0=Global name, otherwise index to sheet (1-based) - $scope = self::getInt2d($recordData, 8); + $scope = self::getUInt2d($recordData, 8); // offset: 14; size: var; Name (Unicode string without length field) $string = self::readUnicodeString(substr($recordData, 14), $nlen); @@ -2810,7 +2810,7 @@ class Xls extends BaseReader implements IReader */ private function readMsoDrawingGroup() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); // get spliced record data $splicedRecordData = $this->getSplicedRecordData(); @@ -2851,7 +2851,7 @@ class Xls extends BaseReader implements IReader // loop through the Unicode strings (16-bit length) for ($i = 0; $i < $nm; ++$i) { // number of characters in the Unicode string - $numChars = self::getInt2d($recordData, $pos); + $numChars = self::getUInt2d($recordData, $pos); $pos += 2; // option flags @@ -2869,7 +2869,7 @@ class Xls extends BaseReader implements IReader if ($hasRichText) { // number of Rich-Text formatting runs - $formattingRuns = self::getInt2d($recordData, $pos); + $formattingRuns = self::getUInt2d($recordData, $pos); $pos += 2; } @@ -2976,10 +2976,10 @@ class Xls extends BaseReader implements IReader // list of formatting runs for ($j = 0; $j < $formattingRuns; ++$j) { // first formatted character; zero-based - $charPos = self::getInt2d($recordData, $pos + $j * 4); + $charPos = self::getUInt2d($recordData, $pos + $j * 4); // index to font record - $fontIndex = self::getInt2d($recordData, $pos + 2 + $j * 4); + $fontIndex = self::getUInt2d($recordData, $pos + 2 + $j * 4); $fmtRuns[] = [ 'charPos' => $charPos, @@ -3010,7 +3010,7 @@ class Xls extends BaseReader implements IReader */ private function readPrintGridlines() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3018,7 +3018,7 @@ class Xls extends BaseReader implements IReader if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) { // offset: 0; size: 2; 0 = do not print sheet grid lines; 1 = print sheet gridlines - $printGridlines = (bool) self::getInt2d($recordData, 0); + $printGridlines = (bool) self::getUInt2d($recordData, 0); $this->phpSheet->setPrintGridlines($printGridlines); } } @@ -3028,7 +3028,7 @@ class Xls extends BaseReader implements IReader */ private function readDefaultRowHeight() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3036,7 +3036,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; option flags // offset: 2; size: 2; default height for unused rows, (twips 1/20 point) - $height = self::getInt2d($recordData, 2); + $height = self::getUInt2d($recordData, 2); $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20); } @@ -3045,7 +3045,7 @@ class Xls extends BaseReader implements IReader */ private function readSheetPr() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3054,16 +3054,16 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2 // bit: 6; mask: 0x0040; 0 = outline buttons above outline group - $isSummaryBelow = (0x0040 & self::getInt2d($recordData, 0)) >> 6; + $isSummaryBelow = (0x0040 & self::getUInt2d($recordData, 0)) >> 6; $this->phpSheet->setShowSummaryBelow($isSummaryBelow); // bit: 7; mask: 0x0080; 0 = outline buttons left of outline group - $isSummaryRight = (0x0080 & self::getInt2d($recordData, 0)) >> 7; + $isSummaryRight = (0x0080 & self::getUInt2d($recordData, 0)) >> 7; $this->phpSheet->setShowSummaryRight($isSummaryRight); // bit: 8; mask: 0x100; 0 = scale printout in percent, 1 = fit printout to number of pages // this corresponds to radio button setting in page setup dialog in Excel - $this->isFitToPages = (bool) ((0x0100 & self::getInt2d($recordData, 0)) >> 8); + $this->isFitToPages = (bool) ((0x0100 & self::getUInt2d($recordData, 0)) >> 8); } /** @@ -3071,7 +3071,7 @@ class Xls extends BaseReader implements IReader */ private function readHorizontalPageBreaks() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3079,13 +3079,13 @@ class Xls extends BaseReader implements IReader if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) { // offset: 0; size: 2; number of the following row index structures - $nm = self::getInt2d($recordData, 0); + $nm = self::getUInt2d($recordData, 0); // offset: 2; size: 6 * $nm; list of $nm row index structures for ($i = 0; $i < $nm; ++$i) { - $r = self::getInt2d($recordData, 2 + 6 * $i); - $cf = self::getInt2d($recordData, 2 + 6 * $i + 2); - $cl = self::getInt2d($recordData, 2 + 6 * $i + 4); + $r = self::getUInt2d($recordData, 2 + 6 * $i); + $cf = self::getUInt2d($recordData, 2 + 6 * $i + 2); + $cl = self::getUInt2d($recordData, 2 + 6 * $i + 4); // not sure why two column indexes are necessary? $this->phpSheet->setBreakByColumnAndRow($cf, $r, Worksheet::BREAK_ROW); @@ -3098,7 +3098,7 @@ class Xls extends BaseReader implements IReader */ private function readVerticalPageBreaks() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3106,13 +3106,13 @@ class Xls extends BaseReader implements IReader if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) { // offset: 0; size: 2; number of the following column index structures - $nm = self::getInt2d($recordData, 0); + $nm = self::getUInt2d($recordData, 0); // offset: 2; size: 6 * $nm; list of $nm row index structures for ($i = 0; $i < $nm; ++$i) { - $c = self::getInt2d($recordData, 2 + 6 * $i); - $rf = self::getInt2d($recordData, 2 + 6 * $i + 2); - $rl = self::getInt2d($recordData, 2 + 6 * $i + 4); + $c = self::getUInt2d($recordData, 2 + 6 * $i); + $rf = self::getUInt2d($recordData, 2 + 6 * $i + 2); + $rl = self::getUInt2d($recordData, 2 + 6 * $i + 4); // not sure why two row indexes are necessary? $this->phpSheet->setBreakByColumnAndRow($c, $rf, Worksheet::BREAK_COLUMN); @@ -3125,7 +3125,7 @@ class Xls extends BaseReader implements IReader */ private function readHeader() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3152,7 +3152,7 @@ class Xls extends BaseReader implements IReader */ private function readFooter() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3178,7 +3178,7 @@ class Xls extends BaseReader implements IReader */ private function readHcenter() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3186,7 +3186,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally - $isHorizontalCentered = (bool) self::getInt2d($recordData, 0); + $isHorizontalCentered = (bool) self::getUInt2d($recordData, 0); $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered); } @@ -3197,7 +3197,7 @@ class Xls extends BaseReader implements IReader */ private function readVcenter() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3205,7 +3205,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered - $isVerticalCentered = (bool) self::getInt2d($recordData, 0); + $isVerticalCentered = (bool) self::getUInt2d($recordData, 0); $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered); } @@ -3216,7 +3216,7 @@ class Xls extends BaseReader implements IReader */ private function readLeftMargin() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3233,7 +3233,7 @@ class Xls extends BaseReader implements IReader */ private function readRightMargin() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3250,7 +3250,7 @@ class Xls extends BaseReader implements IReader */ private function readTopMargin() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3267,7 +3267,7 @@ class Xls extends BaseReader implements IReader */ private function readBottomMargin() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3284,7 +3284,7 @@ class Xls extends BaseReader implements IReader */ private function readPageSetup() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3292,25 +3292,25 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; paper size - $paperSize = self::getInt2d($recordData, 0); + $paperSize = self::getUInt2d($recordData, 0); // offset: 2; size: 2; scaling factor - $scale = self::getInt2d($recordData, 2); + $scale = self::getUInt2d($recordData, 2); // offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed - $fitToWidth = self::getInt2d($recordData, 6); + $fitToWidth = self::getUInt2d($recordData, 6); // offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed - $fitToHeight = self::getInt2d($recordData, 8); + $fitToHeight = self::getUInt2d($recordData, 8); // offset: 10; size: 2; option flags // bit: 1; mask: 0x0002; 0=landscape, 1=portrait - $isPortrait = (0x0002 & self::getInt2d($recordData, 10)) >> 1; + $isPortrait = (0x0002 & self::getUInt2d($recordData, 10)) >> 1; // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init // when this bit is set, do not use flags for those properties - $isNotInit = (0x0004 & self::getInt2d($recordData, 10)) >> 2; + $isNotInit = (0x0004 & self::getUInt2d($recordData, 10)) >> 2; if (!$isNotInit) { $this->phpSheet->getPageSetup()->setPaperSize($paperSize); @@ -3345,7 +3345,7 @@ class Xls extends BaseReader implements IReader */ private function readProtect() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3358,7 +3358,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; // bit 0, mask 0x01; 1 = sheet is protected - $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0; + $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0; $this->phpSheet->getProtection()->setSheet((bool) $bool); } @@ -3367,7 +3367,7 @@ class Xls extends BaseReader implements IReader */ private function readScenProtect() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3380,7 +3380,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; // bit: 0, mask 0x01; 1 = scenarios are protected - $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0; + $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0; $this->phpSheet->getProtection()->setScenarios((bool) $bool); } @@ -3390,7 +3390,7 @@ class Xls extends BaseReader implements IReader */ private function readObjectProtect() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3403,7 +3403,7 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; // bit: 0, mask 0x01; 1 = objects are protected - $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0; + $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0; $this->phpSheet->getProtection()->setObjects((bool) $bool); } @@ -3413,7 +3413,7 @@ class Xls extends BaseReader implements IReader */ private function readPassword() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3421,7 +3421,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; 16-bit hash value of password - $password = strtoupper(dechex(self::getInt2d($recordData, 0))); // the hashed password + $password = strtoupper(dechex(self::getUInt2d($recordData, 0))); // the hashed password $this->phpSheet->getProtection()->setPassword($password, true); } } @@ -3431,14 +3431,14 @@ class Xls extends BaseReader implements IReader */ private function readDefColWidth() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; default column width - $width = self::getInt2d($recordData, 0); + $width = self::getUInt2d($recordData, 0); if ($width != 8) { $this->phpSheet->getDefaultColumnDimension()->setWidth($width); } @@ -3449,7 +3449,7 @@ class Xls extends BaseReader implements IReader */ private function readColInfo() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3457,26 +3457,26 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; index to first column in range - $fc = self::getInt2d($recordData, 0); // first column index + $fc = self::getUInt2d($recordData, 0); // first column index // offset: 2; size: 2; index to last column in range - $lc = self::getInt2d($recordData, 2); // first column index + $lc = self::getUInt2d($recordData, 2); // first column index // offset: 4; size: 2; width of the column in 1/256 of the width of the zero character - $width = self::getInt2d($recordData, 4); + $width = self::getUInt2d($recordData, 4); // offset: 6; size: 2; index to XF record for default column formatting - $xfIndex = self::getInt2d($recordData, 6); + $xfIndex = self::getUInt2d($recordData, 6); // offset: 8; size: 2; option flags // bit: 0; mask: 0x0001; 1= columns are hidden - $isHidden = (0x0001 & self::getInt2d($recordData, 8)) >> 0; + $isHidden = (0x0001 & self::getUInt2d($recordData, 8)) >> 0; // bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline) - $level = (0x0700 & self::getInt2d($recordData, 8)) >> 8; + $level = (0x0700 & self::getUInt2d($recordData, 8)) >> 8; // bit: 12; mask: 0x1000; 1 = collapsed - $isCollapsed = (0x1000 & self::getInt2d($recordData, 8)) >> 12; + $isCollapsed = (0x1000 & self::getUInt2d($recordData, 8)) >> 12; // offset: 10; size: 2; not used @@ -3506,7 +3506,7 @@ class Xls extends BaseReader implements IReader */ private function readRow() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3514,7 +3514,7 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; index of this row - $r = self::getInt2d($recordData, 0); + $r = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to column of the first cell which is described by a cell record @@ -3523,10 +3523,10 @@ class Xls extends BaseReader implements IReader // offset: 6; size: 2; // bit: 14-0; mask: 0x7FFF; height of the row, in twips = 1/20 of a point - $height = (0x7FFF & self::getInt2d($recordData, 6)) >> 0; + $height = (0x7FFF & self::getUInt2d($recordData, 6)) >> 0; // bit: 15: mask: 0x8000; 0 = row has custom height; 1= row has default height - $useDefaultHeight = (0x8000 & self::getInt2d($recordData, 6)) >> 15; + $useDefaultHeight = (0x8000 & self::getUInt2d($recordData, 6)) >> 15; if (!$useDefaultHeight) { $this->phpSheet->getRowDimension($r + 1)->setRowHeight($height / 20); @@ -3575,23 +3575,23 @@ class Xls extends BaseReader implements IReader */ private function readRk() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to column - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // offset: 6; size: 4; RK value $rknum = self::getInt4d($recordData, 6); @@ -3619,24 +3619,24 @@ class Xls extends BaseReader implements IReader */ private function readLabelSst() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to column - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); $emptyCell = true; // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // offset: 6; size: 4; index to SST record $index = self::getInt4d($recordData, 6); @@ -3703,20 +3703,20 @@ class Xls extends BaseReader implements IReader */ private function readMulRk() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to first column - $colFirst = self::getInt2d($recordData, 2); + $colFirst = self::getUInt2d($recordData, 2); // offset: var; size: 2; index to last column - $colLast = self::getInt2d($recordData, $length - 2); + $colLast = self::getUInt2d($recordData, $length - 2); $columns = $colLast - $colFirst + 1; // offset within record data @@ -3728,7 +3728,7 @@ class Xls extends BaseReader implements IReader // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: var; size: 2; index to XF record - $xfIndex = self::getInt2d($recordData, $offset); + $xfIndex = self::getUInt2d($recordData, $offset); // offset: var; size: 4; RK value $numValue = self::getIEEE754(self::getInt4d($recordData, $offset + 2)); @@ -3756,23 +3756,23 @@ class Xls extends BaseReader implements IReader */ private function readNumber() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size 2; index to column - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset 4; size: 2; index to XF record - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); $numValue = self::extractNumber(substr($recordData, 6, 8)); @@ -3797,24 +3797,24 @@ class Xls extends BaseReader implements IReader */ private function readFormula() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; row index - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; col index - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); // offset: 20: size: variable; formula structure $formulaStructure = substr($recordData, 20); // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc. - $options = self::getInt2d($recordData, 14); + $options = self::getUInt2d($recordData, 14); // bit: 0; mask: 0x0001; 1 = recalculate always // bit: 1; mask: 0x0002; 1 = calculate on open @@ -3830,8 +3830,8 @@ class Xls extends BaseReader implements IReader if ($isPartOfSharedFormula) { // part of shared formula which means there will be a formula with a tExp token and nothing else // get the base cell, grab tExp token - $baseRow = self::getInt2d($formulaStructure, 3); - $baseCol = self::getInt2d($formulaStructure, 5); + $baseRow = self::getUInt2d($formulaStructure, 3); + $baseCol = self::getUInt2d($formulaStructure, 5); $this->_baseCell = Cell::stringFromColumnIndex($baseCol) . ($baseRow + 1); } @@ -3845,7 +3845,7 @@ class Xls extends BaseReader implements IReader // offset: 16: size: 4; not used // offset: 4; size: 2; XF index - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // offset: 6; size: 8; result of the formula if ((ord($recordData[6]) == 0) && (ord($recordData[12]) == 255) && (ord($recordData[13]) == 255)) { @@ -3853,7 +3853,7 @@ class Xls extends BaseReader implements IReader $dataType = Cell\DataType::TYPE_STRING; // read possible SHAREDFMLA record - $code = self::getInt2d($this->data, $this->pos); + $code = self::getUInt2d($this->data, $this->pos); if ($code == self::XLS_TYPE_SHAREDFMLA) { $this->readSharedFmla(); } @@ -3923,7 +3923,7 @@ class Xls extends BaseReader implements IReader */ private function readSharedFmla() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3954,7 +3954,7 @@ class Xls extends BaseReader implements IReader */ private function readString() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -3981,23 +3981,23 @@ class Xls extends BaseReader implements IReader */ private function readBoolErr() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; row index - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; column index - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // offset: 6; size: 1; the boolean value or error value $boolErr = ord($recordData[6]); @@ -4038,17 +4038,17 @@ class Xls extends BaseReader implements IReader */ private function readMulBlank() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to first column - $fc = self::getInt2d($recordData, 2); + $fc = self::getUInt2d($recordData, 2); // offset: 4; size: 2 x nc; list of indexes to XF records // add style information @@ -4058,7 +4058,7 @@ class Xls extends BaseReader implements IReader // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { - $xfIndex = self::getInt2d($recordData, 4 + 2 * $i); + $xfIndex = self::getUInt2d($recordData, 4 + 2 * $i); $this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]); } } @@ -4079,23 +4079,23 @@ class Xls extends BaseReader implements IReader */ private function readLabel() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; index to row - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to column - $column = self::getInt2d($recordData, 2); + $column = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($column); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: 4; size: 2; XF index - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // add cell value // todo: what if string is very long? continue record @@ -4123,23 +4123,23 @@ class Xls extends BaseReader implements IReader */ private function readBlank() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; row index - $row = self::getInt2d($recordData, 0); + $row = self::getUInt2d($recordData, 0); // offset: 2; size: 2; col index - $col = self::getInt2d($recordData, 2); + $col = self::getUInt2d($recordData, 2); $columnString = Cell::stringFromColumnIndex($col); // Read cell? if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) { // offset: 4; size: 2; XF index - $xfIndex = self::getInt2d($recordData, 4); + $xfIndex = self::getUInt2d($recordData, 4); // add style information if (!$this->readDataOnly && $this->readEmptyCells) { @@ -4153,7 +4153,7 @@ class Xls extends BaseReader implements IReader */ private function readMsoDrawing() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); // get spliced record data $splicedRecordData = $this->getSplicedRecordData(); @@ -4167,7 +4167,7 @@ class Xls extends BaseReader implements IReader */ private function readObj() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4186,11 +4186,11 @@ class Xls extends BaseReader implements IReader // data: var; subrecord data // for now, we are just interested in the second subrecord containing the object type - $ftCmoType = self::getInt2d($recordData, 0); - $cbCmoSize = self::getInt2d($recordData, 2); - $otObjType = self::getInt2d($recordData, 4); - $idObjID = self::getInt2d($recordData, 6); - $grbitOpts = self::getInt2d($recordData, 6); + $ftCmoType = self::getUInt2d($recordData, 0); + $cbCmoSize = self::getUInt2d($recordData, 2); + $otObjType = self::getUInt2d($recordData, 4); + $idObjID = self::getUInt2d($recordData, 6); + $grbitOpts = self::getUInt2d($recordData, 6); $this->objs[] = [ 'ftCmoType' => $ftCmoType, @@ -4207,30 +4207,30 @@ class Xls extends BaseReader implements IReader */ private function readWindow2() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; option flags - $options = self::getInt2d($recordData, 0); + $options = self::getUInt2d($recordData, 0); // offset: 2; size: 2; index to first visible row - $firstVisibleRow = self::getInt2d($recordData, 2); + $firstVisibleRow = self::getUInt2d($recordData, 2); // offset: 4; size: 2; index to first visible colum - $firstVisibleColumn = self::getInt2d($recordData, 4); + $firstVisibleColumn = self::getUInt2d($recordData, 4); if ($this->version === self::XLS_BIFF8) { // offset: 8; size: 2; not used // offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%) // offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%) // offset: 14; size: 4; not used - $zoomscaleInPageBreakPreview = self::getInt2d($recordData, 10); + $zoomscaleInPageBreakPreview = self::getUInt2d($recordData, 10); if ($zoomscaleInPageBreakPreview === 0) { $zoomscaleInPageBreakPreview = 60; } - $zoomscaleInNormalView = self::getInt2d($recordData, 12); + $zoomscaleInNormalView = self::getUInt2d($recordData, 12); if ($zoomscaleInNormalView === 0) { $zoomscaleInNormalView = 100; } @@ -4278,7 +4278,7 @@ class Xls extends BaseReader implements IReader */ private function readPageLayoutView() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4286,17 +4286,17 @@ class Xls extends BaseReader implements IReader // offset: 0; size: 2; rt //->ignore - $rt = self::getInt2d($recordData, 0); + $rt = self::getUInt2d($recordData, 0); // offset: 2; size: 2; grbitfr //->ignore - $grbitFrt = self::getInt2d($recordData, 2); + $grbitFrt = self::getUInt2d($recordData, 2); // offset: 4; size: 8; reserved //->ignore // offset: 12; size 2; zoom scale - $wScalePLV = self::getInt2d($recordData, 12); + $wScalePLV = self::getUInt2d($recordData, 12); // offset: 14; size 2; grbit - $grbit = self::getInt2d($recordData, 14); + $grbit = self::getUInt2d($recordData, 14); // decomprise grbit $fPageLayoutView = $grbit & 0x01; @@ -4315,17 +4315,17 @@ class Xls extends BaseReader implements IReader */ private function readScl() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record $this->pos += 4 + $length; // offset: 0; size: 2; numerator of the view magnification - $numerator = self::getInt2d($recordData, 0); + $numerator = self::getUInt2d($recordData, 0); // offset: 2; size: 2; numerator of the view magnification - $denumerator = self::getInt2d($recordData, 2); + $denumerator = self::getUInt2d($recordData, 2); // set the zoom scale (in percent) $this->phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator); @@ -4336,7 +4336,7 @@ class Xls extends BaseReader implements IReader */ private function readPane() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4344,10 +4344,10 @@ class Xls extends BaseReader implements IReader if (!$this->readDataOnly) { // offset: 0; size: 2; position of vertical split - $px = self::getInt2d($recordData, 0); + $px = self::getUInt2d($recordData, 0); // offset: 2; size: 2; position of horizontal split - $py = self::getInt2d($recordData, 2); + $py = self::getUInt2d($recordData, 2); if ($this->frozen) { // frozen panes @@ -4362,7 +4362,7 @@ class Xls extends BaseReader implements IReader */ private function readSelection() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4373,14 +4373,14 @@ class Xls extends BaseReader implements IReader $paneId = ord($recordData[0]); // offset: 1; size: 2; index to row of the active cell - $r = self::getInt2d($recordData, 1); + $r = self::getUInt2d($recordData, 1); // offset: 3; size: 2; index to column of the active cell - $c = self::getInt2d($recordData, 3); + $c = self::getUInt2d($recordData, 3); // offset: 5; size: 2; index into the following cell range list to the // entry that contains the active cell - $index = self::getInt2d($recordData, 5); + $index = self::getUInt2d($recordData, 5); // offset: 7; size: var; cell range address list containing all selected cell ranges $data = substr($recordData, 7); @@ -4438,7 +4438,7 @@ class Xls extends BaseReader implements IReader */ private function readMergedCells() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4460,7 +4460,7 @@ class Xls extends BaseReader implements IReader */ private function readHyperLink() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer forward to next record @@ -4480,22 +4480,22 @@ class Xls extends BaseReader implements IReader // offset: 28, size: 4; option flags // bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL - $isFileLinkOrUrl = (0x00000001 & self::getInt2d($recordData, 28)) >> 0; + $isFileLinkOrUrl = (0x00000001 & self::getUInt2d($recordData, 28)) >> 0; // bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL - $isAbsPathOrUrl = (0x00000001 & self::getInt2d($recordData, 28)) >> 1; + $isAbsPathOrUrl = (0x00000001 & self::getUInt2d($recordData, 28)) >> 1; // bit: 2 (and 4); mask: 0x00000014; 0 = no description - $hasDesc = (0x00000014 & self::getInt2d($recordData, 28)) >> 2; + $hasDesc = (0x00000014 & self::getUInt2d($recordData, 28)) >> 2; // bit: 3; mask: 0x00000008; 0 = no text, 1 = has text - $hasText = (0x00000008 & self::getInt2d($recordData, 28)) >> 3; + $hasText = (0x00000008 & self::getUInt2d($recordData, 28)) >> 3; // bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame - $hasFrame = (0x00000080 & self::getInt2d($recordData, 28)) >> 7; + $hasFrame = (0x00000080 & self::getUInt2d($recordData, 28)) >> 7; // bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name) - $isUNC = (0x00000100 & self::getInt2d($recordData, 28)) >> 8; + $isUNC = (0x00000100 & self::getUInt2d($recordData, 28)) >> 8; // offset within record data $offset = 32; @@ -4554,7 +4554,7 @@ class Xls extends BaseReader implements IReader $offset += 16; // offset: var; size: 2; directory up-level count. - $upLevelCount = self::getInt2d($recordData, $offset); + $upLevelCount = self::getUInt2d($recordData, $offset); $offset += 2; // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word @@ -4631,7 +4631,7 @@ class Xls extends BaseReader implements IReader */ private function readDataValidations() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer forward to next record @@ -4643,7 +4643,7 @@ class Xls extends BaseReader implements IReader */ private function readDataValidation() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer forward to next record @@ -4766,7 +4766,7 @@ class Xls extends BaseReader implements IReader $offset += $string['size']; // offset: var; size: 2; size of the formula data for the first condition - $sz1 = self::getInt2d($recordData, $offset); + $sz1 = self::getUInt2d($recordData, $offset); $offset += 2; // offset: var; size: 2; not used @@ -4788,7 +4788,7 @@ class Xls extends BaseReader implements IReader $offset += $sz1; // offset: var; size: 2; size of the formula data for the first condition - $sz2 = self::getInt2d($recordData, $offset); + $sz2 = self::getUInt2d($recordData, $offset); $offset += 2; // offset: var; size: 2; not used @@ -4834,7 +4834,7 @@ class Xls extends BaseReader implements IReader */ private function readSheetLayout() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4855,7 +4855,7 @@ class Xls extends BaseReader implements IReader switch ($sz) { case 0x14: // offset: 16; size: 2; color index for sheet tab - $colorIndex = self::getInt2d($recordData, 16); + $colorIndex = self::getUInt2d($recordData, 16); $color = Xls\Color::map($colorIndex, $this->palette, $this->version); $this->phpSheet->getTabColor()->setRGB($color['rgb']); break; @@ -4872,7 +4872,7 @@ class Xls extends BaseReader implements IReader */ private function readSheetProtection() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4889,7 +4889,7 @@ class Xls extends BaseReader implements IReader // offset: 4; size: 8; Currently not used and set to 0 // offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag) - $isf = self::getInt2d($recordData, 12); + $isf = self::getUInt2d($recordData, 12); if ($isf != 2) { return; } @@ -4900,7 +4900,7 @@ class Xls extends BaseReader implements IReader // rgbHdrSData, assume "Enhanced Protection" // offset: 19; size: 2; option flags - $options = self::getInt2d($recordData, 19); + $options = self::getUInt2d($recordData, 19); // bit: 0; mask 0x0001; 1 = user may edit objects, 0 = users must not edit objects $bool = (0x0001 & $options) >> 0; @@ -4972,7 +4972,7 @@ class Xls extends BaseReader implements IReader */ private function readRangeProtection() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // move stream pointer to next record @@ -4985,7 +4985,7 @@ class Xls extends BaseReader implements IReader $offset += 12; // offset: 12; size: 2; shared feature type, 2 = enhanced protection, 4 = smart tag - $isf = self::getInt2d($recordData, 12); + $isf = self::getUInt2d($recordData, 12); if ($isf != 2) { // we only read FEAT records of type 2 return; @@ -4995,7 +4995,7 @@ class Xls extends BaseReader implements IReader $offset += 5; // offset: 19; size: 2; count of ref ranges this feature is on - $cref = self::getInt2d($recordData, 19); + $cref = self::getUInt2d($recordData, 19); $offset += 2; $offset += 6; @@ -5032,7 +5032,7 @@ class Xls extends BaseReader implements IReader */ private function readImData() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); // get spliced record data $splicedRecordData = $this->getSplicedRecordData(); @@ -5041,10 +5041,10 @@ class Xls extends BaseReader implements IReader // UNDER CONSTRUCTION // offset: 0; size: 2; image format - $cf = self::getInt2d($recordData, 0); + $cf = self::getUInt2d($recordData, 0); // offset: 2; size: 2; environment from which the file was written - $env = self::getInt2d($recordData, 2); + $env = self::getUInt2d($recordData, 2); // offset: 4; size: 4; length of the image data $lcb = self::getInt4d($recordData, 4); @@ -5060,16 +5060,16 @@ class Xls extends BaseReader implements IReader $bcSize = self::getInt4d($iData, 0); // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels - $bcWidth = self::getInt2d($iData, 4); + $bcWidth = self::getUInt2d($iData, 4); // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels. - $bcHeight = self::getInt2d($iData, 6); + $bcHeight = self::getUInt2d($iData, 6); $ih = imagecreatetruecolor($bcWidth, $bcHeight); // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1 // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24 - $bcBitCount = self::getInt2d($iData, 10); + $bcBitCount = self::getUInt2d($iData, 10); $rgbString = substr($iData, 12); $rgbTriples = []; @@ -5107,7 +5107,7 @@ class Xls extends BaseReader implements IReader */ private function readContinue() { - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); // check if we are reading drawing data @@ -5135,7 +5135,7 @@ class Xls extends BaseReader implements IReader // 0xF00D MsofbtClientTextbox $validSplitPoints = [0xF003, 0xF004, 0xF00D]; // add identifiers if we find more - $splitPoint = self::getInt2d($recordData, 2); + $splitPoint = self::getUInt2d($recordData, 2); if (in_array($splitPoint, $validSplitPoints)) { // get spliced record data (and move pointer to next record) $splicedRecordData = $this->getSplicedRecordData(); @@ -5168,15 +5168,15 @@ class Xls extends BaseReader implements IReader ++$i; // offset: 0; size: 2; identifier - $identifier = self::getInt2d($this->data, $this->pos); + $identifier = self::getUInt2d($this->data, $this->pos); // offset: 2; size: 2; length - $length = self::getInt2d($this->data, $this->pos + 2); + $length = self::getUInt2d($this->data, $this->pos + 2); $data .= $this->readRecordData($this->data, $this->pos + 4, $length); $spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length; $this->pos += 4 + $length; - $nextIdentifier = self::getInt2d($this->data, $this->pos); + $nextIdentifier = self::getUInt2d($this->data, $this->pos); } while ($nextIdentifier == self::XLS_TYPE_CONTINUE); $splicedData = [ @@ -5198,7 +5198,7 @@ class Xls extends BaseReader implements IReader private function getFormulaFromStructure($formulaStructure, $baseCell = 'A1') { // offset: 0; size: 2; size of the following formula data - $sz = self::getInt2d($formulaStructure, 0); + $sz = self::getUInt2d($formulaStructure, 0); // offset: 2; size: sz $formulaData = substr($formulaStructure, 2, $sz); @@ -5536,7 +5536,7 @@ class Xls extends BaseReader implements IReader case 0x04: $name = 'tAttrChoose'; // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1) - $nc = self::getInt2d($formulaData, 2); + $nc = self::getUInt2d($formulaData, 2); // offset: 4; size: 2 * $nc // offset: 4 + 2 * $nc; size: 2 $size = 2 * $nc + 6; @@ -5606,7 +5606,7 @@ class Xls extends BaseReader implements IReader // offset: 1; size: 2; unsigned 16-bit integer $name = 'tInt'; $size = 3; - $data = self::getInt2d($formulaData, 1); + $data = self::getUInt2d($formulaData, 1); break; case 0x1F: // number // offset: 1; size: 8; @@ -5629,7 +5629,7 @@ class Xls extends BaseReader implements IReader $name = 'tFunc'; $size = 3; // offset: 1; size: 2; index to built-in sheet function - switch (self::getInt2d($formulaData, 1)) { + switch (self::getUInt2d($formulaData, 1)) { case 2: $function = 'ISNA'; $args = 1; @@ -6284,7 +6284,7 @@ class Xls extends BaseReader implements IReader // offset: 1; size: 1; number of arguments $args = ord($formulaData[1]); // offset: 2: size: 2; index to built-in sheet function - $index = self::getInt2d($formulaData, 2); + $index = self::getUInt2d($formulaData, 2); switch ($index) { case 0: $function = 'COUNT'; @@ -6562,7 +6562,7 @@ class Xls extends BaseReader implements IReader $name = 'tName'; $size = 5; // offset: 1; size: 2; one-based index to definedname record - $definedNameIndex = self::getInt2d($formulaData, 1) - 1; + $definedNameIndex = self::getUInt2d($formulaData, 1) - 1; // offset: 2; size: 2; not used $data = $this->definedname[$definedNameIndex]['name']; break; @@ -6586,7 +6586,7 @@ class Xls extends BaseReader implements IReader $name = 'tMemArea'; // offset: 1; size: 4; not used // offset: 5; size: 2; size of the following subexpression - $subSize = self::getInt2d($formulaData, 5); + $subSize = self::getUInt2d($formulaData, 5); $size = 7 + $subSize; $data = $this->getFormulaFromData(substr($formulaData, 7, $subSize)); break; @@ -6596,7 +6596,7 @@ class Xls extends BaseReader implements IReader $name = 'tMemErr'; // offset: 1; size: 4; not used // offset: 5; size: 2; size of the following subexpression - $subSize = self::getInt2d($formulaData, 5); + $subSize = self::getUInt2d($formulaData, 5); $size = 7 + $subSize; $data = $this->getFormulaFromData(substr($formulaData, 7, $subSize)); break; @@ -6605,7 +6605,7 @@ class Xls extends BaseReader implements IReader case 0x69: $name = 'tMemFunc'; // offset: 1; size: 2; size of the following sub-expression - $subSize = self::getInt2d($formulaData, 1); + $subSize = self::getUInt2d($formulaData, 1); $size = 3 + $subSize; $data = $this->getFormulaFromData(substr($formulaData, 3, $subSize)); break; @@ -6630,7 +6630,7 @@ class Xls extends BaseReader implements IReader $size = 7; // offset: 1; size: 2; index to REF entry in EXTERNSHEET record // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record - $index = self::getInt2d($formulaData, 3); + $index = self::getUInt2d($formulaData, 3); // assume index is to EXTERNNAME record $data = $this->externalNames[$index - 1]['name']; // offset: 5; size: 2; not used @@ -6643,7 +6643,7 @@ class Xls extends BaseReader implements IReader try { // offset: 1; size: 2; index to REF entry - $sheetRange = $this->readSheetRangeByRefIndex(self::getInt2d($formulaData, 1)); + $sheetRange = $this->readSheetRangeByRefIndex(self::getUInt2d($formulaData, 1)); // offset: 3; size: 4; cell address $cellAddress = $this->readBIFF8CellAddress(substr($formulaData, 3, 4)); @@ -6661,7 +6661,7 @@ class Xls extends BaseReader implements IReader try { // offset: 1; size: 2; index to REF entry - $sheetRange = $this->readSheetRangeByRefIndex(self::getInt2d($formulaData, 1)); + $sheetRange = $this->readSheetRangeByRefIndex(self::getUInt2d($formulaData, 1)); // offset: 3; size: 8; cell address $cellRangeAddress = $this->readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); @@ -6696,18 +6696,18 @@ class Xls extends BaseReader implements IReader private function readBIFF8CellAddress($cellAddressStructure) { // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) - $row = self::getInt2d($cellAddressStructure, 0) + 1; + $row = self::getUInt2d($cellAddressStructure, 0) + 1; // offset: 2; size: 2; index to column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $column = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($cellAddressStructure, 2)); + $column = Cell::stringFromColumnIndex(0x00FF & self::getUInt2d($cellAddressStructure, 2)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($cellAddressStructure, 2))) { + if (!(0x4000 & self::getUInt2d($cellAddressStructure, 2))) { $column = '$' . $column; } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($cellAddressStructure, 2))) { + if (!(0x8000 & self::getUInt2d($cellAddressStructure, 2))) { $row = '$' . $row; } @@ -6730,24 +6730,29 @@ class Xls extends BaseReader implements IReader $baseCol = Cell::columnIndexFromString($baseCol) - 1; // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) - $rowIndex = self::getInt2d($cellAddressStructure, 0); - $row = self::getInt2d($cellAddressStructure, 0) + 1; - - // offset: 2; size: 2; index to column or column offset + relative flags - // bit: 7-0; mask 0x00FF; column index - $colIndex = 0x00FF & self::getInt2d($cellAddressStructure, 2); + $rowIndex = self::getUInt2d($cellAddressStructure, 0); + $row = self::getUInt2d($cellAddressStructure, 0) + 1; // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($cellAddressStructure, 2))) { + if (!(0x4000 & self::getUInt2d($cellAddressStructure, 2))) { + // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $colIndex = 0x00FF & self::getUInt2d($cellAddressStructure, 2); + $column = Cell::stringFromColumnIndex($colIndex); $column = '$' . $column; } else { - $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; - $column = Cell::stringFromColumnIndex($baseCol + $colIndex); + // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $relativeColIndex = 0x00FF & self::getInt2d($cellAddressStructure, 2); + $colIndex = $baseCol + $relativeColIndex; + $colIndex = ($colIndex < 256) ? $colIndex : $colIndex - 256; + $colIndex = ($colIndex >= 0) ? $colIndex : $colIndex + 256; + $column = Cell::stringFromColumnIndex($colIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($cellAddressStructure, 2))) { + if (!(0x8000 & self::getUInt2d($cellAddressStructure, 2))) { $row = '$' . $row; } else { $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536; @@ -6771,10 +6776,10 @@ class Xls extends BaseReader implements IReader private function readBIFF5CellRangeAddressFixed($subData) { // offset: 0; size: 2; index to first row - $fr = self::getInt2d($subData, 0) + 1; + $fr = self::getUInt2d($subData, 0) + 1; // offset: 2; size: 2; index to last row - $lr = self::getInt2d($subData, 2) + 1; + $lr = self::getUInt2d($subData, 2) + 1; // offset: 4; size: 1; index to first column $fc = ord($subData[4]); @@ -6812,16 +6817,16 @@ class Xls extends BaseReader implements IReader private function readBIFF8CellRangeAddressFixed($subData) { // offset: 0; size: 2; index to first row - $fr = self::getInt2d($subData, 0) + 1; + $fr = self::getUInt2d($subData, 0) + 1; // offset: 2; size: 2; index to last row - $lr = self::getInt2d($subData, 2) + 1; + $lr = self::getUInt2d($subData, 2) + 1; // offset: 4; size: 2; index to first column - $fc = self::getInt2d($subData, 4); + $fc = self::getUInt2d($subData, 4); // offset: 6; size: 2; index to last column - $lc = self::getInt2d($subData, 6); + $lc = self::getUInt2d($subData, 6); // check values if ($fr > $lr || $fc > $lc) { @@ -6854,38 +6859,38 @@ class Xls extends BaseReader implements IReader // not just return e.g. 'A1' and not 'A1:A1' ? // offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767)) - $fr = self::getInt2d($subData, 0) + 1; + $fr = self::getUInt2d($subData, 0) + 1; // offset: 2; size: 2; index to last row (0... 65535) (or offset (-32768... 32767)) - $lr = self::getInt2d($subData, 2) + 1; + $lr = self::getUInt2d($subData, 2) + 1; // offset: 4; size: 2; index to first column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $fc = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 4)); + $fc = Cell::stringFromColumnIndex(0x00FF & self::getUInt2d($subData, 4)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($subData, 4))) { + if (!(0x4000 & self::getUInt2d($subData, 4))) { $fc = '$' . $fc; } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($subData, 4))) { + if (!(0x8000 & self::getUInt2d($subData, 4))) { $fr = '$' . $fr; } // offset: 6; size: 2; index to last column or column offset + relative flags // bit: 7-0; mask 0x00FF; column index - $lc = Cell::stringFromColumnIndex(0x00FF & self::getInt2d($subData, 6)); + $lc = Cell::stringFromColumnIndex(0x00FF & self::getUInt2d($subData, 6)); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($subData, 6))) { + if (!(0x4000 & self::getUInt2d($subData, 6))) { $lc = '$' . $lc; } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($subData, 6))) { + if (!(0x8000 & self::getUInt2d($subData, 6))) { $lr = '$' . $lr; } @@ -6911,29 +6916,32 @@ class Xls extends BaseReader implements IReader // not just return e.g. 'A1' and not 'A1:A1' ? // offset: 0; size: 2; first row - $frIndex = self::getInt2d($subData, 0); // adjust below + $frIndex = self::getUInt2d($subData, 0); // adjust below // offset: 2; size: 2; relative index to first row (0... 65535) should be treated as offset (-32768... 32767) - $lrIndex = self::getInt2d($subData, 2); // adjust below - - // offset: 4; size: 2; first column with relative/absolute flags - - // bit: 7-0; mask 0x00FF; column index - $fcIndex = 0x00FF & self::getInt2d($subData, 4); + $lrIndex = self::getUInt2d($subData, 2); // adjust below // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($subData, 4))) { + if (!(0x4000 & self::getUInt2d($subData, 4))) { // absolute column index + // offset: 4; size: 2; first column with relative/absolute flags + // bit: 7-0; mask 0x00FF; column index + $fcIndex = 0x00FF & self::getUInt2d($subData, 4); $fc = Cell::stringFromColumnIndex($fcIndex); $fc = '$' . $fc; } else { // column offset - $fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256; - $fc = Cell::stringFromColumnIndex($baseCol + $fcIndex); + // offset: 4; size: 2; first column with relative/absolute flags + // bit: 7-0; mask 0x00FF; column index + $relativeFcIndex = 0x00FF & self::getInt2d($subData, 4); + $fcIndex = $baseCol + $relativeFcIndex; + $fcIndex = ($fcIndex < 256) ? $fcIndex : $fcIndex - 256; + $fcIndex = ($fcIndex >= 0) ? $fcIndex : $fcIndex + 256; + $fc = Cell::stringFromColumnIndex($fcIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($subData, 4))) { + if (!(0x8000 & self::getUInt2d($subData, 4))) { // absolute row index $fr = $frIndex + 1; $fr = '$' . $fr; @@ -6943,26 +6951,29 @@ class Xls extends BaseReader implements IReader $fr = $baseRow + $frIndex; } - // offset: 6; size: 2; last column with relative/absolute flags - - // bit: 7-0; mask 0x00FF; column index - $lcIndex = 0x00FF & self::getInt2d($subData, 6); - $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256; $lc = Cell::stringFromColumnIndex($baseCol + $lcIndex); // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::getInt2d($subData, 6))) { + if (!(0x4000 & self::getUInt2d($subData, 6))) { // absolute column index + // offset: 6; size: 2; last column with relative/absolute flags + // bit: 7-0; mask 0x00FF; column index + $lcIndex = 0x00FF & self::getUInt2d($subData, 6); $lc = Cell::stringFromColumnIndex($lcIndex); $lc = '$' . $lc; } else { // column offset - $lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256; - $lc = Cell::stringFromColumnIndex($baseCol + $lcIndex); + // offset: 4; size: 2; first column with relative/absolute flags + // bit: 7-0; mask 0x00FF; column index + $relativeLcIndex = 0x00FF & self::getInt2d($subData, 4); + $lcIndex = $baseCol + $relativeLcIndex; + $lcIndex = ($lcIndex < 256) ? $lcIndex : $lcIndex - 256; + $lcIndex = ($lcIndex >= 0) ? $lcIndex : $lcIndex + 256; + $lc = Cell::stringFromColumnIndex($lcIndex); } // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::getInt2d($subData, 6))) { + if (!(0x8000 & self::getUInt2d($subData, 6))) { // absolute row index $lr = $lrIndex + 1; $lr = '$' . $lr; @@ -6988,7 +6999,7 @@ class Xls extends BaseReader implements IReader $cellRangeAddresses = []; // offset: 0; size: 2; number of the following cell range addresses - $nm = self::getInt2d($subData, 0); + $nm = self::getUInt2d($subData, 0); $offset = 2; // offset: 2; size: 8 * $nm; list of $nm (fixed) cell range addresses @@ -7016,7 +7027,7 @@ class Xls extends BaseReader implements IReader $cellRangeAddresses = []; // offset: 0; size: 2; number of the following cell range addresses - $nm = self::getInt2d($subData, 0); + $nm = self::getUInt2d($subData, 0); $offset = 2; // offset: 2; size: 6 * $nm; list of $nm (fixed) cell range addresses @@ -7104,7 +7115,7 @@ class Xls extends BaseReader implements IReader $nc = ord($arrayData[0]); // offset: 1; size: 2; number of rows decreased by 1 - $nr = self::getInt2d($arrayData, 1); + $nr = self::getUInt2d($arrayData, 1); $size = 3; // initialize $arrayData = substr($arrayData, 3); @@ -7238,7 +7249,7 @@ class Xls extends BaseReader implements IReader private function readByteStringLong($subData) { // offset: 0; size: 2; length of the string (character count) - $ln = self::getInt2d($subData, 0); + $ln = self::getUInt2d($subData, 0); // offset: 2: size: var; character array (8-bit characters) $value = $this->decodeCodepage(substr($subData, 2)); @@ -7288,7 +7299,7 @@ class Xls extends BaseReader implements IReader $value = ''; // offset: 0: size: 2; length of the string (character count) - $characterCount = self::getInt2d($subData, 0); + $characterCount = self::getUInt2d($subData, 0); $string = self::readUnicodeString(substr($subData, 2), $characterCount); @@ -7460,11 +7471,24 @@ class Xls extends BaseReader implements IReader * * @return int */ - public static function getInt2d($data, $pos) + public static function getUInt2d($data, $pos) { return ord($data[$pos]) | (ord($data[$pos + 1]) << 8); } + /** + * Read 16-bit signed integer. + * + * @param string $data + * @param int $pos + * + * @return int + */ + public static function getInt2d($data, $pos) + { + return unpack('s', $data[$pos] . $data[$pos + 1])[1]; + } + /** * Read 32-bit signed integer. * diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index 270272c6..a5e337fd 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -110,7 +110,7 @@ class Escher // Parse Escher stream while ($this->pos < $this->dataSize) { // offset: 2; size: 2: Record Type - $fbt = Xls::getInt2d($this->data, $this->pos + 2); + $fbt = Xls::getUInt2d($this->data, $this->pos + 2); switch ($fbt) { case self::DGGCONTAINER: @@ -182,10 +182,10 @@ class Escher private function readDefault() { // offset 0; size: 2; recVer and recInstance - $verInstance = Xls::getInt2d($this->data, $this->pos); + $verInstance = Xls::getUInt2d($this->data, $this->pos); // offset: 2; size: 2: Record Type - $fbt = Xls::getInt2d($this->data, $this->pos + 2); + $fbt = Xls::getUInt2d($this->data, $this->pos + 2); // bit: 0-3; mask: 0x000F; recVer $recVer = (0x000F & $verInstance) >> 0; @@ -253,7 +253,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -277,7 +277,7 @@ class Escher $rgbUid = substr($recordData, 2, 16); // offset: 18; size: 2; tag - $tag = Xls::getInt2d($recordData, 18); + $tag = Xls::getUInt2d($recordData, 18); // offset: 20; size: 4; size of BLIP in bytes $size = Xls::getInt4d($recordData, 20); @@ -319,7 +319,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -360,7 +360,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -401,7 +401,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -420,7 +420,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -539,7 +539,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -556,7 +556,7 @@ class Escher // offset: 0; size: 2; recVer and recInstance // bit: 4-15; mask: 0xFFF0; recInstance - $recInstance = (0xFFF0 & Xls::getInt2d($this->data, $this->pos)) >> 4; + $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4; $length = Xls::getInt4d($this->data, $this->pos + 4); $recordData = substr($this->data, $this->pos + 8, $length); @@ -577,28 +577,28 @@ class Escher $this->pos += 8 + $length; // offset: 2; size: 2; upper-left corner column index (0-based) - $c1 = Xls::getInt2d($recordData, 2); + $c1 = Xls::getUInt2d($recordData, 2); // offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width - $startOffsetX = Xls::getInt2d($recordData, 4); + $startOffsetX = Xls::getUInt2d($recordData, 4); // offset: 6; size: 2; upper-left corner row index (0-based) - $r1 = Xls::getInt2d($recordData, 6); + $r1 = Xls::getUInt2d($recordData, 6); // offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height - $startOffsetY = Xls::getInt2d($recordData, 8); + $startOffsetY = Xls::getUInt2d($recordData, 8); // offset: 10; size: 2; bottom-right corner column index (0-based) - $c2 = Xls::getInt2d($recordData, 10); + $c2 = Xls::getUInt2d($recordData, 10); // offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width - $endOffsetX = Xls::getInt2d($recordData, 12); + $endOffsetX = Xls::getUInt2d($recordData, 12); // offset: 14; size: 2; bottom-right corner row index (0-based) - $r2 = Xls::getInt2d($recordData, 14); + $r2 = Xls::getUInt2d($recordData, 14); // offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height - $endOffsetY = Xls::getInt2d($recordData, 16); + $endOffsetY = Xls::getUInt2d($recordData, 16); // set the start coordinates $this->object->setStartCoordinates(Cell::stringFromColumnIndex($c1) . ($r1 + 1)); @@ -647,7 +647,7 @@ class Escher $fopte = substr($data, 6 * $i, 6); // offset: 0; size: 2; opid - $opid = Xls::getInt2d($fopte, 0); + $opid = Xls::getUInt2d($fopte, 0); // bit: 0-13; mask: 0x3FFF; opid.opid $opidOpid = (0x3FFF & $opid) >> 0; From 41a1aa9ede042b564521ca5b03e2e34c1115674a Mon Sep 17 00:00:00 2001 From: Davis Devasia Date: Sat, 9 Sep 2017 00:13:12 +0530 Subject: [PATCH 28/31] Uncommented the increment of $imageCounter (#205) The static variable $imageCounter previously had a constant value of 0 throughout the program as it was never being modified, because it was commented out by mistake. Now it increments every time a new drawing is being instantiated. This also fixed a problem when multiple images of same name in the same worksheet are incorrectly displayed. Fixes #204 Closes #205 --- src/PhpSpreadsheet/Worksheet/BaseDrawing.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index 9f9ad163..c9a2921d 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -139,7 +139,8 @@ class BaseDrawing implements IComparable $this->rotation = 0; $this->shadow = new Drawing\Shadow(); - // Set image index++self::$imageCounter; + // Set image index + ++self::$imageCounter; $this->imageIndex = self::$imageCounter; } From e558028eb78a7a584cb92ce2569cf02191a272e6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Sep 2017 18:23:07 +0900 Subject: [PATCH 29/31] Remove extraneous parameter --- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 5 ++--- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 76c86793..7fbb5fb3 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -91,11 +91,10 @@ class DataSeriesValues /** * Create a new DataSeriesValues object. * - * - * @param mixed $dataType + * @param string $dataType * @param string $dataSource * @param null|mixed $formatCode - * @param mixed $pointCount + * @param int $pointCount * @param mixed $dataValues * @param null|mixed $marker * @param null|string $fillColor diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 6e9e1df0..2c636e45 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -310,30 +310,30 @@ class Chart return new DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); } - private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) + private static function chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null) { if (isset($seriesDetail->strRef)) { $seriesSource = (string) $seriesDetail->strRef->f; $seriesData = self::chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']), 's'); - return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker); } elseif (isset($seriesDetail->numRef)) { $seriesSource = (string) $seriesDetail->numRef->f; $seriesData = self::chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c'])); - return new DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker); } elseif (isset($seriesDetail->multiLvlStrRef)) { $seriesSource = (string) $seriesDetail->multiLvlStrRef->f; $seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']), 's'); $seriesData['pointCount'] = count($seriesData['dataValues']); - return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker); } elseif (isset($seriesDetail->multiLvlNumRef)) { $seriesSource = (string) $seriesDetail->multiLvlNumRef->f; $seriesData = self::chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']), 's'); $seriesData['pointCount'] = count($seriesData['dataValues']); - return new DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine); + return new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker); } return null; From ec7312cb64af8d93f56017289ab18a8badfd3bd2 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Sep 2017 18:26:01 +0900 Subject: [PATCH 30/31] Use constants instead of hardcoded values --- samples/33_Chart_create_area.php | 14 +++++------ samples/33_Chart_create_bar_stacked.php | 14 +++++------ samples/33_Chart_create_column.php | 14 +++++------ samples/33_Chart_create_column_2.php | 14 +++++------ samples/33_Chart_create_composite.php | 14 +++++------ samples/33_Chart_create_line.php | 14 +++++------ samples/33_Chart_create_multiple_charts.php | 28 ++++++++++----------- samples/33_Chart_create_pie.php | 12 ++++----- samples/33_Chart_create_radar.php | 12 ++++----- samples/33_Chart_create_scatter.php | 14 +++++------ samples/33_Chart_create_stock.php | 18 ++++++------- samples/templates/chartSpreadsheet.php | 14 +++++------ 12 files changed, 91 insertions(+), 91 deletions(-) diff --git a/samples/33_Chart_create_area.php b/samples/33_Chart_create_area.php index 76a9f478..2fba7ca7 100644 --- a/samples/33_Chart_create_area.php +++ b/samples/33_Chart_create_area.php @@ -31,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -43,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,9 +53,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_bar_stacked.php b/samples/33_Chart_create_bar_stacked.php index af9fb542..86178d79 100644 --- a/samples/33_Chart_create_bar_stacked.php +++ b/samples/33_Chart_create_bar_stacked.php @@ -31,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -43,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,9 +53,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_column.php b/samples/33_Chart_create_column.php index 12903ea6..49d65c75 100644 --- a/samples/33_Chart_create_column.php +++ b/samples/33_Chart_create_column.php @@ -31,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -43,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,9 +53,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_column_2.php b/samples/33_Chart_create_column_2.php index 8ea8d791..f4afcedb 100644 --- a/samples/33_Chart_create_column_2.php +++ b/samples/33_Chart_create_column_2.php @@ -39,9 +39,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 'Budget' - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 'Forecast' - new DataSeriesValues('String', 'Worksheet!$E$1', null, 1), // 'Actual' + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 'Budget' + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 'Forecast' + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), // 'Actual' ]; // Set the X-Axis Labels // Datatype @@ -51,7 +51,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012 ]; // Set the Data values for each data series we want to plot // Datatype @@ -61,9 +61,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), - new DataSeriesValues('Number', 'Worksheet!$E$2:$E$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$13', null, 12), ]; // Build the dataseries diff --git a/samples/33_Chart_create_composite.php b/samples/33_Chart_create_composite.php index d050a3e9..692209f8 100644 --- a/samples/33_Chart_create_composite.php +++ b/samples/33_Chart_create_composite.php @@ -39,13 +39,13 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // Temperature + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // Temperature ]; $dataSeriesLabels2 = [ - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // Rainfall + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // Rainfall ]; $dataSeriesLabels3 = [ - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // Humidity + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // Humidity ]; // Set the X-Axis Labels @@ -56,7 +56,7 @@ $dataSeriesLabels3 = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec ]; // Set the Data values for each data series we want to plot @@ -67,7 +67,7 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues1 = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$13', null, 12), ]; // Build the dataseries @@ -91,7 +91,7 @@ $series1->setPlotDirection(DataSeries::DIRECTION_COL); // Data values // Data Marker $dataSeriesValues2 = [ - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), ]; // Build the dataseries @@ -112,7 +112,7 @@ $series2 = new DataSeries( // Data values // Data Marker $dataSeriesValues3 = [ - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), ]; // Build the dataseries diff --git a/samples/33_Chart_create_line.php b/samples/33_Chart_create_line.php index b2d6e4f3..0f1184f6 100644 --- a/samples/33_Chart_create_line.php +++ b/samples/33_Chart_create_line.php @@ -31,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -43,7 +43,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,9 +53,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_multiple_charts.php b/samples/33_Chart_create_multiple_charts.php index fe20b76d..bd2cf606 100644 --- a/samples/33_Chart_create_multiple_charts.php +++ b/samples/33_Chart_create_multiple_charts.php @@ -31,9 +31,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -43,7 +43,7 @@ $dataSeriesLabels1 = [ // Data values // Data Marker $xAxisTickValues1 = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -53,9 +53,9 @@ $xAxisTickValues1 = [ // Data values // Data Marker $dataSeriesValues1 = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries @@ -103,9 +103,9 @@ $worksheet->addChart($chart1); // Data values // Data Marker $dataSeriesLabels2 = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -115,7 +115,7 @@ $dataSeriesLabels2 = [ // Data values // Data Marker $xAxisTickValues2 = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -125,9 +125,9 @@ $xAxisTickValues2 = [ // Data values // Data Marker $dataSeriesValues2 = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_pie.php b/samples/33_Chart_create_pie.php index 895e0429..3b5ea810 100644 --- a/samples/33_Chart_create_pie.php +++ b/samples/33_Chart_create_pie.php @@ -31,7 +31,7 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels1 = [ - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 ]; // Set the X-Axis Labels // Datatype @@ -41,7 +41,7 @@ $dataSeriesLabels1 = [ // Data values // Data Marker $xAxisTickValues1 = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -51,7 +51,7 @@ $xAxisTickValues1 = [ // Data values // Data Marker $dataSeriesValues1 = [ - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), ]; // Build the dataseries @@ -103,7 +103,7 @@ $worksheet->addChart($chart1); // Data values // Data Marker $dataSeriesLabels2 = [ - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 ]; // Set the X-Axis Labels // Datatype @@ -113,7 +113,7 @@ $dataSeriesLabels2 = [ // Data values // Data Marker $xAxisTickValues2 = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -123,7 +123,7 @@ $xAxisTickValues2 = [ // Data values // Data Marker $dataSeriesValues2 = [ - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_radar.php b/samples/33_Chart_create_radar.php index df81f38c..49053c95 100644 --- a/samples/33_Chart_create_radar.php +++ b/samples/33_Chart_create_radar.php @@ -39,8 +39,8 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -50,8 +50,8 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec - new DataSeriesValues('String', 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec ]; // Set the Data values for each data series we want to plot // Datatype @@ -61,8 +61,8 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', null, 12), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), ]; // Build the dataseries diff --git a/samples/33_Chart_create_scatter.php b/samples/33_Chart_create_scatter.php index df5564d7..f756c5a9 100644 --- a/samples/33_Chart_create_scatter.php +++ b/samples/33_Chart_create_scatter.php @@ -31,13 +31,13 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -47,9 +47,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries diff --git a/samples/33_Chart_create_stock.php b/samples/33_Chart_create_stock.php index 78d16e3f..30c876b5 100644 --- a/samples/33_Chart_create_stock.php +++ b/samples/33_Chart_create_stock.php @@ -37,10 +37,10 @@ $worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(NumberFormat::FO // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), //Max / Open - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), //Min / Close - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), //Min Threshold / Min - new DataSeriesValues('String', 'Worksheet!$E$1', null, 1), //Max Threshold / Max + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), //Max / Open + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), //Min / Close + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), //Min Threshold / Min + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), //Max Threshold / Max ]; // Set the X-Axis Labels // Datatype @@ -50,7 +50,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$6', null, 5), // Counts + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$6', null, 5), // Counts ]; // Set the Data values for each data series we want to plot // Datatype @@ -60,10 +60,10 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$6', null, 5), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$6', null, 5), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$6', null, 5), - new DataSeriesValues('Number', 'Worksheet!$E$2:$E$6', null, 5), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$6', null, 5), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$6', null, 5), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$6', null, 5), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$6', null, 5), ]; // Build the dataseries diff --git a/samples/templates/chartSpreadsheet.php b/samples/templates/chartSpreadsheet.php index c462f533..7406e4be 100644 --- a/samples/templates/chartSpreadsheet.php +++ b/samples/templates/chartSpreadsheet.php @@ -28,9 +28,9 @@ $worksheet->fromArray( // Data values // Data Marker $dataSeriesLabels = [ - new DataSeriesValues('String', 'Worksheet!$B$1', null, 1), // 2010 - new DataSeriesValues('String', 'Worksheet!$C$1', null, 1), // 2011 - new DataSeriesValues('String', 'Worksheet!$D$1', null, 1), // 2012 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 ]; // Set the X-Axis Labels // Datatype @@ -40,7 +40,7 @@ $dataSeriesLabels = [ // Data values // Data Marker $xAxisTickValues = [ - new DataSeriesValues('String', 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 ]; // Set the Data values for each data series we want to plot // Datatype @@ -50,9 +50,9 @@ $xAxisTickValues = [ // Data values // Data Marker $dataSeriesValues = [ - new DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', null, 4), - new DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), + new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), ]; // Build the dataseries From 1cf119dd0b442502127192546270c8eb56eb0262 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Sep 2017 19:29:08 +0900 Subject: [PATCH 31/31] Escape control characters in cell values Control characters in cell values are automatically escaped without the need to excplicitly call `StringHelper::buildCharacterSets()` beforehand. Fixes #212 --- CHANGELOG.md | 2 ++ src/PhpSpreadsheet/Shared/StringHelper.php | 9 ++++++- .../{StringTest.php => StringHelperTest.php} | 26 ++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) rename tests/PhpSpreadsheetTests/Shared/{StringTest.php => StringHelperTest.php} (74%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7dfefca..2b85901e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Control characters in cell values are automatically escaped [#212](https://github.com/PHPOffice/PhpSpreadsheet/issues/212) + ### BREAKING CHANGE - Standardization of array keys used for style, see the [migration guide](./docs/topics/migration-from-PHPExcel.md). diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index b7e8e568..8eb66423 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -300,11 +300,12 @@ class StringHelper return true; } - public static function buildCharacterSets() + private static function buildCharacterSets() { if (empty(self::$controlCharacters)) { self::buildControlCharacters(); } + if (empty(self::$SYLKCharacters)) { self::buildSYLKCharacters(); } @@ -327,6 +328,8 @@ class StringHelper */ public static function controlCharacterOOXML2PHP($value) { + self::buildCharacterSets(); + return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value); } @@ -347,6 +350,8 @@ class StringHelper */ public static function controlCharacterPHP2OOXML($value) { + self::buildCharacterSets(); + return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value); } @@ -713,6 +718,8 @@ class StringHelper */ public static function SYLKtoUTF8($pValue) { + self::buildCharacterSets(); + // If there is no escape character in the string there is nothing to do if (strpos($pValue, '') === false) { return $pValue; diff --git a/tests/PhpSpreadsheetTests/Shared/StringTest.php b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php similarity index 74% rename from tests/PhpSpreadsheetTests/Shared/StringTest.php rename to tests/PhpSpreadsheetTests/Shared/StringHelperTest.php index 9fbaba33..67b82f7e 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php @@ -5,7 +5,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Shared; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PHPUnit_Framework_TestCase; -class StringTest extends PHPUnit_Framework_TestCase +class StringHelperTest extends PHPUnit_Framework_TestCase { public function setUp() { @@ -73,4 +73,28 @@ class StringTest extends PHPUnit_Framework_TestCase $result = StringHelper::getCurrencyCode(); $this->assertEquals($expectedResult, $result); } + + public function testControlCharacterPHP2OOXML() + { + $expectedResult = 'foo_x000B_bar'; + $result = StringHelper::controlCharacterPHP2OOXML('foo' . chr(11) . 'bar'); + + $this->assertEquals($expectedResult, $result); + } + + public function testControlCharacterOOXML2PHP() + { + $expectedResult = 'foo' . chr(11) . 'bar'; + $result = StringHelper::controlCharacterOOXML2PHP('foo_x000B_bar'); + + $this->assertEquals($expectedResult, $result); + } + + public function testSYLKtoUTF8() + { + $expectedResult = 'foo' . chr(11) . 'bar'; + $result = StringHelper::SYLKtoUTF8("foo\x1B ;bar"); + + $this->assertEquals($expectedResult, $result); + } }