diff --git a/.gitignore b/.gitignore index 66f52a1..260600a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ tests/*/*/*.php tests/*/*/*.exp tmp-php.ini libxl/* +.idea/* +/.idea/workspace.xml diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3bb978c --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,116 @@ +# Code of Conduct - doPhp/excel + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, +threatening, offensive, or harmful. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will +communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at . +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version +[1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and +[2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md), +and was generated by [contributing-gen](https://github.com/bttger/contributing-gen). \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..aae06c3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,159 @@ + +# Contributing to doPhp/excel + +First off, thanks for taking the time to contribute! ❤️ + +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉 + +> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: +> - Star the project +> - Tweet about it +> - Refer this project in your project's readme +> - Mention the project at local meetups and tell your friends/colleagues + + +## Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [I Have a Question](#i-have-a-question) +- [I Want To Contribute](#i-want-to-contribute) + - [Reporting Bugs](#reporting-bugs) + - [Suggesting Enhancements](#suggesting-enhancements) + - [Your First Code Contribution](#your-first-code-contribution) + - [Improving The Documentation](#improving-the-documentation) +- [Styleguides](#styleguides) + - [Commit Messages](#commit-messages) +- [Join The Project Team](#join-the-project-team) + + +## Code of Conduct + +This project and everyone participating in it is governed by the +[doPhp/excel Code of Conduct](https://github.com/doPhp/excel/CODE_OF_CONDUCT.md). +By participating, you are expected to uphold this code. Please report unacceptable behavior +to . + + +## I Have a Question + +> If you want to ask a question, we assume that you have read the available [Documentation](TBD). + +Before you ask a question, it is best to search for existing [Issues](https://github.com/doPhp/excel/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first. + +If you then still feel the need to ask a question and need clarification, we recommend the following: + +- Open an [Issue](https://github.com/doPhp/excel/issues/new). +- Provide as much context as you can about what you're running into. +- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. + +We will then take care of the issue as soon as possible. + + + +## I Want To Contribute + +> ### Legal Notice +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. + +### Reporting Bugs + + +#### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](TBD). If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/doPhp/excel/issues?q=label%3Abug). +- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. +- Collect information about the bug: + - Stack trace (Traceback) + - OS, Platform and Version (Windows, Linux, macOS, x86, ARM) + - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. + - Possibly your input and the output + - Can you reliably reproduce the issue? And can you also reproduce it with older versions? + + +#### How Do I Submit a Good Bug Report? + +> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to . + + +We use GitHub issues to track bugs and errors. If you run into an issue with the project: + +- Open an [Issue](https://github.com/doPhp/excel/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). + + + + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for doPhp/excel, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +#### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Read the [documentation](TBD) carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://github.com/doPhp/excel/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. + + +#### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://github.com/doPhp/excel/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. +- **Explain why this enhancement would be useful** to most doPhp/excel users. You may also want to point out the other projects that solved it better and which could serve as inspiration. + + + +### Your First Code Contribution + + +### Improving The Documentation + + +## Styleguides +### Commit Messages + + +## Join The Project Team + + + +## Attribution +This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)! diff --git a/ChangeLog b/ChangeLog index 28ebdc8..442cc74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,16 @@ -[2016-??-??] - Version 1.0.3dev +[2018-??-??] - Version 1.0.3dev + * Fixed crash when trying to read an empty file + * Fixed bug with writing references (see issue #234) + * Added PECL package.xml to allow installation via pecl + * Added ExcelSheet::AS_STRING const to use with write operations (see PR 183 by ederuiter) + * Added new methods (requires LibXL 3.8.0) + - ExcelBook::addPictureAsLink() + - ExcelBook::moveSheet() + - ExcelSheet::addDataValidation() + - ExcelSheet::addDataValidationDouble() + - ExcelSheet::removeDataValidations() + * Added ExcelBook::getLibXlVersion() + * Added ExcelBook::getPhpExcelVersion() [2016-06-23] - Version 1.0.2 * Fixed bug in ExcelSheet::addPictureDim() (see issue #120) @@ -10,6 +22,8 @@ - ExcelBook::printRepeatRows() * Added support for LibXL 3.6.3 * ExcelSheet::addPictureDim() & ExcelSheet::addPictureScaled() now support position parameters + * Includes official PHP7 release + * Added support for libxl compiled from source [2015-02-26] - Version 1.0.1 * Added methods diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5bc9013 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- + The PHP License, version 3.01 +Copyright (c) 1999 - 2019 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact group@php.net. + +4. Products derived from this software may not be called "PHP", nor + may "PHP" appear in their name, without prior written permission + from group@php.net. You may indicate that your software works in + conjunction with PHP by saying "Foo for PHP" instead of calling + it "PHP Foo" or "phpfoo" + +5. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. + Once covered code has been published under a particular version + of the license, you may always continue to use it under the terms + of that version. You may also choose to use such covered code + under the terms of any subsequent version of the license + published by the PHP Group. No one other than the PHP Group has + the right to modify the terms applicable to covered code created + under this License. + +6. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes PHP software, freely available from + ". + +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by many +individuals on behalf of the PHP Group. + +The PHP Group can be contacted via Email at group@php.net. + +For more information on the PHP Group and the PHP project, +please see . + +PHP includes the Zend Engine, freely available at +. diff --git a/README.markdown b/README.markdown deleted file mode 100644 index 8ca257e..0000000 --- a/README.markdown +++ /dev/null @@ -1,127 +0,0 @@ -## Description - -This extension uses libXl library to provide API for generating or parsing -all Excel files. - -libxl is a high-performance mechanism for working with Excel files and is -able to generate output readable on Blackberries, iPhone, Office Products, -Numbers, etc... - -## Documentation - -Please see the ```docs/``` and the ```tests/``` directory. - -## Resources - -* [required LibXL library (commercial)](http://www.libxl.com/) -* [slides of confoo talk about php_excel](http://ilia.ws/files/confoo_phpexcel.pdf) - -## Installation - -### Linux - -``` shell -# change into php source files directory -cd php-5.x.x - -# clone repository into php extension dir -git clone https://github.com/iliaal/php_excel.git ext/excel - -# to build php7 module, you should use php7 git branch -cd ext/excel && git checkout php7 && cd ../.. - -# rebuild configure -./buildconf --force - -# replace with the file path to the extracted libxl files -# on a 32-bit platform use -./configure --with-excel --with-libxl-incdir=/libxl-3.6.0.1/include_c --with-libxl-libdir=/libxl-3.6.0.1/lib - -# on a 64-bit platform use -./configure --with-excel --with-libxl-incdir=/libxl-3.6.0.1/include_c --with-libxl-libdir=/libxl-3.6.0.1/lib64 -``` - -### Windows - -Pre-build packages for Windows can be downloaded [here](http://windows.php.net/downloads/pecl/snaps/excel). - -## Getting started - -``` php -', '', $useXlsxFormat); -$xlBook->setLocale('UTF-8'); - -// add sheet to work book -$xlSheet1 = $xlBook->addSheet('Sheet1'); - -// create a small sample data set -$dataset = [ - [1, 1500, 'John', 'Doe'], - [2, 750, 'Jane', 'Doe'] -]; - -// write data set to sheet -$row = 1; -foreach($dataset as $item){ - $xlSheet1->writeRow($row, $item); - $row++; -} - -// write sum formula under data set -$col = 1; -$xlSheet1->write($row, $col, '=SUM(B1:B3)'); - -// add second sheet to work book -$xlSheet2 = $xlBook->addSheet('Sheet2'); - -// add a date with specific date format to second sheet -$row = 1; $col = 0; -$date = new \DateTime('2014-08-02'); -$dateFormat = new \ExcelFormat($xlBook); -$dateFormat->numberFormat(\ExcelFormat::NUMFORMAT_DATE); -$xlSheet2->write($row, $col, $date->getTimestamp(), $dateFormat, \ExcelFormat::AS_DATE); - -// save workbook -$xlBook->save('test.xlsx'); -``` - -## optional php.ini settings - -To prevent unvealing your credentials in your code you can save them in your php.ini file. -They will be automatically fetched by the extension and you can pass ```null``` instead of -your credentials ```new \ExcelBook(null, null, $useXlsxFormat)```. - -``` ini -; optional settings for excel extension -[excel] -excel.license_name="" -excel.license_key="" -excel.skip_empty=0 -``` - -## Known Issues - -### Formulas written but no values readable - -**Excel stores value and formula** for each cell while **LibXL stores only the formula**. This means -if you create an Excel sheet with php_excel and write a formula like ```=SUM(A1:B1)``` in cell ```C1``` you can't -read the value of the calculation by reading cell ```C1``` in a later step. There has been observations that -this can also affect the OS pre-view of Excel files. You can circumvent this by opening and saving the file directly -in Excel or using the COM classes to open and save the Excel file via PHP. (**In both cases Excel is required!**) - -### multibyte characters in credentials - -If your credentials does not work properly because of multibyte characters you can compile php_excel with -```--with-xml --with-libxml --with-iconv``` and your credentials will be automatically ```utf8_decoded()``` -before using with LibXL. - -If you compile php_excel as a shared extension on Linux you need to provide the path to the libxml directory. -e.g. on Ubuntu you need to compile with ```--with-libxml-dir=/usr/include/libxml2```. - -### Further reading - -* [Performant-Handling-Excel-Files-PHP](http://blog.mayflower.de/4922-Performant-Handling-Excel-Files-PHP.html) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e62fd27 --- /dev/null +++ b/README.md @@ -0,0 +1,171 @@ +## Description + +This extension uses libXl library to provide API for generating or parsing +all Excel files. + +libxl is a high-performance mechanism for working with Excel files and is +able to generate output readable on Blackberries, iPhone, Office Products, +Numbers, etc... + +## Documentation + +Please see the ```docs/``` and the ```tests/``` directory. + +## Resources + +* [required LibXL library (commercial)](http://www.libxl.com/) +* [slides of confoo talk about php_excel](http://ilia.ws/files/confoo_phpexcel.pdf) + +## Installation + +### Linux + +``` shell +# change into php source files directory + +cd php-8.x.x + +# clone repository into php extension dir +git clone https://github.com/doPhp/excel.git -b php8 ext/excel + +# to build php8 module, you should use php8 git branch +cd ext/excel && git checkout php8 && cd ../.. + +# rebuild configure +./buildconf --force + +# replace with the file path to the extracted libxl files +# on a 32-bit platform use +./configure --with-excel=shared --with-libxl-incdir=/libxl-4.1.2/include_c --with-libxl-libdir=/libxl-4.1.2/lib + +# on a 64-bit platform use +./configure --with-excel=shared --with-libxl-incdir=/libxl-4.1.2/include_c --with-libxl-libdir=/libxl-4.1.2/lib64 +``` + +### Windows + +Pre-build packages for Windows can be downloaded [here](https://www.apachelounge.com/viewtopic.php?t=6617). To build the package for +Windows on your own you may want to visit this [project](https://github.com/johmue/win-php-sdk-builder). + +### PHP8 + +* requires LibXL 3.6.0+ +* use the php8 branch of the github repo + +## Getting started + +``` php +', '', $useXlsxFormat); +$xlBook->setLocale('UTF-8'); + +// add sheet to work book +$xlSheet1 = $xlBook->addSheet('Sheet1'); + +// create a small sample data set +$dataset = [ + [1, 1500, 'John', 'Doe'], + [2, 750, 'Jane', 'Doe'] +]; + +// write data set to sheet +$row = 1; +foreach($dataset as $item){ + $xlSheet1->writeRow($row, $item); + $row++; +} + +// write sum formula under data set +$col = 1; +$xlSheet1->write($row, $col, '=SUM(B1:B3)'); + +// add second sheet to work book +$xlSheet2 = $xlBook->addSheet('Sheet2'); + +// add a date with specific date format to second sheet +$row = 1; $col = 0; +$date = new \DateTime('2014-08-02'); +$dateFormat = new \ExcelFormat($xlBook); +$dateFormat->numberFormat(\ExcelFormat::NUMFORMAT_DATE); +$xlSheet2->write($row, $col, $date->getTimestamp(), $dateFormat, \ExcelFormat::AS_DATE); + +// save workbook +$xlBook->save('test.xlsx'); +``` + +## optional php.ini settings + +To prevent unvealing your credentials in your code you can save them in your php.ini file. +They will be automatically fetched by the extension and you can pass ```null``` instead of +your credentials ```new \ExcelBook(null, null, $useXlsxFormat)```. + +``` ini +; optional settings for excel extension +[excel] +excel.license_name="" +excel.license_key="" +excel.skip_empty=0 +``` + +## Known Issues + +### Formulas written but no values readable + +**Excel stores value and formula** for each cell while **LibXL stores only the formula**. This means +if you create an Excel sheet with php_excel and write a formula like ```=SUM(A1:B1)``` in cell ```C1``` you cannot +read the value of the calculation by reading cell ```C1``` in a later step. There have been observations that +this can also affect the OS pre-view of Excel files which rely on values. You can circumvent this by opening and saving the file directly +in Excel by using the [COM](http://de2.php.net/manual/en/class.com.php) or [DOTNET](http://de2.php.net/manual/en/class.dotnet.php) +interface. (**Excel is required!**) + +``` php +/** + * if you are having trouble try adding usleep(1000000) between the steps + * for a pause of 1s or kill running Excel tasks beforehand e.g. with PHP on Windows + * exec('TASKKILL /F /FI "IMAGENAME eq EXCEL.EXE" /T', $out); + */ + +$workbook = realpath($file); +$excelHandler = new \COM("Excel.sheet") or die('Failed to connect Excel COM handler in file '.__FILE__.' on line '.__LINE__); +$excelHandler->Application->Workbooks->Open($workbook) or die('Failed to open Excel Workbook '.$file.' in file '.__FILE__.' on line '.__LINE__); +$excelHandler->Application->ActiveWorkbook->Save(); +$excelHandler->Application->ActiveWorkbook->Close(); +$excelHandler->Application->Quit(); +$excelHandler = null; +``` + +### multibyte characters in credentials + +If your credentials do not work properly because of multibyte characters you can extend ExcelBook +class and circumvent the build-in mechanism for ```php.ini``` settings. + +``` php +setLocale('UTF-8'); + } +} +``` + +### Testing (Windows) + +After you have build the extension you can use ```nmake test``` to run the test suite against the php_excel extension. + +``` shell +..\php-8.2.4> nmake test TESTS="-d extension=php_excel.dll -d date.timezone=\"America/Toronto\" -d excel.license_name=\"LICENSE_NAME\" -d excel.license_key=\"LICENSE_KEY\" ./ext/php_excel" +``` + +### Further reading + +* [Performant-Handling-Excel-Files-PHP](http://blog.mayflower.de/4922-Performant-Handling-Excel-Files-PHP.html) diff --git a/docs/ExcelAutoFilter.php b/docs/ExcelAutoFilter.php new file mode 100644 index 0000000..91999a6 --- /dev/null +++ b/docs/ExcelAutoFilter.php @@ -0,0 +1,107 @@ + | + | | + | php_excel "PECL" style module (http://github.com/iliaal/php_excel) | + | libxl library (http://www.libxl.com) | + | | + +---------------------------------------------------------------------------+ +*/ +class ExcelAutoFilter +{ + /** + * Create a AutoFilter within an Excel sheet + * + * @see ExcelSheet::autofilter() + * @param ExcelSheet $sheet + * @return ExcelAutoFilter + */ + public function __construct(ExcelSheet $sheet) + { + } // __construct + + /** + * Gets the cell range of AutoFilter with header. + * + * @return array with keys "row_first"(int), "row_last"(int), "col_first"(int), "col_last"(int) + */ + public function getRef() + { + } // getRef + + /** + * Sets the cell range of AutoFilter with header. + * + * @param int $row_first 0-based (optional, default = 0) + * @param int $row_last 0-based (optional, default = 0) + * @param int $col_first 0-based (optional, default = 0) + * @param int $col_last 0-based (optional, default = 0) + * @return void + */ + public function setRef($row_first = 0, $row_last = 0, $col_first = 0, $col_last = 0) + { + } // setRef + + /** + * Returns the AutoFilter column by zero-based index. Creates it if it doesn't exist. + * + * @param int $colId 0-based + * @return ExcelFilterColumn + */ + public function column($colId) + { + } // column + + /** + * Returns the number of specified AutoFilter columns which have a filter information. + * + * @return int + */ + public function columnSize() + { + } // columnSize + + /** + * Returns the specified AutoFilter column which have a filter information by index. + * + * @param int $index 0-based + * @return ExcelFilterColumn + */ + public function columnByIndex($index) + { + } // columnByIndex + + /** + * Gets the whole range of data to sort. + * + * @return array with keys "row_first"(int), "col_first"(int), "row_last"(int), "col_last"(int) + */ + public function getSortRange() + { + } // getSortRange + + /** + * Gets the zero-based index of sorted column in AutoFilter and its sort order. + * + * @return array with keys "column_index"(int), "descending"(bool), + */ + public function getSort() + { + } // getSort + + /** + * Sets the sorted column in AutoFilter by zero-based index and its sort order. + * + * @param int $columnIndex 0-based + * @param bool $descending + * @return bool + */ + public function setSort($columnIndex, $descending) + { + } // setSort + +} // end ExcelAutoFilter diff --git a/docs/ExcelBook.php b/docs/ExcelBook.php index bac1b5f..459ee7a 100644 --- a/docs/ExcelBook.php +++ b/docs/ExcelBook.php @@ -84,6 +84,22 @@ public function addFormat(ExcelFormat $format = null) { } // addFormat + /** + * Adds a picture to the workbook as link (only for xlsx files). + * Supports BMP, DIB, PNG, JPG and WMF picture formats. Use picture identifier with + * \ExcelSheet::setPictureDim() or \ExcelSheet::setPictureScale() + * @see \ExcelSheet::setPictureDim() + * @see \ExcelSheet::setPictureScale() + * + * @since libXl 3.8.0.0 + * @param string $filename + * @param bool $insert (optional, default = false) false - stores only a link to file, true - stores a picture and a link to file. + * @return int picture identifier + */ + public function addPictureAsLink($filename, $insert = false) + { + } // addPictureAsLink + /** * Add a picture from file * @@ -224,6 +240,15 @@ public function getError() { } // getError + /** + * Get LibXL version + * + * @return string LibXl library version + */ + public function getLibXlVersion() + { + } // getLibXlVersion + /** * Returns a number of pictures in this workbook. * @@ -233,6 +258,15 @@ public function getNumPictures() { } // getNumPictures + /** + * Get PHP excel extension version + * + * @return string PHP Excel version + */ + public function getPhpExcelVersion() + { + } // getPhpExcelVersion + /** * Returns a picture at position index. * @@ -326,6 +360,28 @@ public function loadFile($filename) { } // loadFile + /** + * Load Excel sheet info + * + * @param string $filename + * @return bool + */ + public function loadInfo($filename) + { + } // loadInfo + + /** + * Moves a sheet with specified index to a new position. Returns false if error occurs. + * + * @since libXL 3.8.0.0 + * @param int $srcIndex + * @param int $dstIndex + * @return bool + */ + public function moveSheet($srcIndex, $dstIndex) + { + } // moveSheet + /** * Pack a unix timestamp into an Excel double * @@ -462,6 +518,16 @@ public function sheetCount() { } // sheetCount + /** + * Returns the sheet name by index + * + * @param int $index + * @return string + */ + public function getSheetName($index) + { + } // getSheetName + /** * Returns type of sheet with specified index: * 0 - sheet diff --git a/docs/ExcelFilterColumn.php b/docs/ExcelFilterColumn.php new file mode 100644 index 0000000..7514cab --- /dev/null +++ b/docs/ExcelFilterColumn.php @@ -0,0 +1,143 @@ + | + | | + | php_excel "PECL" style module (http://github.com/iliaal/php_excel) | + | libxl library (http://www.libxl.com) | + | | + +---------------------------------------------------------------------------+ +*/ +class ExcelFilterColumn +{ + const FILTER_VALUE = 0; + const FILTER_TOP10 = 1; + const FILTER_CUSTOM = 2; + const FILTER_DYNAMIC = 3; + const FILTER_COLOR = 4; + const FILTER_ICON = 5; + const FILTER_EXT = 6; + const FILTER_NOT_SET = 7; + + const OPERATOR_EQUAL = 0; + const OPERATOR_GREATER_THAN = 1; + const OPERATOR_GREATER_THAN_OR_EQUAL = 2; + const OPERATOR_LESS_THAN = 3; + const OPERATOR_LESS_THAN_OR_EQUAL = 4; + const OPERATOR_NOT_EQUAL = 5; + + /** + * Create a filter column within an Excel auto filter + * + * @see ExcelAutoFilter::column() + * @param ExcelAutoFilter $autoFilter + * @return ExcelFilterColumn + */ + public function __construct(ExcelAutoFilter $autoFilter) + { + } // __construct + + /** + * Returns the zero-based index of this AutoFilter column. + * + * @return int + */ + public function index() + { + } // index + + /** + * Returns the filter type of this AutoFilter column. + * + * @return int One of ExcelFilterColumn::FILTER_* constants + */ + public function filterType() + { + } // filterType + + /** + * Returns the number of filter values. + * + * @return int + */ + public function filterSize() + { + } // filterSize + + /** + * Returns the filter value by index. + * + * @param int $index + * @return string filter value + */ + public function filter($index) + { + } // filter + + /** + * Adds the filter value. + * + * @param string $filterValue + * @return void + */ + public function addFilter($filterValue) + { + } // addFilter + + /** + * Gets the number of top or bottom items: + * + * @return array with keys "value"(float), "top"(bool) and "percent"(bool) + */ + public function getTop10() + { + } // getTop10 + + /** + * Sets the number of top or bottom items: + * + * @param float $value - number of items; + * @param bool $top - top items if true otherwise bottom items; (optional, default = true) + * @param bool $percent - using percent instead of number items. (optional, default = false) + * @return bool + */ + public function setTop10($value, $top = true, $percent = false) + { + } // setTop10 + + /** + * Gets the custom filter criteria: + * + * @return array with keys "operator_1"(int), "value_1"(string), "operator_2"(int), "value_2"(string) and "andOp"(bool) + */ + public function getCustomFilter() + { + } // getCustomFilter + + /** + * Sets the custom filter criteria. + * + * @param int $op1 - one of ExcelFilterColumn::OPERATOR_* constants - operator used by the filter comparison in the first filter criteria; + * @param string $v1 - value used in the first filter criteria; + * @param int $op2 - one of ExcelFilterColumn::OPERATOR_* constants - operator used by the filter comparison in the second filter criteria; (optional, default = -1) + * @param string $v2 - value used in the second filter criteria; (optional, default = null) + * @param bool $andOp - flag indicating whether the two criterias have an "and" relationship. True indicates "and", false indicates "or". (optional, default = false) + * @return void + */ + public function setCustomFilter($op1, $v1, $op2 = -1, $v2 = null, $andOp = false) + { + } // setCustomFilter + + /** + * Clear the filter criteria. + * + * @return bool + */ + public function clear() + { + } // clear + +} // end ExcelFilterColumn diff --git a/docs/ExcelFont.php b/docs/ExcelFont.php index cb4fe92..53f3fae 100644 --- a/docs/ExcelFont.php +++ b/docs/ExcelFont.php @@ -31,7 +31,7 @@ class ExcelFont * @param ExcelBook $book * @return ExcelFont */ - public function __construct($book) + public function __construct(ExcelBook $book) { } // __construct diff --git a/docs/ExcelSheet.php b/docs/ExcelSheet.php index 372e9f0..f9bee2d 100644 --- a/docs/ExcelSheet.php +++ b/docs/ExcelSheet.php @@ -71,10 +71,64 @@ class ExcelSheet const ERRORTYPE_NAME = 29; const ERRORTYPE_NUM = 36; const ERRORTYPE_NA = 42; + const ERRORTYPE_NOERROR = 255; const LEFT_TO_RIGHT = 0; const RIGHT_TO_LEFT = 1; + const IERR_EVAL_ERROR = 1; + const IERR_EMPTY_CELLREF = 2; + const IERR_NUMBER_STORED_AS_TEXT = 4; + const IERR_INCONSIST_RANGE = 8; + const IERR_INCONSIST_FMLA = 16; + const IERR_TWODIG_TEXTYEAR = 32; + const IERR_UNLOCK_FMLA = 64; + const IERR_DATA_VALIDATION = 128; + + const PROT_DEFAULT = -1; + const PROT_ALL = 0; + const PROT_OBJECTS = 1; + const PROT_SCENARIOS = 2; + const PROT_FORMAT_CELLS = 4; + const PROT_FORMAT_COLUMNS = 8; + const PROT_FORMAT_ROWS = 16; + const PROT_INSERT_COLUMNS = 32; + const PROT_INSERT_ROWS = 64; + const PROT_INSERT_HYPERLINKS = 128; + const PROT_DELETE_COLUMNS = 256; + const PROT_DELETE_ROWS = 512; + const PROT_SEL_LOCKED_CELLS = 1024; + const PROT_SORT = 2048; + const PROT_AUTOFILTER = 4096; + const PROT_PIVOTTABLES = 8192; + const PROT_SEL_UNLOCKED_CELLS = 16384; + + const SHEETSTATE_VISIBLE = 0; + const SHEETSTATE_HIDDEN = 1; + const SHEETSTATE_VERYHIDDEN = 2; + + const VALIDATION_TYPE_NONE = 0; + const VALIDATION_TYPE_WHOLE = 1; + const VALIDATION_TYPE_DECIMAL = 2; + const VALIDATION_TYPE_LIST = 3; + const VALIDATION_TYPE_DATE = 4; + const VALIDATION_TYPE_TIME = 5; + const VALIDATION_TYPE_TEXTLENGTH = 6; + const VALIDATION_TYPE_CUSTOM = 7; + + const VALIDATION_OP_BETWEEN = 0; + const VALIDATION_OP_NOTBETWEEN = 1; + const VALIDATION_OP_EQUAL = 2; + const VALIDATION_OP_NOTEQUAL = 3; + const VALIDATION_OP_LESSTHAN = 4; + const VALIDATION_OP_LESSTHANOREQUAL = 5; + const VALIDATION_OP_GREATERTHAN = 6; + const VALIDATION_OP_GREATERTHANOREQUAL = 7; + + const VALIDATION_ERRSTYLE_STOP = 0; // stop icon in the error alert + const VALIDATION_ERRSTYLE_WARNING = 1; // warning icon in the error alert + const VALIDATION_ERRSTYLE_INFORMATION = 2; // information icon in the error alert + /** * Create an ExcelSheet in given Workbook * @@ -86,6 +140,59 @@ public function __construct(ExcelBook $book, $name) { } // __construct + /** + * Adds a data validation for the specified range (only for xlsx files). + * + * @since libXL 3.8.0.0 + * @param int $type - one of the ExcelSheet::VALIDATION_TYPE_* constants + * @param int $op - one of the ExcelSheet::VALIDATION_OP_* constants + * @param int $row_first 0-based + * @param int $row_last 0-based + * @param int $col_first 0-based + * @param int $col_last 0-based + * @param string $val_1 the first value for relational operator + * @param string $val_2 the second value for VALIDATION_OP_BETWEEN or VALIDATION_OP_NOTBETWEEN operator + * @param bool $allow_blank (optional, default = true) a boolean value indicating whether the data validation treats empty or blank entries as valid, 'true' means empty entries are OK and do not violate the validation constraints + * @param bool $hide_dropdown (optional, default = false) a boolean value indicating whether to display the dropdown combo box for a list type data validation (ExcelSheet::VALIDATION_TYPE_LIST) + * @param bool $show_inputmessage (optional, default = true) a boolean value indicating whether to display the input prompt message + * @param bool $show_errormessage (optional, default = true) a boolean value indicating whether to display the error alert message when an invalid value has been entered, according to the criteria specified + * @param string $prompt_title (optional, default = '') title bar text of input prompt + * @param string $prompt (optional, default = '') message text of input prompt + * @param string $error_title (optional, default = '') title bar text of error alert + * @param string $error (optional, default = '') message text of error alert + * @param int $error_style - (optional, default = \ExcelSheet::VALIDATION_ERRSTYLE_WARNING) one of the ExcelSheet::VALIDATION_ERRSTYLE_* constants + */ + public function addDataValidation($type, $op, $row_first, $row_last, $col_first, $col_last, $val_1, $val_2 = null, $allow_blank = true, $hide_dropdown = false, $show_inputmessage = true, $show_errormessage = true, $prompt_title = '', $prompt = '', $error_title = '', $error = '', $error_style = \ExcelSheet::VALIDATION_ERRSTYLE_WARNING) + { + } // addDataValidation + + /** + * Adds a data validation for the specified range with double or date values for the relational + * operator (only for xlsx files). + * + * @since libXL 3.8.0.0 + * @param int $type - one of the ExcelSheet::VALIDATION_TYPE_* constants + * @param int $op - one of the ExcelSheet::VALIDATION_OP_* constants + * @param int $row_first 0-based + * @param int $row_last 0-based + * @param int $col_first 0-based + * @param int $col_last 0-based + * @param float $val_1 the first value for relational operator + * @param float $val_2 the second value for VALIDATION_OP_BETWEEN or VALIDATION_OP_NOTBETWEEN operator + * @param bool $allow_blank (optional, default = true) a boolean value indicating whether the data validation treats empty or blank entries as valid, 'true' means empty entries are OK and do not violate the validation constraints + * @param bool $hide_dropdown (optional, default = false) a boolean value indicating whether to display the dropdown combo box for a list type data validation (ExcelSheet::VALIDATION_TYPE_LIST) + * @param bool $show_inputmessage (optional, default = true) a boolean value indicating whether to display the input prompt message + * @param bool $show_errormessage (optional, default = true) a boolean value indicating whether to display the error alert message when an invalid value has been entered, according to the criteria specified + * @param string $prompt_title (optional, default = '') title bar text of input prompt + * @param string $prompt (optional, default = '') message text of input prompt + * @param string $error_title (optional, default = '') title bar text of error alert + * @param string $error (optional, default = '') message text of error alert + * @param int $error_style - (optional, default = \ExcelSheet::VALIDATION_ERRSTYLE_WARNING) one of the ExcelSheet::VALIDATION_ERRSTYLE_* constants + */ + public function addDataValidationDouble($type, $op, $row_first, $row_last, $col_first, $col_last, $val_1, $val_2 = null, $allow_blank = true, $hide_dropdown = false, $show_inputmessage = true, $show_errormessage = true, $prompt_title = '', $prompt = '', $error_title = '', $error = '', $error_style = \ExcelSheet::VALIDATION_ERRSTYLE_WARNING) + { + } // addDataValidationDouble + /** * Adds the new hyperlink. * @@ -100,6 +207,20 @@ public function addHyperlink($hyperlink, $row_first, $row_last, $col_first, $col { } // addHyperlink + /** + * Adds the ignored error for specified range. It allows to hide green triangles on left sides of cells. + * + * @param int $error - one of the ExcelSheet::IERR_* constants + * @param int $row_first 0-based (optional, default = 0) + * @param int $col_first 0-based (optional, default = 0) + * @param int $row_last 0-based (optional, default = 0) + * @param int $col_last 0-based (optional, default = 0) + * @return bool + */ + public function addIgnoredError($error, $row_first=0, $col_first=0, $row_last=0, $col_last=0) + { + } // addIgnoredError + /** * Insert a picture into a cell with given dimensions * @@ -147,6 +268,33 @@ public function addrToRowCol($cell_reference) { } // addrToRowCol + /** + * Returns the AutoFilter. Creates it if it doesn't exist. + * + * @return ExcelAutoFilter + */ + public function autoFilter() + { + } // autoFilter + + /** + * Applies the AutoFilter to the sheet. + * + * @return bool + */ + public function applyFilter() + { + } // applyFilter + + /** + * Removes the AutoFilter from the sheet. + * + * @return bool + */ + public function removeFilter() + { + } // removeFilter + /** * Get the cell format * @@ -163,7 +311,7 @@ public function cellFormat($row, $column) * * @param int $row 0-based row number * @param int $column 0-based column number - * @return int One of ExcelSheet:CELLTYPE_* constants + * @return int One of ExcelSheet::CELLTYPE_* constants */ public function cellType($row, $column) { @@ -625,9 +773,10 @@ public function horPageBreak($row, $break) * * @param int $column_start 0-based column number * @param int $column_end 0-based column number + * @param bool $update_named_ranges (optional, default=true) * @return bool */ - public function insertCol($column_start, $column_end) + public function insertCol($column_start, $column_end, $update_named_ranges = true) { } // insertCol @@ -636,9 +785,10 @@ public function insertCol($column_start, $column_end) * * @param int $row_start 0-based row number * @param int $row_end 0-based row number + * @param bool $update_named_ranges (optional, default=true) * @return bool */ - public function insertRow($row_start, $row_end) + public function insertRow($row_start, $row_end, $update_named_ranges = true) { } // insertRow @@ -884,20 +1034,32 @@ public function readRow($row, $column_start = 0, $column_end = -1, $read_formula * * @param int $column_start 0-based column number * @param int $column_end 0-based column number + * @param bool $update_named_ranges (optional, default=true) * @return bool */ - public function removeCol($column_start, $column_end) + public function removeCol($column_start, $column_end, $update_named_ranges = true) { } // removeCol + /** + * Removes all data validations for the sheet (only for xlsx files). + * + * @since libXL 3.8.0.0 + * @return bool + */ + public function removeDataValidations() + { + } // removeDataValidations + /** * Remove rows from row_start to row_end * * @param int $row_start 0-based row number * @param int $row_end 0-based row number + * @param bool $update_named_ranges (optional, default=true) * @return bool */ - public function removeRow($row_start, $row_end) + public function removeRow($row_start, $row_end, $update_named_ranges = true) { } // removeRow @@ -987,7 +1149,7 @@ public function setColWidth($column_start, $column_end, $width, $hidden = false, * @param int $column_end 0-based column number * @return bool */ - public function setAutofitArea($row_start=0, $row_end=-1, $column_start=0, $column_end=-1) + public function setAutofitArea($row_start = 0, $row_end = -1, $column_start = 0, $column_end = -1) { } // setAutofitArea @@ -1237,6 +1399,16 @@ public function setPrintRepeatCols($column_start, $column_end) { } // setPrintRepeatCols + /** + * Sets the color for the sheet's tab. + * + * @param int $color - one of the ExcelSheet::COLOR_* constants (optional, default=0) + * @return bool + */ + public function setTabColor($color=0) + { + } // setTabColor + /** * Gets repeated columns on each page from colFirst to colLast. Returns false * if repeated columns aren't found. @@ -1275,9 +1447,11 @@ public function printRepeatRows() * * @see ExcelSheet::protect() * @param bool $value + * @param string $password (optional, default="") + * @param int ExcelSheet::PROT_ALL (optional, default=ExcelSheet::PROT_DEFAULT) * @return void */ - public function setProtect($value) + public function setProtect($value, $password = '', $enhancedProtection = ExcelSheet::PROT_DEFAULT) { } // setProtect @@ -1384,6 +1558,25 @@ public function splitSheet($row, $column) { } // splitSheet + /** + * Gets the table parameters by index. + * + * @param int $index (optional, default = 0) + * @return array with keys "name"(string), "row_first"(int), "col_first"(int), "row_last"(int), "col_last"(int), "header_row_count"(int) and "totals_row_count"(int) + */ + public function table($index = 0) + { + } // table + + /** + * Returns the number of tables in the sheet. + * + * @return int + */ + public function tableSize() + { + } // tableSize + /** * Returns whether the sheet is centered vertically when printed * @@ -1450,6 +1643,19 @@ public function writeComment($row, $column, $comment, $author, $width, $height) { } // writeComment + /** + * Writes error into the cell with specified format. If format equals 0 then format is ignored. + * + * @param int $row (optional, default = 0) + * @param int $col (optional, default = 0) + * @param int $error - one of ExcelSheet::ERRORTYPE_* constants (optional, default = 0) + * @param ExcelFormat $format (optional, default = null) + * @return bool + */ + public function writeError($row = 0, $col = 0, $error = 0, $format = null) + { + } // writeError + /** * Write an array of values into a row * diff --git a/excel.c b/excel.c index 6d4f8be..baa4e12 100644 --- a/excel.c +++ b/excel.c @@ -28,13 +28,19 @@ #include "ext/standard/info.h" #include "ext/date/php_date.h" -#if defined(HAVE_XML) && defined(EXCEL_WITH_LIBXML) -#include "ext/xml/php_xml.h" -#endif - #include "php_excel.h" #include "zend_exceptions.h" +// support for LibXL v 3.6.0+ +#ifndef LIBXL_VERSION +#pragma message ("LibXL version 3.6.0+ required") +#endif + +// support for LibXL v 3.6.0+ +#if LIBXL_VERSION < 0x03060000 +#pragma message ("LibXL version 3.6.0+ required") +#endif + static long xlFormatBorder(FormatHandle f) { return 1; @@ -44,26 +50,6 @@ static long xlFormatBorderColor(FormatHandle f) return 1; } -/* work-around for missing headers in LibXL */ - -#ifndef LIBXL_VERSION - -#define xlSheetSetProtect xlSheetSetProtectA -#ifndef HAVE_LIBXL_243_PLUS -#define xlSheetProtect xlSheetProtectA -#endif - -#endif - -#if LIBXL_VERSION >= 0x03020000 -#define xlBookSetRefR1C1 xlBookSetRefR1C1A -#define xlBookRefR1C1 xlBookRefR1C1A -#endif - -#if LIBXL_VERSION >= 0x03020000 && LIBXL_VERSION < 0x03050401 -enum libXLPictureType {PICTURETYPE_PNG, PICTURETYPE_JPEG, PICTURETYPE_WMF, PICTURETYPE_DIB, PICTURETYPE_EMF, PICTURETYPE_PICT, PICTURETYPE_TIFF, PICTURETYPE_ERROR = 0xFF}; -#endif - #define PHP_EXCEL_DATE 1 #define PHP_EXCEL_FORMULA 2 #define PHP_EXCEL_NUMERIC_STRING 3 @@ -92,303 +78,419 @@ PHP_INI_END() zend_class_entry ce; \ INIT_CLASS_ENTRY(ce, "Excel" # name, excel_funcs_ ## c_name); \ ce.create_object = excel_object_new_ ## c_name; \ - excel_ce_ ## c_name = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); \ + excel_ce_ ## c_name = zend_register_internal_class_ex(&ce, NULL); \ memcpy(&excel_object_handlers_ ## c_name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \ - excel_object_handlers_ ## c_name.clone_obj = clone; \ + excel_object_handlers_ ## c_name .offset = XtOffsetOf(excel_ ## c_name ## _object, std); \ + excel_object_handlers_ ## c_name .free_obj = excel_ ## c_name ## _object_free_storage; \ + excel_object_handlers_ ## c_name .clone_obj = clone; \ } +#if LIBXL_VERSION < 0x03070000 zend_class_entry *excel_ce_book, *excel_ce_sheet, *excel_ce_format, *excel_ce_font; +#else +zend_class_entry *excel_ce_book, *excel_ce_sheet, *excel_ce_format, *excel_ce_font, *excel_ce_filtercolumn, *excel_ce_autofilter; +#endif static zend_object_handlers excel_object_handlers_book; static zend_object_handlers excel_object_handlers_sheet; static zend_object_handlers excel_object_handlers_format; static zend_object_handlers excel_object_handlers_font; +#if LIBXL_VERSION >= 0x03070000 +static zend_object_handlers excel_object_handlers_autofilter; +static zend_object_handlers excel_object_handlers_filtercolumn; +#endif typedef struct _excel_book_object { - zend_object std; BookHandle book; + zend_object std; } excel_book_object; +static inline excel_book_object *php_excel_book_object_fetch_object(zend_object *obj) { + return (excel_book_object *)((char *)(obj) - XtOffsetOf(excel_book_object, std)); +} + +#define Z_EXCEL_BOOK_OBJ_P(zv) php_excel_book_object_fetch_object(Z_OBJ_P(zv)); + #define BOOK_FROM_OBJECT(book, object) \ { \ - excel_book_object *obj = (excel_book_object*) zend_object_store_get_object(object TSRMLS_CC); \ + excel_book_object *obj = Z_EXCEL_BOOK_OBJ_P(object); \ book = obj->book; \ if (!book) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The book wasn't initialized"); \ + php_error_docref(NULL, E_WARNING, "The book wasn't initialized"); \ RETURN_FALSE; \ } \ } typedef struct _excel_sheet_object { - zend_object std; SheetHandle sheet; BookHandle book; + zend_object std; } excel_sheet_object; +static inline excel_sheet_object *php_excel_sheet_object_fetch_object(zend_object *obj) { + return (excel_sheet_object *)((char *)(obj) - XtOffsetOf(excel_sheet_object, std)); +} + +#define Z_EXCEL_SHEET_OBJ_P(zv) php_excel_sheet_object_fetch_object(Z_OBJ_P(zv)); + #define SHEET_FROM_OBJECT(sheet, object) \ { \ - excel_sheet_object *obj = (excel_sheet_object*) zend_object_store_get_object(object TSRMLS_CC); \ + excel_sheet_object *obj = Z_EXCEL_SHEET_OBJ_P(object); \ sheet = obj->sheet; \ if (!sheet) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The sheet wasn't initialized"); \ + php_error_docref(NULL, E_WARNING, "The sheet wasn't initialized"); \ RETURN_FALSE; \ } \ } #define SHEET_AND_BOOK_FROM_OBJECT(sheet, book, object) \ { \ - excel_sheet_object *obj = (excel_sheet_object*) zend_object_store_get_object(object TSRMLS_CC); \ + excel_sheet_object *obj = Z_EXCEL_SHEET_OBJ_P(object); \ sheet = obj->sheet; \ book = obj->book; \ if (!sheet) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The sheet wasn't initialized"); \ + php_error_docref(NULL, E_WARNING, "The sheet wasn't initialized"); \ RETURN_FALSE; \ } \ } +typedef struct _excel_font_object { + FontHandle font; + BookHandle book; + zend_object std; +} excel_font_object; + +static inline excel_font_object *php_excel_font_object_fetch_object(zend_object *obj) { + return (excel_font_object *)((char *)(obj) - XtOffsetOf(excel_font_object, std)); +} +#define Z_EXCEL_FONT_OBJ_P(zv) php_excel_font_object_fetch_object(Z_OBJ_P(zv)); + #define FONT_FROM_OBJECT(font, object) \ { \ - excel_font_object *obj = (excel_font_object*) zend_object_store_get_object(object TSRMLS_CC); \ + excel_font_object *obj = Z_EXCEL_FONT_OBJ_P(object); \ font = obj->font; \ if (!font) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The font wasn't initialized"); \ + php_error_docref(NULL, E_WARNING, "The font wasn't initialized"); \ RETURN_FALSE; \ } \ } -typedef struct _excel_font_object { - zend_object std; - FontHandle font; - BookHandle book; -} excel_font_object; - #define FORMAT_FROM_OBJECT(format, object) \ { \ - excel_format_object *obj = (excel_format_object*) zend_object_store_get_object(object TSRMLS_CC); \ + excel_format_object *obj = Z_EXCEL_FORMAT_OBJ_P(object); \ format = obj->format; \ if (!format) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The format wasn't initialized"); \ + php_error_docref(NULL, E_WARNING, "The format wasn't initialized"); \ + RETURN_FALSE; \ + } \ + } + +#if LIBXL_VERSION >= 0x03070000 +#define AUTOFILTER_FROM_OBJECT(autofilter, object) \ + { \ + excel_autofilter_object *obj = Z_EXCEL_AUTOFILTER_OBJ_P(object); \ + autofilter = obj->autofilter; \ + if (!autofilter) { \ + php_error_docref(NULL, E_WARNING, "The autofilter wasn't initialized"); \ + RETURN_FALSE; \ + } \ + } + +#define FILTERCOLUMN_FROM_OBJECT(filtercolumn, object) \ + { \ + excel_filtercolumn_object *obj = Z_EXCEL_FILTERCOLUMN_OBJ_P(object); \ + filtercolumn = obj->filtercolumn; \ + if (!filtercolumn) { \ + php_error_docref(NULL, E_WARNING, "The filtercolumn wasn't initialized"); \ RETURN_FALSE; \ } \ } +#endif typedef struct _excel_format_object { - zend_object std; FormatHandle format; BookHandle book; + zend_object std; } excel_format_object; -static void excel_book_object_free_storage(void *object TSRMLS_DC) -{ - excel_book_object *intern = (excel_book_object *)object; +static inline excel_format_object *php_excel_format_object_fetch_object(zend_object *obj) { + return (excel_format_object *)((char *)(obj) - XtOffsetOf(excel_format_object, std)); +} +#define Z_EXCEL_FORMAT_OBJ_P(zv) php_excel_format_object_fetch_object(Z_OBJ_P(zv)); + +#if LIBXL_VERSION >= 0x03070000 +typedef struct _excel_autofilter_object { + AutoFilterHandle autofilter; + SheetHandle sheet; + zend_object std; +} excel_autofilter_object; + +static inline excel_autofilter_object *php_excel_autofilter_object_fetch_object(zend_object *obj) { + return (excel_autofilter_object *)((char *)(obj) - XtOffsetOf(excel_autofilter_object, std)); +} +#define Z_EXCEL_AUTOFILTER_OBJ_P(zv) php_excel_autofilter_object_fetch_object(Z_OBJ_P(zv)); - zend_object_std_dtor(&intern->std TSRMLS_CC); +typedef struct _excel_filtercolumn_object { + FilterColumnHandle filtercolumn; + AutoFilterHandle autofilter; + zend_object std; +} excel_filtercolumn_object; + +static inline excel_filtercolumn_object *php_excel_filtercolumn_object_fetch_object(zend_object *obj) { + return (excel_filtercolumn_object *)((char *)(obj) - XtOffsetOf(excel_filtercolumn_object, std)); +} +#define Z_EXCEL_FILTERCOLUMN_OBJ_P(zv) php_excel_filtercolumn_object_fetch_object(Z_OBJ_P(zv)); +#endif + +static void excel_book_object_free_storage(zend_object *object) +{ + excel_book_object *intern = php_excel_book_object_fetch_object(object); + zend_object_std_dtor(&intern->std); if (intern->book) { xlBookRelease(intern->book); intern->book = NULL; } - - efree(object); } -static zend_object_value excel_object_new_book(zend_class_entry *class_type TSRMLS_DC) +static zend_object *excel_object_new_book(zend_class_entry *class_type) { excel_book_object *intern; - zend_object_value retval; - intern = emalloc(sizeof(excel_book_object)); - memset(intern, 0, sizeof(excel_book_object)); + intern = ecalloc(1, + sizeof(excel_book_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); - zend_object_std_init(&intern->std, class_type TSRMLS_CC); -#ifdef ZEND_ENGINE_2_4 + zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); -#else -{ - zval *tmp; - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); -} -#endif - intern->book = xlCreateBook(); - (&retval)->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) excel_book_object_free_storage, NULL TSRMLS_CC); - (&retval)->handlers = &excel_object_handlers_book; + intern->book = xlCreateBook(); + intern->std.handlers = &excel_object_handlers_book; - return retval; + return &intern->std; } -static void excel_sheet_object_free_storage(void *object TSRMLS_DC) +static void excel_sheet_object_free_storage(zend_object *object) { - excel_sheet_object *intern = (excel_sheet_object *)object; - - zend_object_std_dtor(&intern->std TSRMLS_CC); - - efree(object); + excel_sheet_object *intern = php_excel_sheet_object_fetch_object(object); + zend_object_std_dtor(&intern->std); } -static zend_object_value excel_object_new_sheet(zend_class_entry *class_type TSRMLS_DC) +static zend_object *excel_object_new_sheet(zend_class_entry *class_type) { excel_sheet_object *intern; - zend_object_value retval; - intern = emalloc(sizeof(excel_sheet_object)); - memset(intern, 0, sizeof(excel_sheet_object)); - zend_object_std_init(&intern->std, class_type TSRMLS_CC); -#ifdef ZEND_ENGINE_2_4 + intern = ecalloc(1, + sizeof(excel_sheet_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); + + zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); -#else - { - zval *tmp; - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - } -#endif - (&retval)->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) excel_sheet_object_free_storage, NULL TSRMLS_CC); - (&retval)->handlers = &excel_object_handlers_sheet; - return retval; + intern->std.handlers = &excel_object_handlers_sheet; + + return &intern->std; } -static void excel_font_object_free_storage(void *object TSRMLS_DC) +static void excel_font_object_free_storage(zend_object *object) { - excel_font_object *intern = (excel_font_object *)object; - - zend_object_std_dtor(&intern->std TSRMLS_CC); - - efree(object); + excel_font_object *intern = php_excel_font_object_fetch_object(object); + zend_object_std_dtor(&intern->std); } #define REGISTER_EXCEL_CLASS_CONST_LONG(class_name, const_name, value) \ - zend_declare_class_constant_long(excel_ce_ ## class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); + zend_declare_class_constant_long(excel_ce_ ## class_name, const_name, sizeof(const_name)-1, (long)value); + +#define REGISTER_EXCEL_CLASS_CONST_STRING(class_name, const_name, value) \ + zend_declare_class_constant_string(excel_ce_ ## class_name, const_name, sizeof(const_name)-1, (char *)value); -static zend_object_value excel_object_new_font_ex(zend_class_entry *class_type, excel_font_object **ptr TSRMLS_DC) +static zend_object *excel_object_new_font_ex(zend_class_entry *class_type, excel_font_object **ptr) { excel_font_object *intern; - zend_object_value retval; - intern = emalloc(sizeof(excel_font_object)); - memset(intern, 0, sizeof(excel_font_object)); + intern = ecalloc(1, + sizeof(excel_font_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); + if (ptr) { *ptr = intern; } - zend_object_std_init(&intern->std, class_type TSRMLS_CC); -#ifdef ZEND_ENGINE_2_4 + zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); -#else - { - zval *tmp; - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - } -#endif - (&retval)->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) excel_font_object_free_storage, NULL TSRMLS_CC); - (&retval)->handlers = &excel_object_handlers_font; - return retval; + intern->std.handlers = &excel_object_handlers_font; + + return &intern->std; } -static zend_object_value excel_object_new_font(zend_class_entry *class_type TSRMLS_DC) +static zend_object *excel_object_new_font(zend_class_entry *class_type) { - return excel_object_new_font_ex(class_type, NULL TSRMLS_CC); + return excel_object_new_font_ex(class_type, NULL); } -static zend_object_value excel_font_object_clone(zval *this_ptr TSRMLS_DC) +#if PHP_MAJOR_VERSION >= 8 +static zend_object *excel_font_object_clone(zend_object *this_object) +#else +static zend_object *excel_font_object_clone(zval *this_ptr) +#endif { - excel_font_object *new_obj = NULL; - excel_font_object *old_obj = (excel_font_object *) zend_object_store_get_object(this_ptr TSRMLS_CC); - zend_object_value new_ov = excel_object_new_font_ex(old_obj->std.ce, &new_obj TSRMLS_CC); + zend_object *new_ov; FontHandle font; + excel_font_object *new_obj = NULL; +#if PHP_MAJOR_VERSION >= 8 + excel_font_object *old_obj = php_excel_font_object_fetch_object(this_object); +#else + excel_font_object *old_obj = Z_EXCEL_FONT_OBJ_P(this_ptr); +#endif + new_ov = excel_object_new_font_ex(old_obj->std.ce, &new_obj); + font = xlBookAddFont(old_obj->book, old_obj->font); if (!font) { - zend_throw_exception(NULL, "Failed to copy font", 0 TSRMLS_CC); + zend_throw_exception(NULL, "Failed to copy font", 0); } else { new_obj->book = old_obj->book; new_obj->font = font; } - zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); + zend_objects_clone_members(&new_obj->std, &old_obj->std); return new_ov; } -static void excel_format_object_free_storage(void *object TSRMLS_DC) +static void excel_format_object_free_storage(zend_object *object) { - excel_format_object *intern = (excel_format_object *)object; - - zend_object_std_dtor(&intern->std TSRMLS_CC); - - efree(object); + excel_format_object *intern = php_excel_format_object_fetch_object(object); + zend_object_std_dtor(&intern->std); } -static zend_object_value excel_object_new_format_ex(zend_class_entry *class_type, excel_format_object **ptr TSRMLS_DC) +static zend_object *excel_object_new_format_ex(zend_class_entry *class_type, excel_format_object **ptr) { excel_format_object *intern; - zend_object_value retval; - intern = emalloc(sizeof(excel_format_object)); - memset(intern, 0, sizeof(excel_format_object)); + intern = ecalloc(1, + sizeof(excel_format_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); + if (ptr) { *ptr = intern; } - zend_object_std_init(&intern->std, class_type TSRMLS_CC); -#ifdef ZEND_ENGINE_2_4 + zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); -#else - { - zval *tmp; - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - } -#endif - (&retval)->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) excel_format_object_free_storage, NULL TSRMLS_CC); - (&retval)->handlers = &excel_object_handlers_format; - return retval; + intern->std.handlers = &excel_object_handlers_format; + + return &intern->std; } -static zend_object_value excel_object_new_format(zend_class_entry *class_type TSRMLS_DC) +static zend_object *excel_object_new_format(zend_class_entry *class_type) { - return excel_object_new_format_ex(class_type, NULL TSRMLS_CC); + return excel_object_new_format_ex(class_type, NULL); } -static zend_object_value excel_format_object_clone(zval *this_ptr TSRMLS_DC) +#if PHP_MAJOR_VERSION >= 8 +static zend_object *excel_format_object_clone(zend_object *this_object) +#else +static zend_object *excel_format_object_clone(zval *this_ptr) +#endif { - excel_format_object *new_obj = NULL; - excel_format_object *old_obj = (excel_format_object *) zend_object_store_get_object(this_ptr TSRMLS_CC); - zend_object_value new_ov = excel_object_new_format_ex(old_obj->std.ce, &new_obj TSRMLS_CC); + zend_object *new_ov; FormatHandle format; + excel_format_object *new_obj = NULL; +#if PHP_MAJOR_VERSION >= 8 + excel_format_object *old_obj = php_excel_format_object_fetch_object(this_object); +#else + excel_format_object *old_obj = Z_EXCEL_FORMAT_OBJ_P(this_ptr); +#endif + new_ov = excel_object_new_format_ex(old_obj->std.ce, &new_obj); + format = xlBookAddFormat(old_obj->book, old_obj->format); if (!format) { - zend_throw_exception(NULL, "Failed to copy format", 0 TSRMLS_CC); + zend_throw_exception(NULL, "Failed to copy format", 0); } else { new_obj->book = old_obj->book; new_obj->format = format; } - zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); + zend_objects_clone_members(&new_obj->std, &old_obj->std); return new_ov; } -#if LIBXL_VERSION <= 0x03010000 -static wchar_t * _php_excel_to_wide(const char *string, size_t len, size_t *out_len) +#if LIBXL_VERSION >= 0x03070000 +static void excel_autofilter_object_free_storage(zend_object *object) +{ + excel_autofilter_object *intern = php_excel_autofilter_object_fetch_object(object); + zend_object_std_dtor(&intern->std); +} + +static zend_object *excel_object_new_autofilter_ex(zend_class_entry *class_type, excel_autofilter_object **ptr) +{ + excel_autofilter_object *intern; + + intern = ecalloc(1, + sizeof(excel_autofilter_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); + + if (ptr) { + *ptr = intern; + } + + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + + intern->std.handlers = &excel_object_handlers_autofilter; + + return &intern->std; +} + +static zend_object *excel_object_new_autofilter(zend_class_entry *class_type) +{ + return excel_object_new_autofilter_ex(class_type, NULL); +} + +static void excel_filtercolumn_object_free_storage(zend_object *object) +{ + excel_filtercolumn_object *intern = php_excel_filtercolumn_object_fetch_object(object); + zend_object_std_dtor(&intern->std); +} + +static zend_object *excel_object_new_filtercolumn_ex(zend_class_entry *class_type, excel_filtercolumn_object **ptr) { - wchar_t *buf = safe_emalloc(len, sizeof(wchar_t), 0); + excel_filtercolumn_object *intern; + + intern = ecalloc(1, + sizeof(excel_filtercolumn_object) + + sizeof(zval) * (class_type->default_properties_count - 1)); - *out_len = mbstowcs(buf, string, len); - if (*out_len == (size_t) -1) { - efree(buf); - return NULL; + if (ptr) { + *ptr = intern; } - return erealloc(buf, (*out_len + 1) * sizeof(wchar_t)); + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + + intern->std.handlers = &excel_object_handlers_filtercolumn; + + return &intern->std; +} + +static zend_object *excel_object_new_filtercolumn(zend_class_entry *class_type) +{ + return excel_object_new_filtercolumn_ex(class_type, NULL); } #endif #define EXCEL_METHOD(class_name, function_name) \ PHP_METHOD(Excel ## class_name, function_name) +#define EXCEL_NON_EMPTY_STRING(string_zval) \ + if (!string_zval || ZSTR_LEN(string_zval) < 1) { \ + RETURN_FALSE; \ + } /* {{{ proto bool ExcelBook::requiresKey() true if license key is required. */ @@ -408,20 +510,17 @@ EXCEL_METHOD(Book, load) { BookHandle book; zval *object = getThis(); - char *data; - int data_len; + zend_string *data_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &data_zs) == FAILURE) { RETURN_FALSE; } - if (!data_len) { - RETURN_FALSE; - } + EXCEL_NON_EMPTY_STRING(data_zs) BOOK_FROM_OBJECT(book, object); - RETURN_BOOL(xlBookLoadRaw(book, data, data_len)); + RETURN_BOOL(xlBookLoadRaw(book, ZSTR_VAL(data_zs), ZSTR_LEN(data_zs))); } /* }}} */ @@ -431,36 +530,40 @@ EXCEL_METHOD(Book, loadFile) { BookHandle book; zval *object = getThis(); - char *filename; - int filename_len; + zend_string *filename_zs = NULL; php_stream *stream; - int len; - char *contents; + zend_string *contents; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &filename_zs) == FAILURE) { RETURN_FALSE; } - if (!filename_len) { - RETURN_FALSE; - } + EXCEL_NON_EMPTY_STRING(filename_zs) BOOK_FROM_OBJECT(book, object); - stream = php_stream_open_wrapper(filename, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + stream = php_stream_open_wrapper(ZSTR_VAL(filename_zs), "rb", REPORT_ERRORS, NULL); + if (!stream) { RETURN_FALSE; } - len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0); + contents = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0); php_stream_close(stream); - if (len < 1) { + if (!contents) { + php_error_docref(NULL, E_WARNING, "Source file is empty"); + RETURN_FALSE; + } + + if (ZSTR_LEN(contents) < 1) { + php_error_docref(NULL, E_WARNING, "Source file is empty"); + zend_string_release(contents); RETURN_FALSE; } - RETVAL_BOOL(xlBookLoadRaw(book, contents, len)); - efree(contents); + RETVAL_BOOL(xlBookLoadRaw(book, ZSTR_VAL(contents), ZSTR_LEN(contents))); + zend_string_release(contents); } /* }}} */ @@ -470,24 +573,23 @@ EXCEL_METHOD(Book, save) { BookHandle book; zval *object = getThis(); - char *filename = NULL; - int filename_len; + zend_string *filename_zs = NULL; unsigned int len = 0; char *contents = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &filename_zs) == FAILURE) { RETURN_FALSE; } BOOK_FROM_OBJECT(book, object); - if (!xlBookSaveRaw(book, (const char **)&contents, &len)) { + if (!xlBookSaveRaw(book, (const char **) &contents, &len)) { RETURN_FALSE; } - if (filename) { + if (filename_zs && ZSTR_LEN(filename_zs) > 0) { int numbytes; - php_stream *stream = php_stream_open_wrapper(filename, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); + php_stream *stream = php_stream_open_wrapper(ZSTR_VAL(filename_zs), "wb", REPORT_ERRORS, NULL); if (!stream) { RETURN_FALSE; @@ -495,14 +597,14 @@ EXCEL_METHOD(Book, save) if ((numbytes = php_stream_write(stream, contents, len)) != len) { php_stream_close(stream); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, len); + php_error_docref(NULL, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, len); RETURN_FALSE; } php_stream_close(stream); RETURN_TRUE; } else { - RETURN_STRINGL(contents, len, 1); + RETURN_STRINGL(contents, len); } } @@ -514,11 +616,11 @@ EXCEL_METHOD(Book, getSheet) { BookHandle book; zval *object = getThis(); - long sheet = 0; + zend_long sheet = 0; SheetHandle sh; excel_sheet_object *fo; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &sheet) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &sheet) == FAILURE) { RETURN_FALSE; } @@ -532,11 +634,8 @@ EXCEL_METHOD(Book, getSheet) RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_sheet); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_sheet_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_sheet(excel_ce_sheet)); + fo = Z_EXCEL_SHEET_OBJ_P(return_value); fo->sheet = sh; fo->book = book; } @@ -548,21 +647,18 @@ EXCEL_METHOD(Book, getSheetByName) { BookHandle book; zval *object = getThis(); - char *sheet_name; - int sheet_name_len; + zend_string *sheet_name_zs = NULL; long sheet; excel_sheet_object *fo; long sheet_count; zend_bool case_s = 0; const char *s; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &sheet_name, &sheet_name_len, &case_s) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &sheet_name_zs, &case_s) == FAILURE) { RETURN_FALSE; } - if (sheet_name_len == 0) { - RETURN_FALSE; - } + EXCEL_NON_EMPTY_STRING(sheet_name_zs) BOOK_FROM_OBJECT(book, object); @@ -572,15 +668,11 @@ EXCEL_METHOD(Book, getSheetByName) if (sh) { s = xlSheetName(sh); if (s) { - if ((case_s && !strcasecmp(s, sheet_name)) || (!case_s && !strcmp(s, sheet_name))) { - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_sheet); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_sheet_object *) zend_object_store_get_object(return_value TSRMLS_CC); + if ((case_s && !strcasecmp(s, ZSTR_VAL(sheet_name_zs))) || (!case_s && !strcmp(s, ZSTR_VAL(sheet_name_zs)))) { + ZVAL_OBJ(return_value, excel_object_new_sheet(excel_ce_sheet)); + fo = Z_EXCEL_SHEET_OBJ_P(return_value); fo->sheet = sh; fo->book = book; - return; } } @@ -597,9 +689,9 @@ EXCEL_METHOD(Book, deleteSheet) { BookHandle book; zval *object = getThis(); - long sheet; + zend_long sheet; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sheet) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &sheet) == FAILURE) { RETURN_FALSE; } @@ -619,10 +711,10 @@ EXCEL_METHOD(Book, activeSheet) { BookHandle book; zval *object = getThis(); - long sheet = -1; + zend_long sheet = -1; long res; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &sheet) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &sheet) == FAILURE) { RETURN_FALSE; } @@ -649,30 +741,23 @@ EXCEL_METHOD(Book, addSheet) zval *object = getThis(); SheetHandle sh; excel_sheet_object *fo; - char *name; - int name_len; + zend_string *name_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name_zs) == FAILURE) { RETURN_FALSE; } - BOOK_FROM_OBJECT(book, object); + EXCEL_NON_EMPTY_STRING(name_zs) -#ifdef LIBXL_VERSION - sh = xlBookAddSheet(book, name, 0); -#else - sh = xlBookAddSheet(book, name); -#endif + BOOK_FROM_OBJECT(book, object); + sh = xlBookAddSheet(book, ZSTR_VAL(name_zs), 0); if (!sh) { RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_sheet); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_sheet_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_sheet(excel_ce_sheet)); + fo = Z_EXCEL_SHEET_OBJ_P(return_value); fo->sheet = sh; fo->book = book; } @@ -686,14 +771,11 @@ EXCEL_METHOD(Book, copySheet) zval *object = getThis(); SheetHandle sh; excel_sheet_object *fo; - char *name; - int name_len; - long num; -#ifdef LIBXL_VERSION + zend_string *name_zs = NULL; + zend_long num; SheetHandle osh; -#endif - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &num) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sl", &name_zs, &num) == FAILURE) { RETURN_FALSE; } @@ -701,26 +783,21 @@ EXCEL_METHOD(Book, copySheet) RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(name_zs) + BOOK_FROM_OBJECT(book, object); -#ifdef LIBXL_VERSION if (!(osh = xlBookGetSheet(book, num))) { RETURN_FALSE; } - sh = xlBookAddSheet(book, name, osh); -#else - sh = xlBookCopySheet(book, name, num); -#endif + sh = xlBookAddSheet(book, ZSTR_VAL(name_zs), osh); if (!sh) { RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_sheet); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_sheet_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_sheet(excel_ce_sheet)); + fo = Z_EXCEL_SHEET_OBJ_P(return_value); fo->sheet = sh; fo->book = book; } @@ -762,10 +839,10 @@ EXCEL_METHOD(Book, getError) if (!strcmp(err, "ok")) { RETURN_FALSE; } else { - RETURN_STRING(err, 1); + RETURN_STRING(err); } } else { - RETURN_STRING("Unknown Error", 1); + RETURN_STRING("Unknown Error"); } } /* }}} */ @@ -781,7 +858,7 @@ EXCEL_METHOD(Book, addFont) excel_font_object *fo; zval *fob = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O", &fob, excel_ce_font) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &fob, excel_ce_font) == FAILURE) { RETURN_FALSE; } @@ -795,11 +872,8 @@ EXCEL_METHOD(Book, addFont) RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_font); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_font_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_font(excel_ce_font)); + fo = Z_EXCEL_FONT_OBJ_P(return_value); fo->font = nfont; fo->book = book; } @@ -816,7 +890,7 @@ EXCEL_METHOD(Book, addFormat) excel_format_object *fo; zval *fob = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O", &fob, excel_ce_format) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &fob, excel_ce_format) == FAILURE) { RETURN_FALSE; } @@ -830,17 +904,13 @@ EXCEL_METHOD(Book, addFormat) RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_format); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_format_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_format(excel_ce_format)); + fo = Z_EXCEL_FORMAT_OBJ_P(return_value); fo->format = nformat; fo->book = book; } /* }}} */ -#ifdef HAVE_LIBXL_243_PLUS /* {{{ proto array ExcelBook::getAllFormats() Get an array of all ExcelFormat objects used inside a document. */ EXCEL_METHOD(Book, getAllFormats) @@ -868,23 +938,18 @@ EXCEL_METHOD(Book, getAllFormats) if ((format = xlBookFormat(book, c))) { excel_format_object *fo; - zval *value; - - MAKE_STD_ZVAL(value); - Z_TYPE_P(value) = IS_OBJECT; - object_init_ex(value, excel_ce_format); - Z_SET_REFCOUNT_P(value, 1); - Z_SET_ISREF_P(value); - fo = (excel_format_object *) zend_object_store_get_object(value TSRMLS_CC); + zval value; + + ZVAL_OBJ(&value, excel_object_new_format(excel_ce_format)); + fo = Z_EXCEL_FORMAT_OBJ_P(&value); fo->format = format; fo->book = book; - add_next_index_zval(return_value, value); + add_next_index_zval(return_value, &value); } } } /* }}} */ -#endif /* {{{ proto int ExcelBook::addCustomFormat(string format) Create a custom cell format */ @@ -892,21 +957,18 @@ EXCEL_METHOD(Book, addCustomFormat) { BookHandle book; zval *object = getThis(); - char *format; - int format_len; + zend_string *format_zs = NULL; int id; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &format, &format_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &format_zs) == FAILURE) { RETURN_FALSE; } - if (!format_len) { - RETURN_FALSE; - } + EXCEL_NON_EMPTY_STRING(format_zs) BOOK_FROM_OBJECT(book, object); - if (!(id = xlBookAddCustomNumFormat(book, format))) { + if (!(id = xlBookAddCustomNumFormat(book, ZSTR_VAL(format_zs)))) { RETURN_FALSE; } RETURN_LONG(id); @@ -919,10 +981,10 @@ EXCEL_METHOD(Book, getCustomFormat) { BookHandle book; zval *object = getThis(); - long id; + zend_long id; char *data; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id) == FAILURE) { RETURN_FALSE; } @@ -935,14 +997,16 @@ EXCEL_METHOD(Book, getCustomFormat) if (!(data = (char *)xlBookCustomNumFormat(book, id))) { RETURN_FALSE; } - RETURN_STRING(data, 1); + RETURN_STRING(data); } /* }}} */ -static double _php_excel_date_pack(BookHandle book, long ts) +static double _php_excel_date_pack(BookHandle book, long longts) { + time_t ts; struct tm tm; + ts = (time_t) longts; if (!php_localtime_r(&ts, &tm)) { return -1; } @@ -950,11 +1014,7 @@ static double _php_excel_date_pack(BookHandle book, long ts) tm.tm_year += 1900; tm.tm_mon += 1; - return xlBookDatePack(book, tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec -#ifdef HAVE_LIBXL_243_PLUS - , 0 -#endif - ); + return xlBookDatePack(book, tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0); } /* {{{ proto float ExcelBook::packDate(int timestamp) @@ -963,10 +1023,10 @@ EXCEL_METHOD(Book, packDate) { BookHandle book; zval *object = getThis(); - long ts; + zend_long ts; double dt; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ts) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ts) == FAILURE) { RETURN_FALSE; } @@ -985,11 +1045,7 @@ EXCEL_METHOD(Book, packDate) static double _php_excel_date_pack_values(BookHandle book, int year, int month, int day, int hour, int min, int sec) { - return xlBookDatePack(book, year, month, day, hour, min, sec -#ifdef HAVE_LIBXL_243_PLUS - , 0 -#endif - ); + return xlBookDatePack(book, year, month, day, hour, min, sec, 0); } /* {{{ proto float ExcelBook::packDateValues(int year, int month, int day, int hour, int minute, int second) @@ -998,25 +1054,25 @@ EXCEL_METHOD(Book, packDateValues) { BookHandle book; zval *object = getThis(); - long year, month, day, hour, min, sec; + zend_long year, month, day, hour, min, sec; double dt; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llllll", &year, &month, &day, &hour, &min, &sec) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llllll", &year, &month, &day, &hour, &min, &sec) == FAILURE) { RETURN_FALSE; } - // if it is a date or just a time - hour, min & sec must be checked + // if it is a date or just a time - hout, min & sec must be checked if (hour < 0 || hour > 23) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for hour", hour); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for hour", hour); RETURN_FALSE; } if (min < 0 || min > 59) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for minute", min); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for minute", min); RETURN_FALSE; } if (sec < 0 || sec > 59) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for second", sec); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for second", sec); RETURN_FALSE; } @@ -1024,15 +1080,15 @@ EXCEL_METHOD(Book, packDateValues) // is every value=0 - it's okay for generating a time if (year != 0 || month != 0 || day != 0) { if (year < 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for year", year); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for year", year); RETURN_FALSE; } if (month < 1 || month > 12) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for month", month); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for month", month); RETURN_FALSE; } if (day < 1 || day > 31) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for day", day); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for day", day); RETURN_FALSE; } } @@ -1049,24 +1105,9 @@ EXCEL_METHOD(Book, packDateValues) static long _php_excel_date_unpack(BookHandle book, double dt) { struct tm tm = {0}; -#ifdef HAVE_LIBXL_243_PLUS -#if LIBXL_VERSION >= 0x03010000 int msec; -#else - unsigned short msec; -#endif -#endif -#if LIBXL_VERSION >= 0x03010000 - if (!xlBookDateUnpack(book, dt, (int *) &(tm.tm_year), (int *) &(tm.tm_mon), (int *) &(tm.tm_mday), (int *) &(tm.tm_hour), (int *) &(tm.tm_min), (int *) &(tm.tm_sec) -#else - if (!xlBookDateUnpack(book, dt, (short unsigned int *) &(tm.tm_year), (short unsigned int *) &(tm.tm_mon), (short unsigned int *) &(tm.tm_mday), - (short unsigned int *) &(tm.tm_hour), (short unsigned int *) &(tm.tm_min), (short unsigned int *) &(tm.tm_sec) -#endif -#ifdef HAVE_LIBXL_243_PLUS - , &msec -#endif - )) { + if (!xlBookDateUnpack(book, dt, (int *) &(tm.tm_year), (int *) &(tm.tm_mon), (int *) &(tm.tm_mday), (int *) &(tm.tm_hour), (int *) &(tm.tm_min), (int *) &(tm.tm_sec), &msec)) { return -1; } @@ -1086,7 +1127,7 @@ EXCEL_METHOD(Book, unpackDate) double dt; time_t t; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &dt) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &dt) == FAILURE) { RETURN_FALSE; } @@ -1103,7 +1144,6 @@ EXCEL_METHOD(Book, unpackDate) } /* }}} */ -#if LIBXL_VERSION >= 0x03050300 /* {{{ proto bool ExcelBook::isDate1904() Returns whether the 1904 date system is active: true - 1904 date system, false - 1900 date system */ EXCEL_METHOD(Book, isDate1904) @@ -1129,7 +1169,7 @@ EXCEL_METHOD(Book, setDate1904) zval *object = getThis(); zend_bool date_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &date_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &date_type) == FAILURE) { RETURN_FALSE; } @@ -1140,7 +1180,6 @@ EXCEL_METHOD(Book, setDate1904) RETURN_TRUE; } /* }}} */ -#endif /* {{{ proto int ExcelBook::getActiveSheet() Get the active sheet inside a file. */ @@ -1166,11 +1205,7 @@ EXCEL_METHOD(Book, getDefaultFont) BookHandle book; zval *object = getThis(); const char *font; -#if LIBXL_VERSION >= 0x03010000 int font_size; -#else - unsigned short font_size; -#endif if (ZEND_NUM_ARGS()) { RETURN_FALSE; @@ -1183,7 +1218,7 @@ EXCEL_METHOD(Book, getDefaultFont) } array_init(return_value); - add_assoc_string(return_value, "font", (char *)font, 1); + add_assoc_string(return_value, "font", (char *)font); add_assoc_long(return_value, "font_size", font_size); } /* }}} */ @@ -1194,17 +1229,18 @@ EXCEL_METHOD(Book, setDefaultFont) { BookHandle book; zval *object = getThis(); - char *font; - int font_len; - long font_size; + zend_long font_size; + zend_string *font_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &font, &font_len, &font_size) == FAILURE || font_size < 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sl", &font_zs, &font_size) == FAILURE || font_size < 1) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(font_zs) + BOOK_FROM_OBJECT(book, object); - xlBookSetDefaultFont(book, font, (int)font_size); + xlBookSetDefaultFont(book, ZSTR_VAL(font_zs), (int)font_size); } /* }}} */ @@ -1214,16 +1250,17 @@ EXCEL_METHOD(Book, setLocale) { BookHandle book; zval *object = getThis(); - char *locale; - int locale_len; + zend_string *locale_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &locale, &locale_len) == FAILURE || locale_len < 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &locale_zs) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(locale_zs) + BOOK_FROM_OBJECT(book, object); - xlBookSetLocale(book, locale); + xlBookSetLocale(book, ZSTR_VAL(locale_zs)); } /* }}} */ @@ -1233,87 +1270,41 @@ EXCEL_METHOD(Book, __construct) { BookHandle book; zval *object = getThis(); - char *name = NULL, *key; - int name_len = 0, key_len = 0; -#if LIBXL_VERSION <= 0x03010000 - wchar_t *nw, *kw; - size_t nw_l, kw_l; -#endif -#if defined(HAVE_XML) && defined(EXCEL_WITH_LIBXML) - char *namep, *keyp; - int plen; -#endif - -#ifdef LIBXL_VERSION + char *name = NULL, *key = NULL; + size_t name_len = 0, key_len = 0; zend_bool new_excel = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssb", &name, &name_len, &key, &key_len, &new_excel) == FAILURE) { - RETURN_FALSE; - } -#else - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &name, &name_len, &key, &key_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ssb", &name, &name_len, &key, &key_len, &new_excel) == FAILURE) { RETURN_FALSE; } -#endif -#if defined(HAVE_LIBXL_SETKEY) - if (!name_len) { - if (INI_STR("excel.license_name") && INI_STR("excel.license_key")) { - name = INI_STR("excel.license_name"); - name_len = strlen(name); - key = INI_STR("excel.license_key"); - key_len = strlen(key); - } else { -#ifndef LIBXL_VERSION - return; -#endif - } - } -#endif BOOK_FROM_OBJECT(book, object); -#ifdef LIBXL_VERSION + if (new_excel) { - excel_book_object *obj = (excel_book_object*) zend_object_store_get_object(object TSRMLS_CC); + excel_book_object *obj = (excel_book_object*) Z_EXCEL_BOOK_OBJ_P(object); if ((book = xlCreateXMLBook())) { xlBookRelease(obj->book); obj->book = book; } else { RETURN_FALSE; } -#if !defined(HAVE_LIBXL_SETKEY) - return; -#endif - if (!name_len && !key_len) { - return; - } - } -#endif - if (!name_len || !key_len) { - RETURN_FALSE; } -#if LIBXL_VERSION <= 0x03010000 - if (!(nw = _php_excel_to_wide(name, name_len + 1, &nw_l))) { - RETURN_FALSE; + +#if defined(HAVE_LIBXL_SETKEY) + + if (name_len == 0 && INI_STR("excel.license_name") && INI_STR("excel.license_key")) { + name = INI_STR("excel.license_name"); + name_len = strlen(name); + key = INI_STR("excel.license_key"); + key_len = strlen(key); } - if (!(kw = _php_excel_to_wide(key, key_len + 1, &kw_l))) { - efree(nw); + + if (!name || name_len < 1 || !key || key_len < 1) { RETURN_FALSE; } - xlBookSetKey(book, nw, kw); - efree(nw); - efree(kw); -#else - -#if defined(HAVE_XML) && defined(EXCEL_WITH_LIBXML) - namep = xml_utf8_decode((const XML_Char *) name, name_len, &plen, (const XML_Char *)"ISO-8859-1"); - keyp = xml_utf8_decode((const XML_Char *) key, key_len, &plen, (const XML_Char *)"ISO-8859-1"); - xlBookSetKey(book, namep, keyp); - efree(namep); - efree(keyp); -#else xlBookSetKey(book, name, key); -#endif + #endif } /* }}} */ @@ -1324,9 +1315,9 @@ EXCEL_METHOD(Book, setActiveSheet) { BookHandle book; zval *object = getThis(); - long id; + zend_long id; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE || id < 0) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id) == FAILURE || id < 0) { RETURN_FALSE; } @@ -1339,46 +1330,44 @@ EXCEL_METHOD(Book, setActiveSheet) static void php_excel_add_picture(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ { - char *data; - int data_len; + zend_string *data_zs = NULL; BookHandle book; zval *object = getThis(); int ret; + php_stream *stream; + zend_string *contents; - BOOK_FROM_OBJECT(book, object); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &data_zs) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(data_zs) + + BOOK_FROM_OBJECT(book, object); + if (mode == 1) { - ret = xlBookAddPicture2(book, data, data_len); + ret = xlBookAddPicture2(book, ZSTR_VAL(data_zs), ZSTR_LEN(data_zs)); } else { - php_stream *stream = php_stream_open_wrapper(data, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); - int len; - char *contents; + stream = php_stream_open_wrapper(ZSTR_VAL(data_zs), "rb", REPORT_ERRORS, NULL); if (!stream) { RETURN_FALSE; } - len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0); + contents = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0); php_stream_close(stream); - if (len < 1) { + if (!contents || ZSTR_LEN(contents) < 1) { + zend_string_release(contents); RETURN_FALSE; } - ret = xlBookAddPicture2(book, contents, len); - efree(contents); + ret = xlBookAddPicture2(book, ZSTR_VAL(contents), ZSTR_LEN(contents)); + zend_string_release(contents); } if (ret == -1) { RETURN_FALSE; } else { -#if LIBXL_VERSION >= 0x03020200 && LIBXL_VERSION < 0x03020300 - /* work-around for a bug inside libxl 3.2.2 */ - ret -= 1; -#endif RETURN_LONG(ret); } } @@ -1399,7 +1388,6 @@ EXCEL_METHOD(Book, addPictureFromString) } /* }}} */ -#ifdef LIBXL_VERSION /* {{{ proto bool ExcelBook::rgbMode() Returns whether the RGB mode is active. */ EXCEL_METHOD(Book, rgbMode) @@ -1425,7 +1413,7 @@ EXCEL_METHOD(Book, setRGBMode) zval *object = getThis(); zend_bool val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &val) == FAILURE) { RETURN_FALSE; } @@ -1441,20 +1429,20 @@ EXCEL_METHOD(Book, colorPack) { BookHandle book; zval *object = getThis(); - long r, g, b; + zend_long r, g, b; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &r, &g, &b) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b) == FAILURE) { RETURN_FALSE; } if (r < 0 || r > 255) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for color red", r); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for color red", r); RETURN_FALSE; } else if (g < 0 || g > 255) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for color green", g); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for color green", g); RETURN_FALSE; } else if (b < 0 || b > 255) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for color blue", b); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for color blue", b); RETURN_FALSE; } @@ -1470,19 +1458,15 @@ EXCEL_METHOD(Book, colorUnpack) { BookHandle book; zval *object = getThis(); -#if LIBXL_VERSION >= 0x03010000 int r, g, b; -#else - unsigned short r, g, b; -#endif - long color; + zend_long color; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &color) == FAILURE) { RETURN_FALSE; } if (color <= 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid '%ld' value for color code", color); + php_error_docref(NULL, E_WARNING, "Invalid '%ld' value for color code", color); RETURN_FALSE; } @@ -1496,17 +1480,85 @@ EXCEL_METHOD(Book, colorUnpack) add_assoc_long(return_value, "blue", b); } /* }}} */ + +/* {{{ proto string ExcelBook::getLibXlVersion() + Returns the version of libXL library */ +EXCEL_METHOD(Book, getLibXlVersion) +{ + char libxl_api[25]; + snprintf(libxl_api, sizeof(libxl_api), "%x", LIBXL_VERSION); + RETURN_STRING(libxl_api); +} +/* }}} */ + +/* {{{ proto string ExcelBook::getPhpExcelVersion() + Returns the version of PHP Excel extension */ +EXCEL_METHOD(Book, getPhpExcelVersion) +{ + RETURN_STRING(PHP_EXCEL_VERSION); +} +/* }}} */ + +#if LIBXL_VERSION >= 0x03080300 +/* {{{ proto bool ExcelBook::loadInfo(string filename) + Loads only information about sheets. Afterwards you can call Book::sheetCount() + and Book::getSheetName() methods. Returns false if error occurs. Get error + info with Book::errorMessage(). */ +EXCEL_METHOD(Book, loadInfo) +{ + BookHandle book; + zval *object = getThis(); + zend_string *filename_zs = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &filename_zs) == FAILURE) { + RETURN_FALSE; + } + + EXCEL_NON_EMPTY_STRING(filename_zs) + + BOOK_FROM_OBJECT(book, object); + + RETURN_BOOL(xlBookLoadInfo(book, ZSTR_VAL(filename_zs))); +} +/* }}} */ + +/* {{{ proto string ExcelBook::getSheetName(int index) + Returns a sheet name with specified index. Returns + NULL if error occurs. Get error info with xlBookErrorMessage(). */ +EXCEL_METHOD(Book, getSheetName) +{ + BookHandle book; + zval *object = getThis(); + zend_long index; + char *data; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { + RETURN_FALSE; + } + + if (index < 1) { + RETURN_FALSE; + } + + BOOK_FROM_OBJECT(book, object); + + if (!(data = (char *)xlBookGetSheetName(book, index))) { + RETURN_FALSE; + } + RETURN_STRING(data); +} +/* }}} */ #endif /* {{{ proto int ExcelFont::size([int size]) - Get or set the font size */ + Get or set the font size */ EXCEL_METHOD(Font, size) { zval *object = getThis(); FontHandle font; - long size = -1; + zend_long size = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &size) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &size) == FAILURE) { RETURN_FALSE; } @@ -1521,14 +1573,14 @@ EXCEL_METHOD(Font, size) /* }}} */ /* {{{ proto bool ExcelFont::italics([bool italics]) - Get or set the if italics are enabled */ + Get or set the if italics are enabled */ EXCEL_METHOD(Font, italics) { zval *object = getThis(); FontHandle font; zend_bool italics; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &italics) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &italics) == FAILURE) { RETURN_FALSE; } @@ -1543,14 +1595,14 @@ EXCEL_METHOD(Font, italics) /* }}} */ /* {{{ proto bool ExcelFont::strike([bool strike]) - Get or set the font strike-through */ + Get or set the font strike-through */ EXCEL_METHOD(Font, strike) { zval *object = getThis(); FontHandle font; zend_bool strike; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &strike) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &strike) == FAILURE) { RETURN_FALSE; } @@ -1565,14 +1617,14 @@ EXCEL_METHOD(Font, strike) /* }}} */ /* {{{ proto bool ExcelFont::bold([bool bold]) - Get or set the font bold */ + Get or set the font bold */ EXCEL_METHOD(Font, bold) { zval *object = getThis(); FontHandle font; zend_bool bold; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &bold) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &bold) == FAILURE) { RETURN_FALSE; } @@ -1587,14 +1639,14 @@ EXCEL_METHOD(Font, bold) /* }}} */ /* {{{ proto int ExcelFont::color([int color]) - Get or set the font color */ + Get or set the font color */ EXCEL_METHOD(Font, color) { zval *object = getThis(); FontHandle font; - long color; + zend_long color; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &color) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &color) == FAILURE) { RETURN_FALSE; } @@ -1609,14 +1661,14 @@ EXCEL_METHOD(Font, color) /* }}} */ /* {{{ proto int ExcelFont::mode([int mode]) - Get or set the font mode */ + Get or set the font mode */ EXCEL_METHOD(Font, mode) { zval *object = getThis(); FontHandle font; - long mode; + zend_long mode; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &mode) == FAILURE) { RETURN_FALSE; } @@ -1631,14 +1683,14 @@ EXCEL_METHOD(Font, mode) /* }}} */ /* {{{ proto int ExcelFont::underline([int underline_style]) - Get or set the font underline style */ + Get or set the font underline style */ EXCEL_METHOD(Font, underline) { zval *object = getThis(); FontHandle font; - long underline; + zend_long underline; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &underline) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &underline) == FAILURE) { RETURN_FALSE; } @@ -1653,25 +1705,24 @@ EXCEL_METHOD(Font, underline) /* }}} */ /* {{{ proto string ExcelFont::name([string name]) - Get or set the font name */ + Get or set the font name */ EXCEL_METHOD(Font, name) { zval *object = getThis(); FontHandle font; - char *name = NULL; - int name_len; + zend_string *name_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name_zs) == FAILURE) { RETURN_FALSE; } FONT_FROM_OBJECT(font, object); - if (name) { - xlFontSetName(font, name); + if (name_zs) { + xlFontSetName(font, ZSTR_VAL(name_zs)); } - RETURN_STRING((char *)xlFontName(font), 1); + RETURN_STRING((char *)xlFontName(font)); } /* }}} */ @@ -1686,7 +1737,7 @@ EXCEL_METHOD(Format, __construct) zval *zbook; PHP_EXCEL_ERROR_HANDLING(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zbook, excel_ce_book) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zbook, excel_ce_book) == FAILURE) { PHP_EXCEL_RESTORE_ERRORS(); return; } @@ -1694,7 +1745,7 @@ EXCEL_METHOD(Format, __construct) BOOK_FROM_OBJECT(book, zbook); - obj = (excel_format_object*) zend_object_store_get_object(object TSRMLS_CC); + obj = Z_EXCEL_FORMAT_OBJ_P(object); format = xlBookAddFormat(book, NULL); if (!format) { @@ -1717,7 +1768,7 @@ EXCEL_METHOD(Font, __construct) zval *zbook; PHP_EXCEL_ERROR_HANDLING(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zbook, excel_ce_book) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zbook, excel_ce_book) == FAILURE) { PHP_EXCEL_RESTORE_ERRORS(); return; } @@ -1725,7 +1776,7 @@ EXCEL_METHOD(Font, __construct) BOOK_FROM_OBJECT(book, zbook); - obj = (excel_font_object*) zend_object_store_get_object(object TSRMLS_CC); + obj = Z_EXCEL_FONT_OBJ_P(object); font = xlBookAddFont(book, NULL); if (!font) { @@ -1746,7 +1797,7 @@ EXCEL_METHOD(Format, setFont) FontHandle font; zval *zfont; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zfont, excel_ce_font) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zfont, excel_ce_font) == FAILURE) { RETURN_FALSE; } @@ -1768,11 +1819,11 @@ EXCEL_METHOD(Format, getFont) zval *object = getThis(); FontHandle font; excel_font_object *fo; - excel_format_object *obj = (excel_format_object*) zend_object_store_get_object(object TSRMLS_CC); + excel_format_object *obj = Z_EXCEL_FORMAT_OBJ_P(object); format = obj->format; if (!format) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The format wasn't initialized"); + php_error_docref(NULL, E_WARNING, "The format wasn't initialized"); RETURN_FALSE; } @@ -1787,52 +1838,49 @@ EXCEL_METHOD(Format, getFont) RETURN_FALSE; } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_font); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_font_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_font(excel_ce_font)); + fo = Z_EXCEL_FONT_OBJ_P(return_value); fo->font = font; fo->book = obj->book; } /* }}} */ -#define PHP_EXCEL_LONG_FORMAT_OPTION(func_name, write_only) \ - { \ - FormatHandle format; \ - zval *object = getThis(); \ - long data; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &data) == FAILURE) { \ - RETURN_FALSE; \ - } \ - FORMAT_FROM_OBJECT(format, object); \ - if (ZEND_NUM_ARGS()) { \ - xlFormatSet ## func_name (format, data); \ - } \ - if (!write_only) { \ - RETURN_LONG(xlFormat ## func_name (format)); \ - } else { \ - RETURN_TRUE; \ - } \ - } - -#define PHP_EXCEL_BOOL_FORMAT_OPTION(func_name) \ - { \ - FormatHandle format; \ - zval *object = getThis(); \ - zend_bool data; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &data) == FAILURE) { \ - RETURN_FALSE; \ - } \ - FORMAT_FROM_OBJECT(format, object); \ - if (ZEND_NUM_ARGS()) { \ - xlFormatSet ## func_name (format, data); \ - } \ - RETURN_BOOL(xlFormat ## func_name (format)); \ +#define PHP_EXCEL_LONG_FORMAT_OPTION(func_name, write_only) \ + { \ + FormatHandle format; \ + zval *object = getThis(); \ + zend_long data; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &data) == FAILURE) { \ + RETURN_FALSE; \ + } \ + FORMAT_FROM_OBJECT(format, object); \ + if (ZEND_NUM_ARGS()) { \ + xlFormatSet ## func_name (format, data); \ + } \ + if (!write_only) { \ + RETURN_LONG(xlFormat ## func_name (format)); \ + } else { \ + RETURN_TRUE; \ + } \ + } + +#define PHP_EXCEL_BOOL_FORMAT_OPTION(func_name) \ + { \ + FormatHandle format; \ + zval *object = getThis(); \ + zend_bool data; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &data) == FAILURE) { \ + RETURN_FALSE; \ + } \ + FORMAT_FROM_OBJECT(format, object); \ + if (ZEND_NUM_ARGS()) { \ + xlFormatSet ## func_name (format, data); \ + } \ + RETURN_BOOL(xlFormat ## func_name (format)); \ } /* {{{ proto int ExcelFormat::numberFormat([int format]) - Get or set the cell number format */ + Get or set the cell number format */ EXCEL_METHOD(Format, numberFormat) { PHP_EXCEL_LONG_FORMAT_OPTION(NumFormat, 0); @@ -1840,7 +1888,7 @@ EXCEL_METHOD(Format, numberFormat) /* }}} */ /* {{{ proto int ExcelFormat::horizontalAlign([int align_mode]) - Get or set the cell horizontal alignment */ + Get or set the cell horizontal alignment */ EXCEL_METHOD(Format, horizontalAlign) { PHP_EXCEL_LONG_FORMAT_OPTION(AlignH, 0); @@ -1848,7 +1896,7 @@ EXCEL_METHOD(Format, horizontalAlign) /* }}} */ /* {{{ proto int ExcelFormat::verticalAlign([int align_mode]) - Get or set the cell vertical alignment */ + Get or set the cell vertical alignment */ EXCEL_METHOD(Format, verticalAlign) { PHP_EXCEL_LONG_FORMAT_OPTION(AlignV, 0); @@ -1856,7 +1904,7 @@ EXCEL_METHOD(Format, verticalAlign) /* }}} */ /* {{{ proto bool ExcelFormat::wrap([bool wrap]) - Get or set the cell wrapping */ + Get or set the cell wrapping */ EXCEL_METHOD(Format, wrap) { PHP_EXCEL_BOOL_FORMAT_OPTION(Wrap); @@ -1864,14 +1912,14 @@ EXCEL_METHOD(Format, wrap) /* }}} */ /* {{{ proto int ExcelFormat::rotate([int angle]) - Get or set the cell data rotation */ + Get or set the cell data rotation */ EXCEL_METHOD(Format, rotate) { FormatHandle format; zval *object = getThis(); - long angle; + zend_long angle; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &angle) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &angle) == FAILURE) { RETURN_FALSE; } @@ -1879,7 +1927,7 @@ EXCEL_METHOD(Format, rotate) if (ZEND_NUM_ARGS()) { if (angle < 0 || (angle > 180 && angle != 255)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Rotation can be a number between 0 and 180 or 255"); + php_error_docref(NULL, E_WARNING, "Rotation can be a number between 0 and 180 or 255"); RETURN_FALSE; } xlFormatSetRotation(format, angle); @@ -1890,14 +1938,14 @@ EXCEL_METHOD(Format, rotate) /* }}} */ /* {{{ proto int ExcelFormat::indent([int indent]) - Get or set the cell text indentation level */ + Get or set the cell text indentation level */ EXCEL_METHOD(Format, indent) { FormatHandle format; zval *object = getThis(); - long indent; + zend_long indent; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &indent) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &indent) == FAILURE) { RETURN_FALSE; } @@ -1905,7 +1953,7 @@ EXCEL_METHOD(Format, indent) if (ZEND_NUM_ARGS()) { if (indent < 0 || indent > 15) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Text indentation level must be less than or equal to 15"); + php_error_docref(NULL, E_WARNING, "Text indentation level must be less than or equal to 15"); RETURN_FALSE; } xlFormatSetIndent(format, indent); @@ -2067,26 +2115,26 @@ EXCEL_METHOD(Sheet, __construct) SheetHandle sh; zval *object = getThis(); excel_sheet_object *obj; - zval *zbook; - char *name; - int name_len; + zval *zbook = NULL; + zend_string *name_zs = NULL; PHP_EXCEL_ERROR_HANDLING(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &zbook, excel_ce_book, &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &zbook, excel_ce_book, &name_zs) == FAILURE) { PHP_EXCEL_RESTORE_ERRORS(); return; } PHP_EXCEL_RESTORE_ERRORS(); + if (!zbook) { + RETURN_FALSE; + } + EXCEL_NON_EMPTY_STRING(name_zs) + BOOK_FROM_OBJECT(book, zbook); - obj = (excel_sheet_object*) zend_object_store_get_object(object TSRMLS_CC); + obj = Z_EXCEL_SHEET_OBJ_P(object); -#ifdef LIBXL_VERSION - sh = xlBookAddSheet(book, name, 0); -#else - sh = xlBookAddSheet(book, name); -#endif + sh = xlBookAddSheet(book, ZSTR_VAL(name_zs), 0); if (!sh) { RETURN_FALSE; @@ -2103,9 +2151,9 @@ EXCEL_METHOD(Sheet, cellType) { zval *object = getThis(); SheetHandle sheet; - long row, col; + zend_long row, col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &row, &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { RETURN_FALSE; } @@ -2122,10 +2170,10 @@ EXCEL_METHOD(Sheet, cellFormat) zval *object = getThis(); SheetHandle sheet; FormatHandle format; - long row, col; + zend_long row, col; excel_format_object *fo; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &row, &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { RETURN_FALSE; } @@ -2133,16 +2181,12 @@ EXCEL_METHOD(Sheet, cellFormat) format = xlSheetCellFormat(sheet, row, col); - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_format); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_format_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_format(excel_ce_format)); + fo = Z_EXCEL_FORMAT_OBJ_P(return_value); fo->format = format; } /* }}} */ -#ifdef HAVE_LIBXL_243_PLUS /* {{{ proto void ExcelFormat ExcelSheet::setCellFormat(int row, int column, ExcelFormat format) Set cell format */ EXCEL_METHOD(Sheet, setCellFormat) @@ -2151,9 +2195,9 @@ EXCEL_METHOD(Sheet, setCellFormat) SheetHandle sheet; FormatHandle format; zval *oformat; - long row, col; + zend_long row, col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llo", &row, &col, &oformat, excel_ce_format) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llo", &row, &col, &oformat, excel_ce_format) == FAILURE) { RETURN_FALSE; } @@ -2163,15 +2207,14 @@ EXCEL_METHOD(Sheet, setCellFormat) xlSheetSetCellFormat(sheet, row, col, format); } /* }}} */ -#endif -static zend_bool php_excel_read_cell(int row, int col, zval *val, SheetHandle sheet, BookHandle book, FormatHandle *format, zend_bool read_formula) +zend_bool php_excel_read_cell(int row, int col, zval *val, SheetHandle sheet, BookHandle book, FormatHandle *format, zend_bool read_formula) { const char *s; if (read_formula && xlSheetIsFormula(sheet, row, col)) { s = xlSheetReadFormula(sheet, row, col, format); if (s) { - ZVAL_STRING(val, (char *)s, 1); + ZVAL_STRING(val, (char *)s); return 1; } else { return 0; @@ -2194,11 +2237,7 @@ static zend_bool php_excel_read_cell(int row, int col, zval *val, SheetHandle sh case CELLTYPE_NUMBER: { double d = xlSheetReadNum(sheet, row, col, format); -#if LIBXL_VERSION <= 0x03010000 - if (xlSheetIsDate(sheet, row, col) && xlFormatNumFormat(*format) < 100) { -#else if (xlSheetIsDate(sheet, row, col)) { -#endif long dt = _php_excel_date_unpack(book, d); if (dt == -1) { return 0; @@ -2215,7 +2254,7 @@ static zend_bool php_excel_read_cell(int row, int col, zval *val, SheetHandle sh case CELLTYPE_STRING: { s = xlSheetReadStr(sheet, row, col, format); if (s) { - ZVAL_STRING(val, (char *)s, 1); + ZVAL_STRING(val, (char *)s); return 1; } else { return 0; @@ -2239,28 +2278,28 @@ static zend_bool php_excel_read_cell(int row, int col, zval *val, SheetHandle sh EXCEL_METHOD(Sheet, readRow) { zval *object = getThis(); - long row; - long col_start = 0; - long col_end = -1; + zend_long row; + zend_long col_start = 0; + zend_long col_end = -1; int lc; SheetHandle sheet; BookHandle book; zend_bool read_formula = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|llb", &row, &col_start, &col_end, &read_formula) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|llb", &row, &col_start, &col_end, &read_formula) == FAILURE) { RETURN_FALSE; } SHEET_AND_BOOK_FROM_OBJECT(sheet, book, object); if (row < 0 || row > xlSheetLastRow(sheet)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid row number '%ld'", row); + php_error_docref(NULL, E_WARNING, "Invalid row number '%ld'", row); RETURN_FALSE; } lc = xlSheetLastCol(sheet); if (col_start < 0 || col_start > lc) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid starting column number '%ld'", col_start); + php_error_docref(NULL, E_WARNING, "Invalid starting column number '%ld'", col_start); RETURN_FALSE; } @@ -2269,7 +2308,7 @@ EXCEL_METHOD(Sheet, readRow) } if (col_end < col_start || col_end > lc) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid ending column number '%ld'", col_end); + php_error_docref(NULL, E_WARNING, "Invalid ending column number '%ld'", col_end); RETURN_FALSE; } @@ -2277,17 +2316,16 @@ EXCEL_METHOD(Sheet, readRow) array_init(return_value); while (lc < (col_end + 1)) { - zval *value; + zval value; FormatHandle format = NULL; - MAKE_STD_ZVAL(value); - if (!php_excel_read_cell(row, lc, value, sheet, book, &format, read_formula)) { + if (!php_excel_read_cell(row, lc, &value, sheet, book, &format, read_formula)) { zval_ptr_dtor(&value); zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read cell in row %ld, column %d with error '%s'", row, lc, xlBookErrorMessage(book)); + php_error_docref(NULL, E_WARNING, "Failed to read cell in row %d, column %d with error '%s'", row, lc, xlBookErrorMessage(book)); RETURN_FALSE; } else { - add_next_index_zval(return_value, value); + add_next_index_zval(return_value, &value); } lc++; @@ -2300,28 +2338,28 @@ EXCEL_METHOD(Sheet, readRow) EXCEL_METHOD(Sheet, readCol) { zval *object = getThis(); - long col; - long row_start = 0; - long row_end = -1; + zend_long col; + zend_long row_start = 0; + zend_long row_end = -1; int lc; SheetHandle sheet; BookHandle book; zend_bool read_formula = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|llb", &col, &row_start, &row_end, &read_formula) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|llb", &col, &row_start, &row_end, &read_formula) == FAILURE) { RETURN_FALSE; } SHEET_AND_BOOK_FROM_OBJECT(sheet, book, object); if (col < 0 || col > xlSheetLastCol(sheet)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column number '%ld'", col); + php_error_docref(NULL, E_WARNING, "Invalid column number '%ld'", col); RETURN_FALSE; } lc = xlSheetLastRow(sheet); if (row_start < 0 || row_start > lc) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid starting row number '%ld'", row_start); + php_error_docref(NULL, E_WARNING, "Invalid starting row number '%ld'", row_start); RETURN_FALSE; } @@ -2330,7 +2368,7 @@ EXCEL_METHOD(Sheet, readCol) } if (row_end < row_start || row_end > lc) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid ending row number '%ld'", row_end); + php_error_docref(NULL, E_WARNING, "Invalid ending row number '%ld'", row_end); RETURN_FALSE; } @@ -2338,17 +2376,16 @@ EXCEL_METHOD(Sheet, readCol) array_init(return_value); while (lc < (row_end + 1)) { - zval *value; + zval value; FormatHandle format = NULL; - MAKE_STD_ZVAL(value); - if (!php_excel_read_cell(lc, col, value, sheet, book, &format, read_formula)) { + if (!php_excel_read_cell(lc, col, &value, sheet, book, &format, read_formula)) { zval_ptr_dtor(&value); zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read cell in row %d, column %ld with error '%s'", lc, col, xlBookErrorMessage(book)); + php_error_docref(NULL, E_WARNING, "Failed to read cell in row %d, column %d with error '%s'", lc, col, xlBookErrorMessage(book)); RETURN_FALSE; } else { - add_next_index_zval(return_value, value); + add_next_index_zval(return_value, &value); } lc++; @@ -2363,12 +2400,12 @@ EXCEL_METHOD(Sheet, read) zval *object = getThis(); SheetHandle sheet; BookHandle book; - long row, col; + zend_long row, col; zval *oformat = NULL; FormatHandle format = NULL; zend_bool read_formula = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|z/b", &row, &col, &oformat, &read_formula) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|z/b", &row, &col, &oformat, &read_formula) == FAILURE) { RETURN_FALSE; } @@ -2380,30 +2417,32 @@ EXCEL_METHOD(Sheet, read) } if (!php_excel_read_cell(row, col, return_value, sheet, book, &format, read_formula)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read cell in row %ld, column %ld with error '%s'", row, col, xlBookErrorMessage(book)); + php_error_docref(NULL, E_WARNING, "Failed to read cell in row %d, column %d with error '%s'", row, col, xlBookErrorMessage(book)); RETURN_FALSE; } if (oformat) { excel_format_object *fo; - Z_TYPE_P(oformat) = IS_OBJECT; - object_init_ex(oformat, excel_ce_format); - fo = (excel_format_object *) zend_object_store_get_object(oformat TSRMLS_CC); + ZVAL_OBJ(oformat, excel_object_new_format(excel_ce_format)); + fo = Z_EXCEL_FORMAT_OBJ_P(oformat); fo->format = format; } } /* }}} */ -static zend_bool php_excel_write_cell(SheetHandle sheet, BookHandle book, int row, int col, zval *data, FormatHandle format, long dtype TSRMLS_DC) +zend_bool php_excel_write_cell(SheetHandle sheet, BookHandle book, int row, int col, zval *data, FormatHandle format, long dtype) { + zend_string *data_zs; + + try_again: switch (Z_TYPE_P(data)) { case IS_NULL: if (INI_INT("excel.skip_empty") > 0) { return 1; } if (!format) { - return xlSheetWriteBlank(sheet, row, col, 0); + return xlSheetWriteBlank(sheet, row, col, NULL); } else { return xlSheetWriteBlank(sheet, row, col, format); } @@ -2429,8 +2468,9 @@ static zend_bool php_excel_write_cell(SheetHandle sheet, BookHandle book, int ro return xlSheetWriteNum(sheet, row, col, Z_DVAL_P(data), format); case IS_STRING: + data_zs = Z_STR_P(data); if (Z_STRLEN_P(data) > 0 && '\'' == Z_STRVAL_P(data)[0]) { - return xlSheetWriteStr(sheet, row, col, Z_STRVAL_P(data) + 1, format); + return xlSheetWriteStr(sheet, row, col, (const char*) ZSTR_VAL(data_zs) + 1, format); } if (Z_STRLEN_P(data) > 0 && '=' == Z_STRVAL_P(data)[0]) { dtype = PHP_EXCEL_FORMULA; @@ -2439,7 +2479,7 @@ static zend_bool php_excel_write_cell(SheetHandle sheet, BookHandle book, int ro return xlSheetWriteFormula(sheet, row, col, Z_STRVAL_P(data), format); } else { if (dtype == PHP_EXCEL_NUMERIC_STRING) { - long lval; + zend_long lval; double dval; switch (is_numeric_string(Z_STRVAL_P(data), Z_STRLEN_P(data), &lval, &dval, 0)) { @@ -2453,11 +2493,22 @@ static zend_bool php_excel_write_cell(SheetHandle sheet, BookHandle book, int ro if (Z_STRLEN_P(data) == 0 && INI_INT("excel.skip_empty") == 2) { return 1; } - return xlSheetWriteStr(sheet, row, col, Z_STRVAL_P(data), format); + return xlSheetWriteStr(sheet, row, col, (const char*) ZSTR_VAL(data_zs), format); } - case IS_BOOL: - return xlSheetWriteBool(sheet, row, col, Z_BVAL_P(data), format); + case IS_TRUE: + return xlSheetWriteBool(sheet, row, col, 1, format); + + case IS_FALSE: + return xlSheetWriteBool(sheet, row, col, 0, format); + + case IS_REFERENCE: + ZVAL_DEREF(data); + goto try_again; + + default: + php_error_docref(NULL, E_WARNING, "Type mismatch: %s not supported for atomic write operation in row %d, column %d", Z_TYPE_P(data), row, col); + return 1; } return 0; @@ -2471,12 +2522,12 @@ EXCEL_METHOD(Sheet, write) SheetHandle sheet; BookHandle book; FormatHandle format; - long row, col; + zend_long row, col; zval *oformat = NULL; - long dtype = -1; + zend_long dtype = -1; zval *data; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz|O!l", &row, &col, &data, &oformat, excel_ce_format, &dtype) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llz|O!l", &row, &col, &data, &oformat, excel_ce_format, &dtype) == FAILURE) { RETURN_FALSE; } @@ -2485,8 +2536,8 @@ EXCEL_METHOD(Sheet, write) FORMAT_FROM_OBJECT(format, oformat); } - if (!php_excel_write_cell(sheet, book, row, col, data, oformat ? format : 0, dtype TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write cell in row %ld, column %ld with error '%s'", row, col, xlBookErrorMessage(book)); + if (!php_excel_write_cell(sheet, book, row, col, data, oformat ? format : 0, dtype)) { + php_error_docref(NULL, E_WARNING, "Failed to write cell in row %d, column %d with error '%s'", row, col, xlBookErrorMessage(book)); RETURN_FALSE; } @@ -2502,14 +2553,13 @@ EXCEL_METHOD(Sheet, writeRow) SheetHandle sheet; BookHandle book; FormatHandle format; - long row, col = 0; + zend_long row, col = 0; zval *oformat = NULL; zval *data; - HashPosition pos; - zval **element; + zval *element; long i; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|lO", &row, &data, &col, &oformat, excel_ce_format) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "la|lO", &row, &data, &col, &oformat, excel_ce_format) == FAILURE) { RETURN_FALSE; } @@ -2519,26 +2569,23 @@ EXCEL_METHOD(Sheet, writeRow) } if (row < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid row number '%ld'", row); + php_error_docref(NULL, E_WARNING, "Invalid row number '%ld'", row); RETURN_FALSE; } if (col < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid starting column number '%ld'", col); + php_error_docref(NULL, E_WARNING, "Invalid starting column number '%ld'", col); RETURN_FALSE; } i = col; - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(data), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(data), (void **) &element, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_P(data), &pos)) { - - if (!php_excel_write_cell(sheet, book, row, i++, *element, oformat ? format : 0, -1 TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write cell in row %ld, column %ld with error '%s'", row, i-1, xlBookErrorMessage(book)); + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), element) { + if (!php_excel_write_cell(sheet, book, row, i++, element, (oformat ? format : 0), -1)) { + php_error_docref(NULL, E_WARNING, "Failed to write cell in row %d, column %d with error '%s'", row, i-1, xlBookErrorMessage(book)); RETURN_FALSE; } - } + } ZEND_HASH_FOREACH_END(); RETURN_TRUE; } @@ -2552,15 +2599,14 @@ EXCEL_METHOD(Sheet, writeCol) SheetHandle sheet; BookHandle book; FormatHandle format; - long row = 0, col; + zend_long row = 0, col; zval *oformat = NULL; zval *data; - HashPosition pos; - zval **element; + zval *element; long i; - long dtype = -1; + zend_long dtype = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|lO!l", &col, &data, &row, &oformat, excel_ce_format, &dtype) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "la|lO!l", &col, &data, &row, &oformat, excel_ce_format, &dtype) == FAILURE) { RETURN_FALSE; } @@ -2570,41 +2616,51 @@ EXCEL_METHOD(Sheet, writeCol) } if (col < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column number '%ld'", col); + php_error_docref(NULL, E_WARNING, "Invalid column number '%ld'", col); RETURN_FALSE; } if (row < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid starting row number '%ld'", row); + php_error_docref(NULL, E_WARNING, "Invalid starting row number '%ld'", row); RETURN_FALSE; } i = row; - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(data), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(data), (void **) &element, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_P(data), &pos)) { - - if (!php_excel_write_cell(sheet, book, i++, col, *element, oformat ? format : 0, dtype TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write cell in row %ld, column %ld with error '%s'", i-1, col, xlBookErrorMessage(book)); + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), element) { + if (!php_excel_write_cell(sheet, book, i++, col, element, oformat ? format : 0, dtype)) { + php_error_docref(NULL, E_WARNING, "Failed to write cell in row %d, column %d with error '%s'", i-1, col, xlBookErrorMessage(book)); RETURN_FALSE; } - } + } ZEND_HASH_FOREACH_END(); RETURN_TRUE; } /* }}} */ -#define PHP_EXCEL_SHEET_GET_BOOL_STATE(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long r, c; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &r, &c) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - RETURN_BOOL(xlSheet ## func_name (sheet, r, c)); \ +#define PHP_EXCEL_SHEET_GET_BOOL_STATE(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long r, c; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &r, &c) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_BOOL(xlSheet ## func_name (sheet, r, c)); \ + } + +#define PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long r, c; \ + zend_bool u = 1; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_BOOL(xlSheet ## func_name (sheet, r, c, u)); \ } /* {{{ proto bool ExcelSheet::isFormula(int row, int column) @@ -2620,14 +2676,10 @@ EXCEL_METHOD(Sheet, isFormula) EXCEL_METHOD(Sheet, isDate) { zval *object = getThis(); - long r, c; -#if LIBXL_VERSION <= 0x03010000 - double d; - FormatHandle format = NULL; -#endif + zend_long r, c; SheetHandle sheet; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &r, &c) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &r, &c) == FAILURE) { RETURN_FALSE; } @@ -2636,57 +2688,149 @@ EXCEL_METHOD(Sheet, isDate) if (xlSheetCellType(sheet, r, c) != CELLTYPE_NUMBER) { RETURN_FALSE; } -#if LIBXL_VERSION <= 0x03010000 - d = xlSheetReadNum(sheet, r, c, &format); - RETURN_BOOL(xlSheetIsDate(sheet, r, c) && (!format || (xlFormatNumFormat(format) < 100))); -#else + RETURN_BOOL(xlSheetIsDate(sheet, r, c)); -#endif } /* }}} */ -/* {{{ proto bool ExcelSheet::insertRow(int row_first, int row_last) +/* {{{ proto bool ExcelSheet::insertRow(int row_first, int row_last, bool update_named_ranges) Inserts rows from rowFirst to rowLast */ EXCEL_METHOD(Sheet, insertRow) { +#if LIBXL_VERSION >= 0x03080800 + SheetHandle sheet; + zval *object = getThis(); + zend_long r, c; + zend_bool u = 1; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { + RETURN_FALSE; + } + SHEET_FROM_OBJECT(sheet, object); + if (u == 1) { + RETURN_BOOL(xlSheetInsertRow (sheet, r, c)); + } else { +#ifdef _UNICODE + RETURN_BOOL(xlSheetInsertRowAndKeepRangesW (sheet, r, c)); +#else + RETURN_BOOL(xlSheetInsertRowAndKeepRangesA (sheet, r, c)); +#endif + } +#else +# if LIBXL_VERSION >= 0x03080301 + PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(InsertRow) +# else PHP_EXCEL_SHEET_GET_BOOL_STATE(InsertRow) +# endif +#endif } /* }}} */ -/* {{{ proto bool ExcelSheet::insertCol(int col_first, int col_last) +/* {{{ proto bool ExcelSheet::insertCol(int col_first, int col_last, bool update_named_ranges) Inserts columns from colFirst to colLast */ EXCEL_METHOD(Sheet, insertCol) { +#if LIBXL_VERSION >= 0x03080800 + SheetHandle sheet; + zval *object = getThis(); + zend_long r, c; + zend_bool u = 1; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { + RETURN_FALSE; + } + SHEET_FROM_OBJECT(sheet, object); + if (u == 1) { + RETURN_BOOL(xlSheetInsertCol (sheet, r, c)); + } else { +#ifdef _UNICODE + RETURN_BOOL(xlSheetInsertColAndKeepRangesW (sheet, r, c)); +#else + RETURN_BOOL(xlSheetInsertColAndKeepRangesA (sheet, r, c)); +#endif + } +#else +# if LIBXL_VERSION >= 0x03080301 + PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(InsertCol) +# else PHP_EXCEL_SHEET_GET_BOOL_STATE(InsertCol) +# endif +#endif } /* }}} */ -/* {{{ proto bool ExcelSheet::removeRow(int row_first, int row_last) +/* {{{ proto bool ExcelSheet::removeRow(int row_first, int row_last, bool update_named_ranges) Removes rows from rowFirst to rowLast */ EXCEL_METHOD(Sheet, removeRow) { +#if LIBXL_VERSION >= 0x03080800 + SheetHandle sheet; + zval *object = getThis(); + zend_long r, c; + zend_bool u = 1; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { + RETURN_FALSE; + } + SHEET_FROM_OBJECT(sheet, object); + if (u == 1) { + RETURN_BOOL(xlSheetRemoveRow (sheet, r, c)); + } else { +#ifdef _UNICODE + RETURN_BOOL(xlSheetRemoveRowAndKeepRangesW (sheet, r, c)); +#else + RETURN_BOOL(xlSheetRemoveRowAndKeepRangesA (sheet, r, c)); +#endif + } +#else +# if LIBXL_VERSION >= 0x03080301 + PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(RemoveRow) +# else PHP_EXCEL_SHEET_GET_BOOL_STATE(RemoveRow) +# endif +#endif } /* }}} */ -/* {{{ proto bool ExcelSheet::removeCol(int col_first, int col_last) +/* {{{ proto bool ExcelSheet::removeCol(int col_first, int col_last, bool update_named_ranges) Removes columns from colFirst to colLast */ EXCEL_METHOD(Sheet, removeCol) { +#if LIBXL_VERSION >= 0x03080800 + SheetHandle sheet; + zval *object = getThis(); + zend_long r, c; + zend_bool u = 1; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { + RETURN_FALSE; + } + SHEET_FROM_OBJECT(sheet, object); + if (u == 1) { + RETURN_BOOL(xlSheetRemoveCol (sheet, r, c)); + } else { +#ifdef _UNICODE + RETURN_BOOL(xlSheetRemoveColAndKeepRangesW (sheet, r, c)); +#else + RETURN_BOOL(xlSheetRemoveColAndKeepRangesA (sheet, r, c)); +#endif + } +#else +# if LIBXL_VERSION >= 0x03080301 + PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(RemoveCol) +# else PHP_EXCEL_SHEET_GET_BOOL_STATE(RemoveCol) +# endif +#endif } /* }}} */ -#define PHP_EXCEL_SHEET_GET_DOUBLE_STATE(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long val; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - RETURN_DOUBLE(xlSheet ## func_name (sheet, val)); \ +#define PHP_EXCEL_SHEET_GET_DOUBLE_STATE(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long val; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &val) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_DOUBLE(xlSheet ## func_name (sheet, val)); \ } /* {{{ proto double ExcelSheet::colWidth(int column) @@ -2712,9 +2856,9 @@ EXCEL_METHOD(Sheet, readComment) SheetHandle sheet; zval *object = getThis(); const char *s; - long r, c; + zend_long r, c; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &r, &c) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &r, &c) == FAILURE) { RETURN_FALSE; } @@ -2724,7 +2868,7 @@ EXCEL_METHOD(Sheet, readComment) if (!s) { RETURN_FALSE; } - RETURN_STRING((char *)s, 1); + RETURN_STRING((char *)s); } /* }}} */ @@ -2734,17 +2878,19 @@ EXCEL_METHOD(Sheet, writeComment) { SheetHandle sheet; zval *object = getThis(); - char *val, *auth; - int val_len, auth_len; - long r, c, w, h; + zend_string *val_zs = NULL, *auth_zs = NULL; + zend_long r, c, w, h; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llssll", &r, &c, &val, &val_len, &auth, &auth_len, &w, &h) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llSSll", &r, &c, &val_zs, &auth_zs, &w, &h) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(auth_zs) + EXCEL_NON_EMPTY_STRING(val_zs) + SHEET_FROM_OBJECT(sheet, object); - xlSheetWriteComment(sheet, r, c, val, auth, w, h); + xlSheetWriteComment(sheet, r, c, ZSTR_VAL(val_zs), ZSTR_VAL(auth_zs), w, h); } /* }}} */ @@ -2755,12 +2901,12 @@ EXCEL_METHOD(Sheet, setColWidth) SheetHandle sheet; FormatHandle format; zval *object = getThis(); - long s, e; + zend_long s, e; double width; zval *f = NULL; zend_bool h = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lld|bz/", &s, &e, &width, &h, &f) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lld|bz/", &s, &e, &width, &h, &f) == FAILURE) { RETURN_FALSE; } @@ -2771,13 +2917,13 @@ EXCEL_METHOD(Sheet, setColWidth) } if (e < s) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Start cell is greater then end cell"); + php_error_docref(NULL, E_WARNING, "Start cell is greater then end cell"); RETURN_FALSE; } else if (s < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Start cell cannot be less then 0"); + php_error_docref(NULL, E_WARNING, "Start cell cannot be less then 0"); RETURN_FALSE; } else if (width < -1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Width cannot be less then -1"); + php_error_docref(NULL, E_WARNING, "Width cannot be less then -1"); RETURN_FALSE; } @@ -2792,12 +2938,12 @@ EXCEL_METHOD(Sheet, setRowHeight) SheetHandle sheet; FormatHandle format; zval *object = getThis(); - long row; + zend_long row; double height; zval *f = NULL; zend_bool h = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld|z/b", &row, &height, &f, &h) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ld|z/b", &row, &height, &f, &h) == FAILURE) { RETURN_FALSE; } @@ -2808,10 +2954,10 @@ EXCEL_METHOD(Sheet, setRowHeight) } if (row < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Row number cannot be less then 0"); + php_error_docref(NULL, E_WARNING, "Row number cannot be less then 0"); RETURN_FALSE; } else if (height < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Height cannot be less then 0"); + php_error_docref(NULL, E_WARNING, "Height cannot be less then 0"); RETURN_FALSE; } @@ -2825,14 +2971,10 @@ EXCEL_METHOD(Sheet, getMerge) { SheetHandle sheet; zval *object = getThis(); - long row, col; -#if LIBXL_VERSION >= 0x03010000 + zend_long row, col; int rowFirst, rowLast, colFirst, colLast; -#else - unsigned short rowFirst, rowLast, colFirst, colLast; -#endif - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &row, &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { RETURN_FALSE; } @@ -2856,9 +2998,9 @@ EXCEL_METHOD(Sheet, setMerge) { SheetHandle sheet; zval *object = getThis(); - long row_s, col_s, row_e, col_e; + zend_long row_s, col_s, row_e, col_e; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &row_s, &row_e, &col_s, &col_e) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &row_s, &row_e, &col_s, &col_e) == FAILURE) { RETURN_FALSE; } @@ -2874,9 +3016,9 @@ EXCEL_METHOD(Sheet, deleteMerge) { SheetHandle sheet; zval *object = getThis(); - long row, col; + zend_long row, col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &row, &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { RETURN_FALSE; } @@ -2886,18 +3028,17 @@ EXCEL_METHOD(Sheet, deleteMerge) } /* }}} */ -#if LIBXL_VERSION >= 0x03040000 /* {{{ proto void ExcelSheet::addPictureScaled(int row, int column, int pic_id, double scale [, int x_offset [, int y_offset]]) Insert picture into a cell with a set scale */ EXCEL_METHOD(Sheet, addPictureScaled) { SheetHandle sheet; zval *object = getThis(); - long row, col, pic_id; - long x_offset = 0, y_offset = 0, pos = 0; + zend_long row, col, pic_id; + zend_long x_offset = 0, y_offset = 0, pos = 0; double scale; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llld|lll", &row, &col, &pic_id, &scale, &x_offset, &y_offset, &pos) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llld|lll", &row, &col, &pic_id, &scale, &x_offset, &y_offset, &pos) == FAILURE) { RETURN_FALSE; } @@ -2917,10 +3058,10 @@ EXCEL_METHOD(Sheet, addPictureDim) { SheetHandle sheet; zval *object = getThis(); - long row, col, pic_id, w, h; - long x_offset = 0, y_offset = 0, pos = 0; + zend_long row, col, pic_id, w, h; + zend_long x_offset = 0, y_offset = 0, pos = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllll|lll", &row, &col, &pic_id, &w, &h, &x_offset, &y_offset, &pos) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll|lll", &row, &col, &pic_id, &w, &h, &x_offset, &y_offset, &pos) == FAILURE) { RETURN_FALSE; } @@ -2933,56 +3074,18 @@ EXCEL_METHOD(Sheet, addPictureDim) ); } /* }}} */ -#else -/* {{{ proto void ExcelSheet::addPictureScaled(int row, int column, int pic_id, double scale) - Insert picture into a cell with a set scale */ -EXCEL_METHOD(Sheet, addPictureScaled) -{ - SheetHandle sheet; - zval *object = getThis(); - long row, col, pic_id; - double scale; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llld", &row, &col, &pic_id, &scale) == FAILURE) { - RETURN_FALSE; - } - - SHEET_FROM_OBJECT(sheet, object); - - xlSheetSetPicture(sheet, row, col, pic_id, scale); -} -/* }}} */ - -/* {{{ proto void ExcelSheet::addPictureDim(int row, int column, int pic_id, int width, int height) - Insert picture into a cell with a given dimensions */ -EXCEL_METHOD(Sheet, addPictureDim) -{ - SheetHandle sheet; - zval *object = getThis(); - long row, col, pic_id, w, h; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllll", &row, &col, &pic_id, &w, &h) == FAILURE) { - RETURN_FALSE; - } - SHEET_FROM_OBJECT(sheet, object); - - xlSheetSetPicture2(sheet, row, col, pic_id, w, h); -} -/* }}} */ -#endif - -#define PHP_EXCEL_SHEET_SET_BREAK(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long val; \ +#define PHP_EXCEL_SHEET_SET_BREAK(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long val; \ zend_bool brk; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &val, &brk) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - RETURN_BOOL(xlSheet ## func_name (sheet, val, brk)); \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lb", &val, &brk) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_BOOL(xlSheet ## func_name (sheet, val, brk)); \ } /* {{{ proto bool ExcelSheet::horPageBreak(int row, bool break) @@ -3007,9 +3110,9 @@ EXCEL_METHOD(Sheet, splitSheet) { SheetHandle sheet; zval *object = getThis(); - long row, col; + zend_long row, col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &row, &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { RETURN_FALSE; } @@ -3019,17 +3122,17 @@ EXCEL_METHOD(Sheet, splitSheet) } /* }}} */ -#define PHP_EXCEL_SHEET_GROUP(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long s, e; \ +#define PHP_EXCEL_SHEET_GROUP(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long s, e; \ zend_bool brk = 0; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|b", &s, &e, &brk) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - RETURN_BOOL(xlSheet ## func_name (sheet, s, e, brk)); \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &s, &e, &brk) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_BOOL(xlSheet ## func_name (sheet, s, e, brk)); \ } /* {{{ proto bool ExcelSheet::groupRows(int start_row, int end_row [, bool collapse]) @@ -3054,9 +3157,9 @@ EXCEL_METHOD(Sheet, clear) { SheetHandle sheet; zval *object = getThis(); - long row_s, col_s, col_e, row_e; + zend_long row_s, col_s, col_e, row_e; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &row_s, &row_e, &col_s, &col_e) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &row_s, &row_e, &col_s, &col_e) == FAILURE) { RETURN_FALSE; } @@ -3072,9 +3175,9 @@ EXCEL_METHOD(Sheet, copy) { SheetHandle sheet; zval *object = getThis(); - long row, col, to_row, to_col; + zend_long row, col, to_row, to_col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &row, &col, &to_row, &to_col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &row, &col, &to_row, &to_col) == FAILURE) { RETURN_FALSE; } @@ -3087,53 +3190,53 @@ EXCEL_METHOD(Sheet, copy) #define PE_RETURN_IS_LONG RETURN_LONG #define PE_RETURN_IS_BOOL RETURN_BOOL #define PE_RETURN_IS_DOUBLE RETURN_DOUBLE -#define PE_RETURN_IS_STRING(data) if (data) { RETURN_STRING((char *)data, 1) } else { RETURN_NULL(); } +#define PE_RETURN_IS_STRING(data) if (data) { RETURN_STRING((char *)data); } else { RETURN_NULL(); } -#define PHP_EXCEL_INFO(func_name, type) \ -{ \ - SheetHandle sheet; \ - zval *object = getThis(); \ - if (ZEND_NUM_ARGS()) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - PE_RETURN_ ## type (xlSheet ## func_name (sheet)); \ -} - -#define PHP_EXCEL_SET_BOOL_VAL(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - zend_bool val; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - xlSheet ## func_name (sheet, val); \ - } - -#define PHP_EXCEL_SET_LONG_VAL(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long val; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - xlSheet ## func_name (sheet, val); \ - } - -#define PHP_EXCEL_SET_DOUBLE_VAL(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - double val; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &val) == FAILURE) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - xlSheet ## func_name (sheet, val); \ +#define PHP_EXCEL_INFO(func_name, type) \ +{ \ + SheetHandle sheet; \ + zval *object = getThis(); \ + if (ZEND_NUM_ARGS()) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + PE_RETURN_ ## type (xlSheet ## func_name (sheet)); \ +} + +#define PHP_EXCEL_SET_BOOL_VAL(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_bool val; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &val) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + xlSheet ## func_name (sheet, val); \ + } + +#define PHP_EXCEL_SET_LONG_VAL(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long val; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &val) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + xlSheet ## func_name (sheet, val); \ + } + +#define PHP_EXCEL_SET_DOUBLE_VAL(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + double val; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &val) == FAILURE) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + xlSheet ## func_name (sheet, val); \ } /* {{{ proto int ExcelSheet::firstRow() @@ -3192,7 +3295,6 @@ EXCEL_METHOD(Sheet, setDisplayGridlines) } /* }}} */ -#if LIBXL_VERSION >= 0x03020300 /* {{{ proto bool ExcelSheet::setHidden(bool value) Hides/unhides the sheet. */ EXCEL_METHOD(Sheet, setHidden) @@ -3201,7 +3303,7 @@ EXCEL_METHOD(Sheet, setHidden) zval *object = getThis(); zend_bool val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &val) == FAILURE) { RETURN_FALSE; } @@ -3227,9 +3329,7 @@ EXCEL_METHOD(Sheet, isHidden) RETURN_BOOL(xlSheetHidden(sheet)); } /* }}} */ -#endif -#if LIBXL_VERSION >= 0x03020400 /* {{{ proto array ExcelSheet::getTopLeftView() Extracts the first visible row and the leftmost visible column of the sheet. */ EXCEL_METHOD(Sheet, getTopLeftView) @@ -3258,9 +3358,9 @@ EXCEL_METHOD(Sheet, setTopLeftView) { SheetHandle sheet; zval *object = getThis(); - long r,c; + zend_long r,c; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &r, &c) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &r, &c) == FAILURE) { RETURN_FALSE; } @@ -3278,10 +3378,10 @@ EXCEL_METHOD(Sheet, rowColToAddr) SheetHandle sheet; zval *object = getThis(); zend_bool row_relative = 1, col_relative = 1; - long row, col; + zend_long row, col; const char *cel_ref; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|bb", &row, &col, &row_relative, &col_relative) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|bb", &row, &col, &row_relative, &col_relative) == FAILURE) { RETURN_FALSE; } @@ -3291,7 +3391,7 @@ EXCEL_METHOD(Sheet, rowColToAddr) if (!cel_ref) { RETURN_FALSE; } - RETURN_STRING(cel_ref, 1); + RETURN_STRING(cel_ref); } /* }}} */ @@ -3301,22 +3401,21 @@ EXCEL_METHOD(Sheet, addrToRowCol) { SheetHandle sheet; zval *object = getThis(); - char *cell_reference; - int cell_reference_len; + zend_string *cell_reference_zs = NULL; int row = 0, col = 0, rowRelative = 0, colRelative = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &cell_reference, &cell_reference_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &cell_reference_zs) == FAILURE) { RETURN_FALSE; } - if (!cell_reference_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cell reference cannot be empty"); + if (!cell_reference_zs || ZSTR_LEN(cell_reference_zs) < 1) { + php_error_docref(NULL, E_WARNING, "Cell reference cannot be empty"); RETURN_FALSE; } SHEET_FROM_OBJECT(sheet, object); - xlSheetAddrToRowCol(sheet, cell_reference, &row, &col, &rowRelative, &colRelative); + xlSheetAddrToRowCol(sheet, ZSTR_VAL(cell_reference_zs), &row, &col, &rowRelative, &colRelative); array_init(return_value); add_assoc_long(return_value, "row", row); add_assoc_long(return_value, "column", col); @@ -3324,7 +3423,6 @@ EXCEL_METHOD(Sheet, addrToRowCol) add_assoc_bool(return_value, "row_relative", rowRelative); } /* }}} */ -#endif /* {{{ proto void ExcelSheet::setPrintGridlines(bool value) Sets gridlines for printing */ @@ -3414,18 +3512,20 @@ EXCEL_METHOD(Sheet, footer) } /* }}} */ -#define PHP_EXCEL_SET_HF(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - char *val; \ - int val_len; \ - double margin; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd", &val, &val_len, &margin) == FAILURE || val_len > 255) { \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - RETURN_BOOL(xlSheet ## func_name (sheet, val, margin)); \ +#define PHP_EXCEL_SET_HF(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_string *val_zs = NULL; \ + double margin; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sd", &val_zs, &margin) == FAILURE) { \ + RETURN_FALSE; \ + } \ + if (!val_zs || ZSTR_LEN(val_zs) > 255) { \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + RETURN_BOOL(xlSheet ## func_name (sheet, ZSTR_VAL(val_zs), margin)); \ } /* {{{ proto bool ExcelSheet::setHeader(string header, double margin) @@ -3586,58 +3686,50 @@ EXCEL_METHOD(Sheet, setName) { SheetHandle sheet; zval *object = getThis(); - char *val; - int val_len; + zend_string *val_zs = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &val, &val_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &val_zs) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(val_zs) + SHEET_FROM_OBJECT(sheet, object); - xlSheetSetName(sheet, val); + xlSheetSetName(sheet, ZSTR_VAL(val_zs)); } /* }}} */ -#if LIBXL_VERSION >= 0x03010000 -/* {{{ proto bool ExcelSheet::setNamedRange(string name, int row, int to_row, int col, int to_col [, int scope_id]) +/* {{{ proto bool ExcelSheet::setNamedRange(string name, int row, int col, int to_row, int to_col [, int scope_id]) Create a named range */ EXCEL_METHOD(Sheet, setNamedRange) { SheetHandle sheet; zval *object = getThis(); - long row, to_row, col, to_col; - char *name; - int name_len; -#if LIBXL_VERSION >= 0x03050401 - long scope_id = SCOPE_WORKBOOK; + zend_long row, to_row, col, to_col; + zend_string *name_zs = NULL; + zend_long scope_id = SCOPE_WORKBOOK; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll|l", &name, &name_len, &row, &to_row, &col, &to_col, &scope_id) == FAILURE) { -#else - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &name, &name_len, &row, &to_row, &col, &to_col) == FAILURE) { -#endif + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sllll|l", &name_zs, &row, &to_row, &col, &to_col, &scope_id) == FAILURE) { RETURN_FALSE; } - if (!name_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range name cannot be empty."); + if (!name_zs || ZSTR_LEN(name_zs) < 1) { + php_error_docref(NULL, E_WARNING, "The range name cannot be empty."); RETURN_FALSE; } + if (row > to_row) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range row start cannot be greater than row end."); + php_error_docref(NULL, E_WARNING, "The range row start cannot be greater than row end."); RETURN_FALSE; } else if (col > to_col) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range column start cannot be greater than column end."); + php_error_docref(NULL, E_WARNING, "The range column start cannot be greater than column end."); RETURN_FALSE; } SHEET_FROM_OBJECT(sheet, object); -#if LIBXL_VERSION >= 0x03050401 - RETURN_BOOL(xlSheetSetNamedRange(sheet, name, row, to_row, col, to_col, scope_id)); -#else - RETURN_BOOL(xlSheetSetNamedRange(sheet, name, row, to_row, col, to_col)); -#endif + RETURN_BOOL(xlSheetSetNamedRange(sheet, ZSTR_VAL(name_zs), row, to_row, col, to_col, scope_id)); } /* }}} */ @@ -3647,48 +3739,39 @@ EXCEL_METHOD(Sheet, delNamedRange) { SheetHandle sheet; zval *object = getThis(); - char *val; - int val_len; -#if LIBXL_VERSION >= 0x03050401 - long scope_id = SCOPE_WORKBOOK; + zend_string *val_zs = NULL; + zend_long scope_id = SCOPE_WORKBOOK; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &val, &val_len, &scope_id) == FAILURE) { -#else - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &val, &val_len) == FAILURE) { -#endif + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &val_zs, &scope_id) == FAILURE) { RETURN_FALSE; } - if (!val_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range name cannot be empty."); + if (!val_zs || ZSTR_LEN(val_zs) < 1) { + php_error_docref(NULL, E_WARNING, "The range name cannot be empty."); RETURN_FALSE; } SHEET_FROM_OBJECT(sheet, object); -#if LIBXL_VERSION >= 0x03050401 - RETURN_BOOL(xlSheetDelNamedRange(sheet, val, scope_id)); -#else - RETURN_BOOL(xlSheetDelNamedRange(sheet, val)); -#endif + RETURN_BOOL(xlSheetDelNamedRange(sheet, ZSTR_VAL(val_zs), scope_id)); } /* }}} */ -#define PHP_EXCEL_SHEET_PRINT_AREA(func_name) \ - { \ - SheetHandle sheet; \ - zval *object = getThis(); \ - long s, e; \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &s, &e) == FAILURE) { \ - RETURN_FALSE; \ - } \ - if (s > e) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range start is greater than the end."); \ - RETURN_FALSE; \ - } \ - SHEET_FROM_OBJECT(sheet, object); \ - xlSheet ## func_name (sheet, s, e); \ - RETURN_TRUE; \ +#define PHP_EXCEL_SHEET_PRINT_AREA(func_name) \ + { \ + SheetHandle sheet; \ + zval *object = getThis(); \ + zend_long s, e; \ + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &s, &e) == FAILURE) { \ + RETURN_FALSE; \ + } \ + if (s > e) { \ + php_error_docref(NULL, E_WARNING, "The range start is greater than the end."); \ + RETURN_FALSE; \ + } \ + SHEET_FROM_OBJECT(sheet, object); \ + xlSheet ## func_name (sheet, s, e); \ + RETURN_TRUE; \ } /* {{{ proto bool ExcelSheet::setPrintRepeatRows(int rowFirst, int rowLast) @@ -3731,7 +3814,7 @@ EXCEL_METHOD(Sheet, setGroupSummaryBelow) zval *object = getThis(); zend_bool val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &val) == FAILURE) { RETURN_FALSE; } @@ -3766,7 +3849,7 @@ EXCEL_METHOD(Sheet, setGroupSummaryRight) zval *object = getThis(); zend_bool val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &val) == FAILURE) { RETURN_FALSE; } @@ -3777,16 +3860,15 @@ EXCEL_METHOD(Sheet, setGroupSummaryRight) } /* }}} */ -#if LIBXL_VERSION >= 0x03020000 /* {{{ proto bool ExcelSheet::setPrintFit(int wPages, int hPages) Fits sheet width and sheet height to wPages and hPages respectively. */ EXCEL_METHOD(Sheet, setPrintFit) { SheetHandle sheet; zval *object = getThis(); - long wPages, hPages; + zend_long wPages, hPages; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &wPages, &hPages) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &wPages, &hPages) == FAILURE) { RETURN_FALSE; } @@ -3826,34 +3908,26 @@ EXCEL_METHOD(Sheet, getNamedRange) { SheetHandle sheet; zval *object = getThis(); - char *name; - int name_len; + zend_string *name_zs = NULL; int rf, rl, cf, cl; -#if LIBXL_VERSION >= 0x03050401 - long scope_id = SCOPE_WORKBOOK; + zend_long scope_id = SCOPE_WORKBOOK; int hidden = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &name, &name_len, &scope_id) == FAILURE) { -#else - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { -#endif + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &name_zs, &scope_id) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(name_zs) + SHEET_FROM_OBJECT(sheet, object); -#if LIBXL_VERSION >= 0x03050401 - if (xlSheetGetNamedRange(sheet, name, &rf, &rl, &cf, &cl, scope_id, &hidden)) { -#else - if (xlSheetGetNamedRange(sheet, name, &rf, &rl, &cf, &cl)) { -#endif + + if (xlSheetGetNamedRange(sheet, ZSTR_VAL(name_zs), &rf, &rl, &cf, &cl, scope_id, &hidden)) { array_init(return_value); add_assoc_long(return_value, "row_first", rf); add_assoc_long(return_value, "row_last", rl); add_assoc_long(return_value, "col_first", cf); add_assoc_long(return_value, "col_last", cl); -#if LIBXL_VERSION >= 0x03050401 add_assoc_bool(return_value, "hidden", hidden); -#endif } else { RETURN_FALSE; } @@ -3865,36 +3939,24 @@ EXCEL_METHOD(Sheet, getIndexRange) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; int rf, rl, cf, cl; -#if LIBXL_VERSION >= 0x03050401 - int hidden; - long scope_id = SCOPE_WORKBOOK; + int hidden = 0; + zend_long scope_id = SCOPE_WORKBOOK; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &index, &scope_id) == FAILURE) { - RETURN_FALSE; - } -#else - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &index, &scope_id) == FAILURE) { RETURN_FALSE; } -#endif SHEET_FROM_OBJECT(sheet, object); -#if LIBXL_VERSION >= 0x03050401 if (xlSheetNamedRange(sheet, (int)index, &rf, &rl, &cf, &cl, (int *)&scope_id, &hidden)) { -#else - if (xlSheetNamedRange(sheet, (int)index, &rf, &rl, &cf, &cl)) { -#endif array_init(return_value); add_assoc_long(return_value, "row_first", rf); add_assoc_long(return_value, "row_last", rl); add_assoc_long(return_value, "col_first", cf); add_assoc_long(return_value, "col_last", cl); -#if LIBXL_VERSION >= 0x03050401 add_assoc_bool(return_value, "hidden", hidden); add_assoc_long(return_value, "scope", scope_id); -#endif } else { RETURN_FALSE; } @@ -3923,9 +3985,9 @@ EXCEL_METHOD(Sheet, getVerPageBreak) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -3956,9 +4018,9 @@ EXCEL_METHOD(Sheet, getHorPageBreak) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -3989,11 +4051,11 @@ EXCEL_METHOD(Sheet, getPictureInfo) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; int rowTop, colLeft, rowBottom, colRight, width, height, offset_x, offset_y; int pic_index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4065,7 +4127,7 @@ EXCEL_METHOD(Book, getRefR1C1) } BOOK_FROM_OBJECT(book, object); - RETURN_BOOL(xlBookRefR1C1(book)); + RETURN_BOOL(xlBookRefR1C1A(book)); } /* }}} */ @@ -4077,12 +4139,12 @@ EXCEL_METHOD(Book, setRefR1C1) zval *object = getThis(); zend_bool active; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &active) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &active) == FAILURE) { RETURN_FALSE; } BOOK_FROM_OBJECT(book, object); - xlBookSetRefR1C1(book, (int)active); + xlBookSetRefR1C1A(book, (int)active); } /* }}} */ @@ -4092,13 +4154,13 @@ EXCEL_METHOD(Book, getPicture) { BookHandle book; zval *object = getThis(); - long index; + zend_long index; int type; const char *buf; unsigned int buf_len; enum PictureType {PICTURETYPE_PNG, PICTURETYPE_JPEG, PICTURETYPE_WMF, PICTURETYPE_DIB, PICTURETYPE_EMF, PICTURETYPE_PICT, PICTURETYPE_TIFF, PICTURETYPE_ERROR = 0xFF}; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4109,7 +4171,7 @@ EXCEL_METHOD(Book, getPicture) } array_init(return_value); - add_assoc_stringl(return_value, "data", (char *)buf, buf_len, 1); + add_assoc_stringl(return_value, "data", (char *)buf, buf_len); add_assoc_long(return_value, "type", type); } /* }}} */ @@ -4139,39 +4201,34 @@ EXCEL_METHOD(Book, insertSheet) zval *shz = NULL; SheetHandle sh, sheet; excel_sheet_object *fo; - char *name; - int name_len; - long index; + zend_string *name_zs = NULL; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|o", &index, &name, &name_len, &shz) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lS|o", &index, &name_zs, &shz) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(name_zs) + BOOK_FROM_OBJECT(book, object); if (shz) { SHEET_FROM_OBJECT(sheet, shz); - if (!(sh = xlBookInsertSheet(book, index, name, sheet))) { + if (!(sh = xlBookInsertSheet(book, index, ZSTR_VAL(name_zs), sheet))) { RETURN_FALSE; } } else { - if (!(sh = xlBookInsertSheet(book, index, name, 0))) { + if (!(sh = xlBookInsertSheet(book, index, ZSTR_VAL(name_zs), 0))) { RETURN_FALSE; } } - Z_TYPE_P(return_value) = IS_OBJECT; - object_init_ex(return_value, excel_ce_sheet); - Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); - fo = (excel_sheet_object *) zend_object_store_get_object(return_value TSRMLS_CC); + ZVAL_OBJ(return_value, excel_object_new_sheet(excel_ce_sheet)); + fo = Z_EXCEL_SHEET_OBJ_P(return_value); fo->sheet = sh; fo->book = book; } /* }}} */ -#endif - -#if LIBXL_VERSION >= 0x03050401 /* {{{ proto bool ExcelBook::isTemplate() Returns whether the workbook is template. */ EXCEL_METHOD(Book, isTemplate) @@ -4196,7 +4253,7 @@ EXCEL_METHOD(Book, setTemplate) zval *object = getThis(); zend_bool mode; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &mode) == FAILURE) { RETURN_FALSE; } @@ -4227,9 +4284,9 @@ EXCEL_METHOD(Sheet, setRightToLeft) { SheetHandle sheet; zval *object = getThis(); - long mode; + zend_long mode; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &mode) == FAILURE) { RETURN_FALSE; } @@ -4237,7 +4294,6 @@ EXCEL_METHOD(Sheet, setRightToLeft) xlSheetSetRightToLeft(sheet, (int)mode); } /* }}} */ -#endif /* {{{ proto bool ExcelSheet::setPrintArea() Sets the print area. */ @@ -4245,17 +4301,17 @@ EXCEL_METHOD(Sheet, setPrintArea) { zval *object = getThis(); SheetHandle sheet; - long row, col, to_row, to_col; + zend_long row, col, to_row, to_col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &row, &to_row, &col, &to_col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &row, &to_row, &col, &to_col) == FAILURE) { RETURN_FALSE; } if (row > to_row) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range row start cannot be greater than row end."); + php_error_docref(NULL, E_WARNING, "The range row start cannot be greater than row end."); RETURN_FALSE; } else if (col > to_col) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The range column start cannot be greater than column end."); + php_error_docref(NULL, E_WARNING, "The range column start cannot be greater than column end."); RETURN_FALSE; } @@ -4300,7 +4356,6 @@ EXCEL_METHOD(Sheet, clearPrintArea) RETURN_TRUE; } /* }}} */ -#endif /* {{{ proto bool ExcelSheet::protect() Returns whether sheet is protected: 1 - yes, 0 - no. */ @@ -4310,6 +4365,7 @@ EXCEL_METHOD(Sheet, protect) } /* }}} */ +#if LIBXL_VERSION < 0x03070000 /* {{{ proto void ExcelSheet::setProtect(bool value) Protects (protect = 1) or unprotects (protect = 0) the sheet. */ EXCEL_METHOD(Sheet, setProtect) @@ -4317,8 +4373,8 @@ EXCEL_METHOD(Sheet, setProtect) PHP_EXCEL_SET_BOOL_VAL(SetProtect) } /* }}} */ +#endif -#if LIBXL_VERSION >= 0x03060000 /* {{{ proto long ExcelSheet::hyperlinkSize() Returns the number of hyperlinks in the sheet. */ EXCEL_METHOD(Sheet, hyperlinkSize) @@ -4341,11 +4397,11 @@ EXCEL_METHOD(Sheet, hyperlink) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; int rowFirst, rowLast, colFirst, colLast; const char *s; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4358,7 +4414,7 @@ EXCEL_METHOD(Sheet, hyperlink) } array_init(return_value); - add_assoc_string(return_value, "hyperlink", (char *)s, 1); + add_assoc_string(return_value, "hyperlink", (char *)s); add_assoc_long(return_value, "row_first", rowFirst); add_assoc_long(return_value, "row_last", rowLast); add_assoc_long(return_value, "col_first", colFirst); @@ -4372,9 +4428,9 @@ EXCEL_METHOD(Sheet, delHyperlink) { zval *object = getThis(); SheetHandle sheet; - long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4393,17 +4449,19 @@ EXCEL_METHOD(Sheet, addHyperlink) { SheetHandle sheet; zval *object = getThis(); - char *val; - int val_len; - long row_first, row_last, col_first, col_last; + zend_string *val_zs = NULL; + zend_long row_first, row_last, col_first, col_last; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &val, &val_len, &row_first, &row_last, &col_first, &col_last) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sllll", &val_zs, &row_first, &row_last, &col_first, &col_last) == FAILURE) { RETURN_FALSE; } + EXCEL_NON_EMPTY_STRING(val_zs) + SHEET_FROM_OBJECT(sheet, object); - xlSheetAddHyperlink(sheet, val, row_first, row_last, col_first, col_last); + xlSheetAddHyperlink(sheet, ZSTR_VAL(val_zs), row_first, row_last, col_first, col_last); + RETURN_TRUE; } /* }}} */ @@ -4430,10 +4488,10 @@ EXCEL_METHOD(Sheet, merge) { SheetHandle sheet; zval *object = getThis(); - long index; + zend_long index; int rowFirst, rowLast, colFirst, colLast; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4461,9 +4519,9 @@ EXCEL_METHOD(Sheet, delMergeByIndex) { zval *object = getThis(); SheetHandle sheet; - long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4502,9 +4560,9 @@ EXCEL_METHOD(Sheet, rowHidden) { zval *object = getThis(); SheetHandle sheet; - long row; + zend_long row; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &row) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &row) == FAILURE) { RETURN_FALSE; } @@ -4523,10 +4581,10 @@ EXCEL_METHOD(Sheet, setRowHidden) { zval *object = getThis(); SheetHandle sheet; - long row; + zend_long row; zend_bool hidden; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &row, &hidden) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lb", &row, &hidden) == FAILURE) { RETURN_FALSE; } @@ -4545,9 +4603,9 @@ EXCEL_METHOD(Sheet, colHidden) { zval *object = getThis(); SheetHandle sheet; - long col; + zend_long col; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &col) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &col) == FAILURE) { RETURN_FALSE; } @@ -4566,10 +4624,10 @@ EXCEL_METHOD(Sheet, setColHidden) { zval *object = getThis(); SheetHandle sheet; - long col; + zend_long col; zend_bool hidden; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lb", &col, &hidden) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lb", &col, &hidden) == FAILURE) { RETURN_FALSE; } @@ -4588,9 +4646,9 @@ EXCEL_METHOD(Book, sheetType) { zval *object = getThis(); BookHandle book; - long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_FALSE; } @@ -4602,7 +4660,6 @@ EXCEL_METHOD(Book, sheetType) RETURN_LONG(xlBookSheetType(book, index)); } /* }}} */ -#endif /* {{{ proto bool ExcelSheet::isLicensed() Get license status */ @@ -4613,229 +4670,970 @@ EXCEL_METHOD(Sheet, isLicensed) SheetHandle sheet; BookHandle book; - SHEET_AND_BOOK_FROM_OBJECT(sheet, book, object); + SHEET_AND_BOOK_FROM_OBJECT(sheet, book, object); + + xlSheetCellFormat(sheet, 0, 0); + err = (char *)xlBookErrorMessage(book); + if (err) { + // on Linux + if (!strcmp(err, "can't get access to format in row 0 in trial version")) { + RETURN_FALSE; + } + // on Win + if (!strcmp(err, "can't access row 0 in trial version")) { + RETURN_FALSE; + } + } + + RETURN_TRUE; +} +/* }}} */ + +#if LIBXL_VERSION >= 0x03060200 +/* {{{ proto void ExcelSheet::setAutoFitArea(int rowFirst, int colFirst, int rowLast, int colLast) + Sets the borders for autofit column widths feature. + The function xlSheetSetCol() with -1 width value will + affect only to the specified limited area. */ +EXCEL_METHOD(Sheet, setAutoFitArea) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_long rowFirst=0, colFirst=0, rowLast=-1, colLast=-1; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &rowFirst, &rowLast, &colFirst, &colLast) == FAILURE) { + RETURN_FALSE; + } + + if (rowFirst < 0) { + RETURN_FALSE; + } + + if (colFirst < 0) { + RETURN_FALSE; + } + + if (rowLast < -1) { + RETURN_FALSE; + } + + if (colLast < -1) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + xlSheetSetAutoFitArea(sheet, rowFirst, colFirst, rowLast, colLast); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::printRepeatRows() + Gets repeated rows on each page from rowFirst to rowLast. + Returns 0 if repeated rows aren't found. */ +EXCEL_METHOD(Sheet, printRepeatRows) +{ + zval *object = getThis(); + SheetHandle sheet; + int rowFirst, rowLast; + + if (ZEND_NUM_ARGS()) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + if (!xlSheetPrintRepeatRows(sheet, &rowFirst, &rowLast)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "row_start", rowFirst); + add_assoc_long(return_value, "row_end", rowLast); +} +/* }}} */ + +/* {{{ proto long ExcelSheet::printRepeatCols() + Gets repeated columns on each page from colFirst to colLast. + Returns 0 if repeated columns aren't found. */ +EXCEL_METHOD(Sheet, printRepeatCols) +{ + zval *object = getThis(); + SheetHandle sheet; + int colFirst, colLast; + + if (ZEND_NUM_ARGS()) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + if (!xlSheetPrintRepeatCols(sheet, &colFirst, &colLast)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "col_start", colFirst); + add_assoc_long(return_value, "col_end", colLast); +} +/* }}} */ + +/* {{{ proto long ExcelSheet::printArea() + Gets the print area. Returns 0 if print area isn't found. */ +EXCEL_METHOD(Sheet, printArea) +{ + zval *object = getThis(); + SheetHandle sheet; + int rowFirst, colFirst, rowLast, colLast; + + SHEET_FROM_OBJECT(sheet, object); + + if (!xlSheetPrintArea(sheet, &rowFirst, &colFirst, &rowLast, &colLast)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "row_start", rowFirst); + add_assoc_long(return_value, "col_start", colFirst); + add_assoc_long(return_value, "row_end", rowLast); + add_assoc_long(return_value, "col_end", colLast); +} +/* }}} */ + +#endif + +#if LIBXL_VERSION >= 0x03070000 +/* {{{ proto void ExcelSheet::setProtect(bool protect, string password, int enhancedProtection) + Protects the sheet with password and enchanced parameters below. It is possible to combine a few EnhancedProtection values with operator |. */ +EXCEL_METHOD(Sheet, setProtect) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_bool protect; + zend_string *password_zs = zend_string_init("", sizeof("")-1, 0); + zend_long enhancedProtection = PROT_DEFAULT; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "b|Sl", &protect, &password_zs, &enhancedProtection) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + xlSheetSetProtectEx(sheet, protect, ZSTR_VAL(password_zs), enhancedProtection); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::table() + Gets the table parameters by index. */ +EXCEL_METHOD(Sheet, table) +{ + zval *object = getThis(); + SheetHandle sheet; + int index=0, rowFirst, rowLast, colFirst, colLast, headerRowCount, totalsRowCount; + const char *name; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + // @todo check for XLSX format + if (!(name = xlSheetTable(sheet, index, &rowFirst, &rowLast, &colFirst, &colLast, &headerRowCount, &totalsRowCount))) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_string(return_value, "name", (char *)name); + add_assoc_long(return_value, "row_first", rowFirst); + add_assoc_long(return_value, "col_first", colFirst); + add_assoc_long(return_value, "row_last", rowLast); + add_assoc_long(return_value, "col_last", colLast); + add_assoc_long(return_value, "header_row_count", headerRowCount); + add_assoc_long(return_value, "totals_row_count", totalsRowCount); +} +/* }}} */ + +/* {{{ proto long ExcelSheet::setTabColor([int color]) + Sets the color for the sheet's tab. */ +EXCEL_METHOD(Sheet, setTabColor) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_long color = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &color) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + // @todo check for XLSX format + xlSheetSetTabColor(sheet, color); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::autoFilter() + Returns the AutoFilter. Creates it if it doesn't exist. */ +EXCEL_METHOD(Sheet, autoFilter) +{ + zval *object = getThis(); + excel_autofilter_object *obj; + SheetHandle sheet; + + SHEET_FROM_OBJECT(sheet, object); + + // @todo check for XLSX format + AutoFilterHandle ah = xlSheetAutoFilter(sheet); + + ZVAL_OBJ(return_value, excel_object_new_autofilter(excel_ce_autofilter)); + obj = Z_EXCEL_AUTOFILTER_OBJ_P(return_value); + obj->autofilter = ah; + obj->sheet = sheet; + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::applyFilter() + Applies the AutoFilter to the sheet. */ +EXCEL_METHOD(Sheet, applyFilter) +{ + zval *object = getThis(); + SheetHandle sheet; + + SHEET_FROM_OBJECT(sheet, object); + + // @todo check for XLSX format + xlSheetApplyFilter(sheet); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::removeFilter() + Removes the AutoFilter from the sheet. */ +EXCEL_METHOD(Sheet, removeFilter) +{ + zval *object = getThis(); + SheetHandle sheet; + + SHEET_FROM_OBJECT(sheet, object); + + // @todo check for XLSX format + xlSheetRemoveFilter(sheet); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::addIgnoredError() + Adds the ignored error for specified range. It allows to hide green triangles on left sides of cells. */ +EXCEL_METHOD(Sheet, addIgnoredError) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_long iError, rowFirst=0, colFirst=0, rowLast=0, colLast=0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|llll", &iError, &rowFirst, &colFirst, &rowLast, &colLast) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + if (!xlSheetAddIgnoredError(sheet, rowFirst, colFirst, rowLast, colLast, iError)) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long ExcelSheet::writeError() + Writes error into the cell with specified format. If format equals 0 then format is ignored. */ +EXCEL_METHOD(Sheet, writeError) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_long iError=0, row=0, col=0; + zval *oformat = NULL; + FormatHandle format = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lllo", &row, &col, &iError, &oformat, excel_ce_format) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + FORMAT_FROM_OBJECT(format, oformat); + + xlSheetWriteError(sheet, row, col, iError, format); +} +/* }}} */ + +/* {{{ proto long ExcelSheet::removeComment() + Removes a comment from the cell (only for xls format). */ +EXCEL_METHOD(Sheet, removeComment) +{ + zval *object = getThis(); + SheetHandle sheet; + zend_long row=0, col=0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &row, &col) == FAILURE) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, object); + + xlSheetRemoveComment(sheet, row, col); +} +/* }}} */ + +/* {{{ proto ExcelAutoFilter ExcelAutoFilter::__construct(ExcelSheet sheet) + Sheet Constructor. */ +EXCEL_METHOD(AutoFilter, __construct) +{ + AutoFilterHandle afh; + SheetHandle sheet; + zval *object = getThis(); + excel_autofilter_object *obj; + zval *zsheet = NULL; + + PHP_EXCEL_ERROR_HANDLING(); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zsheet, excel_ce_sheet) == FAILURE) { + PHP_EXCEL_RESTORE_ERRORS(); + return; + } + PHP_EXCEL_RESTORE_ERRORS(); + + if (!zsheet) { + RETURN_FALSE; + } + + SHEET_FROM_OBJECT(sheet, zsheet); + + obj = Z_EXCEL_AUTOFILTER_OBJ_P(object); + + afh = xlSheetAutoFilter(sheet); + + if (!afh) { + RETURN_FALSE; + } + + obj->sheet = sheet; + obj->autofilter = afh; +} +/* }}} */ + +/* {{{ proto long AutoFilter::getRef() + Gets the cell range of AutoFilter with header. Returns 0 if error. */ +EXCEL_METHOD(AutoFilter, getRef) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + int rowFirst=0, colFirst=0, rowLast=0, colLast=0; + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + if (!xlAutoFilterGetRef(autofilter, &rowFirst, &colFirst, &rowLast, &colLast)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "row_first", rowFirst); + add_assoc_long(return_value, "col_first", colFirst); + add_assoc_long(return_value, "row_last", rowLast); + add_assoc_long(return_value, "col_last", rowLast); +} +/* }}} */ + +/* {{{ proto long AutoFilter::setRef() + Sets the cell range of AutoFilter with header. */ +EXCEL_METHOD(AutoFilter, setRef) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + zend_long rowFirst=0, rowLast=0, colFirst=0, colLast=0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &rowFirst, &rowLast, &colFirst, &colLast) == FAILURE) { + RETURN_FALSE; + } + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + xlAutoFilterSetRef(autofilter, rowFirst, rowLast, colFirst, colLast); +} +/* }}} */ + +/* {{{ proto long AutoFilter::column() + Returns the AutoFilter column by zero-based index. Creates it if it doesn't exist. */ +EXCEL_METHOD(AutoFilter, column) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + zend_long colId; + excel_filtercolumn_object *obj; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &colId) == FAILURE) { + RETURN_FALSE; + } + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + FilterColumnHandle fch = xlAutoFilterColumn(autofilter, colId); + + ZVAL_OBJ(return_value, excel_object_new_filtercolumn(excel_ce_filtercolumn)); + obj = Z_EXCEL_FILTERCOLUMN_OBJ_P(return_value); + obj->autofilter = autofilter; + obj->filtercolumn = fch; + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long AutoFilter::columnSize() + Returns the number of specified AutoFilter columns which have a filter information. */ +EXCEL_METHOD(AutoFilter, columnSize) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + RETURN_LONG(xlAutoFilterColumnSize(autofilter)); +} +/* }}} */ + +/* {{{ proto long AutoFilter::columnByIndex() + Returns the specified AutoFilter column which have a filter information by index. */ +EXCEL_METHOD(AutoFilter, columnByIndex) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + excel_filtercolumn_object *obj; + zend_long index; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { + RETURN_FALSE; + } + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + FilterColumnHandle fch = xlAutoFilterColumnByIndex(autofilter, index); + + ZVAL_OBJ(return_value, excel_object_new_filtercolumn(excel_ce_filtercolumn)); + obj = Z_EXCEL_FILTERCOLUMN_OBJ_P(return_value); + obj->autofilter = autofilter; + obj->filtercolumn = fch; + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long AutoFilter::getSortRange() + Gets the whole range of data to sort. Returns 0 if error. */ +EXCEL_METHOD(AutoFilter, getSortRange) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + int rowFirst=0, rowLast=0, colFirst=0, colLast=0; + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + if (!xlAutoFilterGetSortRange(autofilter, &rowFirst, &rowLast, &colFirst, &colLast)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "row_first", rowFirst); + add_assoc_long(return_value, "row_last", rowLast); + add_assoc_long(return_value, "col_first", colFirst); + add_assoc_long(return_value, "col_last", rowLast); +} +/* }}} */ + +/* {{{ proto long AutoFilter::getSort() + Gets the zero-based index of sorted column in AutoFilter and its sort order. Returns 0 if error. */ +EXCEL_METHOD(AutoFilter, getSort) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + int columnIndex, descending; + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + if (!xlAutoFilterGetSort(autofilter, &columnIndex, &descending)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "column_index", columnIndex); + add_assoc_long(return_value, "descending", descending); +} +/* }}} */ + +/* {{{ proto long AutoFilter::setSort() + Sets the sorted column in AutoFilter by zero-based index and its sort order. Returns 0 if error. */ +EXCEL_METHOD(AutoFilter, setSort) +{ + zval *object = getThis(); + AutoFilterHandle autofilter; + zend_long columnIndex; + zend_bool descending; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lb", &columnIndex, &descending) == FAILURE) { + RETURN_FALSE; + } + + AUTOFILTER_FROM_OBJECT(autofilter, object); + + if (!xlAutoFilterSetSort(autofilter, columnIndex, descending)) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto ExcelFilterColumn ExcelFilterColumn::__construct(ExcelAutoFilter autofilter) + Sheet Constructor. */ +EXCEL_METHOD(FilterColumn, __construct) +{ + FilterColumnHandle fch; + AutoFilterHandle autofilter; + zval *object = getThis(); + excel_filtercolumn_object *obj; + zval *zautofilter = NULL; + zend_long colId; + + PHP_EXCEL_ERROR_HANDLING(); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &zautofilter, excel_ce_autofilter, &colId) == FAILURE) { + PHP_EXCEL_RESTORE_ERRORS(); + return; + } + PHP_EXCEL_RESTORE_ERRORS(); + + if (!zautofilter) { + RETURN_FALSE; + } + + AUTOFILTER_FROM_OBJECT(autofilter, zautofilter); + + obj = Z_EXCEL_FILTERCOLUMN_OBJ_P(object); + + fch = xlAutoFilterColumn(autofilter, colId); + + if (!fch) { + RETURN_FALSE; + } + + obj->filtercolumn = fch; + obj->autofilter = autofilter; +} +/* }}} */ + +/* {{{ proto long FilterColumn::index() + Returns the zero-based index of this AutoFilter column. */ +EXCEL_METHOD(FilterColumn, index) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + RETURN_LONG(xlFilterColumnIndex(filtercolumn)); +} +/* }}} */ + +/* {{{ proto long FilterColumn::filterType() + Returns the filter type of this AutoFilter column. */ +EXCEL_METHOD(FilterColumn, filterType) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + RETURN_LONG(xlFilterColumnFilterType(filtercolumn)); +} +/* }}} */ + +/* {{{ proto long FilterColumn::filterSize() + Returns the number of filter values. */ +EXCEL_METHOD(FilterColumn, filterSize) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + RETURN_LONG(xlFilterColumnFilterSize(filtercolumn)); +} +/* }}} */ + +/* {{{ proto long FilterColumn::filter() + Returns the filter value by index. */ +EXCEL_METHOD(FilterColumn, filter) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + zend_long filterIndex; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &filterIndex) == FAILURE) { + RETURN_FALSE; + } + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + RETURN_STRING((char *)xlFilterColumnFilter(filtercolumn, filterIndex)); +} +/* }}} */ + +/* {{{ proto long FilterColumn::addFilter() + Adds the filter value. */ +EXCEL_METHOD(FilterColumn, addFilter) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + zend_string *filtervalue_zs = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &filtervalue_zs) == FAILURE) { + RETURN_FALSE; + } + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + xlFilterColumnAddFilter(filtercolumn, ZSTR_VAL(filtervalue_zs)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long FilterColumn::getTop10() + Gets the number of top or bottom items: */ +EXCEL_METHOD(FilterColumn, getTop10) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + double value; + int top, percent; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + if (!xlFilterColumnGetTop10(filtercolumn, &value, &top, &percent)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_double(return_value, "value", value); + add_assoc_bool(return_value, "top", top); + add_assoc_bool(return_value, "percent", percent); +} +/* }}} */ + +/* {{{ proto long FilterColumn::setTop10() + Sets the number of top or bottom items: */ +EXCEL_METHOD(FilterColumn, setTop10) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + double value; + zend_bool top = 1, percent = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "dbb", &value, &top, &percent) == FAILURE) { + RETURN_FALSE; + } + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + xlFilterColumnSetTop10(filtercolumn, value, top, percent); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long FilterColumn::getCustomFilter() + Gets the custom filter criteria: */ +EXCEL_METHOD(FilterColumn, getCustomFilter) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + int op1, op2, andOp; + char *v1 = NULL, *v2 = NULL; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + if (!xlFilterColumnGetCustomFilter(filtercolumn, &op1, &v1, &op2, &v2, &andOp)) { + RETURN_FALSE; + } + + array_init(return_value); + add_assoc_long(return_value, "operator_1", op1); + add_assoc_string(return_value, "value_1", v1); + add_assoc_long(return_value, "operator_2", op2); + add_assoc_string(return_value, "value_2", v2); + add_assoc_bool(return_value, "and_operator", andOp); +} +/* }}} */ + +/* {{{ proto long FilterColumn::setCustomFilter() + Sets the custom filter criteria: */ +EXCEL_METHOD(FilterColumn, setCustomFilter) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + zend_long op1, op2 = -1; + zend_string *v1 = NULL, *v2 = NULL; + zend_bool andOp = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lS|lSb", &op1, &v1, &op2, &v2, &andOp) == FAILURE) { + RETURN_FALSE; + } + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); + + EXCEL_NON_EMPTY_STRING(v1) + + if (op2 == -1 || !v2) { + xlFilterColumnSetCustomFilter(filtercolumn, op1, ZSTR_VAL(v1)); + RETURN_TRUE; + } + + EXCEL_NON_EMPTY_STRING(v2) + + xlFilterColumnSetCustomFilterEx(filtercolumn, op1, ZSTR_VAL(v1), op2, ZSTR_VAL(v2), andOp); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long FilterColumn::clear() + Clear the filter criteria. */ +EXCEL_METHOD(FilterColumn, clear) +{ + zval *object = getThis(); + FilterColumnHandle filtercolumn; + + FILTERCOLUMN_FROM_OBJECT(filtercolumn, object); - xlSheetCellFormat(sheet, 0, 0); - err = (char *)xlBookErrorMessage(book); - if (err) { - // on Linux - if (!strcmp(err, "can't get access to format in row 0 in trial version")) { - RETURN_FALSE; - } - // on Win - if (!strcmp(err, "can't access row 0 in trial version")) { - RETURN_FALSE; - } - } + xlFilterColumnClear(filtercolumn); RETURN_TRUE; } /* }}} */ +#endif -#if LIBXL_VERSION >= 0x03060200 -/* {{{ proto void ExcelSheet::setAutoFitArea(int rowFirst, int colFirst, int rowLast, int colLast) - Sets the borders for autofit column widths feature. - The function xlSheetSetCol() with -1 width value will - affect only to the specified limited area. */ -EXCEL_METHOD(Sheet, setAutoFitArea) +#if LIBXL_VERSION >= 0x03080000 +/* {{{ proto long ExcelBook::addPictureAsLink(str filename, bool insert) + Adds a picture to the workbook as link (only for xlsx files) */ +EXCEL_METHOD(Book, addPictureAsLink) { zval *object = getThis(); - SheetHandle sheet; - long rowFirst=0, colFirst=0, rowLast=-1, colLast=-1; + BookHandle book; + zend_string *filename; + zend_bool insert = 0; + long result; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|llll", &rowFirst, &rowLast, &colFirst, &colLast) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &filename, &insert) == FAILURE) { RETURN_FALSE; } - if (rowFirst < 0) { - RETURN_FALSE; - } + BOOK_FROM_OBJECT(book, object); - if (colFirst < 0) { + result = xlBookAddPictureAsLink(book, ZSTR_VAL(filename), insert); + + if (-1 == result) { + php_error_docref(NULL, E_WARNING, "Could not add picture as link."); RETURN_FALSE; } - if (rowLast < -1) { + RETURN_LONG(result); +} +/* }}} */ + +/* {{{ proto bool ExcelBook::moveSheet(int src_index, int dest_index) + Moves a sheet with specified index to a new position. Returns 0 if error occurs. */ +EXCEL_METHOD(Book, moveSheet) +{ + BookHandle book; + zval *object = getThis(); + zend_long src_index, dest_index; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &src_index, &dest_index) == FAILURE) { RETURN_FALSE; } - if (colLast < -1) { + BOOK_FROM_OBJECT(book, object); + + if (!xlBookMoveSheet(book, src_index, dest_index)) { RETURN_FALSE; } - SHEET_FROM_OBJECT(sheet, object); - - xlSheetSetAutoFitArea(sheet, rowFirst, colFirst, rowLast, colLast); RETURN_TRUE; } /* }}} */ -/* {{{ proto long ExcelSheet::printRepeatRows() - Gets repeated rows on each page from rowFirst to rowLast. - Returns 0 if repeated rows aren't found. */ -EXCEL_METHOD(Sheet, printRepeatRows) +/* {{{ proto bool Sheet::addDataValidation() + Adds a data validation for the specified range (only for xlsx files). */ +EXCEL_METHOD(Sheet, addDataValidation) { zval *object = getThis(); SheetHandle sheet; - int rowFirst, rowLast; - if (ZEND_NUM_ARGS()) { + zend_long type, op, row_first, row_last, col_first, col_last; + zend_string *val_1, *val_2; + zend_bool allow_blank = 1, hide_dropdown=0, show_inputmessage = 1, show_errormessage = 1; + zend_string *prompt_title = zend_string_init("", sizeof("")-1, 0), *prompt = zend_string_init("", sizeof("")-1, 0); + zend_string *error_title = zend_string_init("", sizeof("")-1, 0), *error = zend_string_init("", sizeof("")-1, 0); + zend_long error_style = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "llllllS|SbbbbSSSSl", &type, &op, &row_first, &row_last, \ + &col_first, &col_last, &val_1, &val_2, &allow_blank, &hide_dropdown, &show_inputmessage, \ + &show_errormessage, &prompt_title, &prompt, &error_title, &error, &error_style) == FAILURE) { RETURN_FALSE; } - SHEET_FROM_OBJECT(sheet, object); + if (!val_1 || ZSTR_LEN(val_1) < 1) { + php_error_docref(NULL, E_WARNING, "The first value can not be empty."); + RETURN_FALSE; + } - if (!xlSheetPrintRepeatRows(sheet, &rowFirst, &rowLast)) { + if ((op == VALIDATION_OP_BETWEEN || op == VALIDATION_OP_NOTBETWEEN) && ZEND_NUM_ARGS() < 8) { + php_error_docref(NULL, E_WARNING, "The second value can not be null when used with (not) between operator."); RETURN_FALSE; } - array_init(return_value); - add_assoc_long(return_value, "row_start", rowFirst); - add_assoc_long(return_value, "row_end", rowLast); + SHEET_FROM_OBJECT(sheet, object); + + xlSheetAddDataValidationEx(sheet, type, op, row_first, row_last, col_first, col_last, ZSTR_VAL(val_1), \ + ZSTR_VAL(val_2), allow_blank, hide_dropdown, show_inputmessage, show_errormessage, \ + ZSTR_VAL(prompt_title), ZSTR_VAL(prompt), ZSTR_VAL(error_title), ZSTR_VAL(error), error_style); + + RETURN_TRUE; } /* }}} */ -/* {{{ proto long ExcelSheet::printRepeatCols() - Gets repeated columns on each page from colFirst to colLast. - Returns 0 if repeated columns aren't found. */ -EXCEL_METHOD(Sheet, printRepeatCols) +/* {{{ proto bool Sheet::addDataValidationDouble() + Adds a data validation for the specified range with double or date values for the relational operator + (only for xlsx files). See parameters in the xlSheetAddDataValidation() method. */ +EXCEL_METHOD(Sheet, addDataValidationDouble) { zval *object = getThis(); SheetHandle sheet; - int colFirst, colLast; - if (ZEND_NUM_ARGS()) { + zend_long type, op, row_first, row_last, col_first, col_last; + double val_1, val_2; + zend_bool allow_blank = 1, hide_dropdown=0, show_inputmessage = 1, show_errormessage = 1; + zend_string *prompt_title = zend_string_init("", sizeof("")-1, 0), *prompt = zend_string_init("", sizeof("")-1, 0); + zend_string *error_title = zend_string_init("", sizeof("")-1, 0), *error = zend_string_init("", sizeof("")-1, 0); + zend_long error_style = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllllld|dbbbbSSSSl", &type, &op, &row_first, &row_last, \ + &col_first, &col_last, &val_1, &val_2, &allow_blank, &hide_dropdown, &show_inputmessage, \ + &show_errormessage, &prompt_title, &prompt, &error_title, &error, &error_style) == FAILURE) { RETURN_FALSE; } - SHEET_FROM_OBJECT(sheet, object); - - if (!xlSheetPrintRepeatCols(sheet, &colFirst, &colLast)) { + if ((op == VALIDATION_OP_BETWEEN || op == VALIDATION_OP_NOTBETWEEN) && ZEND_NUM_ARGS() < 8) { + php_error_docref(NULL, E_WARNING, "The second value can not be null when used with (not) between operator."); RETURN_FALSE; } - array_init(return_value); - add_assoc_long(return_value, "col_start", colFirst); - add_assoc_long(return_value, "col_end", colLast); + SHEET_FROM_OBJECT(sheet, object); + + xlSheetAddDataValidationDoubleEx(sheet, type, op, row_first, row_last, col_first, col_last, val_1, \ + val_2, allow_blank, hide_dropdown, show_inputmessage, show_errormessage, \ + ZSTR_VAL(prompt_title), ZSTR_VAL(prompt), ZSTR_VAL(error_title), ZSTR_VAL(error), error_style); + + RETURN_TRUE; } /* }}} */ -/* {{{ proto long ExcelSheet::printArea() - Gets the print area. Returns 0 if print area isn't found. */ -EXCEL_METHOD(Sheet, printArea) +/* {{{ proto bool Sheet::removeDataValidations() + Removes all data validations for the sheet (only for xlsx files). */ +EXCEL_METHOD(Sheet, removeDataValidations) { zval *object = getThis(); SheetHandle sheet; - int rowFirst, colFirst, rowLast, colLast; SHEET_FROM_OBJECT(sheet, object); + xlSheetRemoveDataValidations(sheet); - if (!xlSheetPrintArea(sheet, &rowFirst, &colFirst, &rowLast, &colLast)) { - RETURN_FALSE; - } - - array_init(return_value); - add_assoc_long(return_value, "row_start", rowFirst); - add_assoc_long(return_value, "col_start", colFirst); - add_assoc_long(return_value, "row_end", rowLast); - add_assoc_long(return_value, "col_end", colLast); + RETURN_TRUE; } /* }}} */ - #endif -#if PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) -# define PHP_EXCEL_ARGINFO -# else -# define PHP_EXCEL_ARGINFO static -#endif -PHP_EXCEL_ARGINFO +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_requiresKey, 0, 0, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_load, 0, 0, 1) ZEND_ARG_INFO(0, data) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_loadFile, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_save, 0, 0, 0) ZEND_ARG_INFO(0, filename) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getSheet, 0, 0, 0) ZEND_ARG_INFO(0, sheet) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getSheetByName, 0, 0, 1) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, case_insensitive) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_deleteSheet, 0, 0, 1) ZEND_ARG_INFO(0, sheet) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_activeSheet, 0, 0, 0) ZEND_ARG_INFO(0, sheet) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addSheet, 0, 0, 1) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_copySheet, 0, 0, 2) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, sheet_number) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_sheetCount, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getError, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addFont, 0, 0, 0) ZEND_ARG_OBJ_INFO(0, font, ExcelFont, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addFormat, 0, 0, 0) ZEND_ARG_OBJ_INFO(0, format, ExcelFormat, 1) ZEND_END_ARG_INFO() -#ifdef HAVE_LIBXL_243_PLUS -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getAllFormats, 0, 0, 0) ZEND_END_ARG_INFO() -#endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addCustomFormat, 0, 0, 1) ZEND_ARG_INFO(0, format) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getCustomFormat, 0, 0, 1) ZEND_ARG_INFO(0, id) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_packDate, 0, 0, 1) ZEND_ARG_INFO(0, timestamp) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_packDateValues, 0, 0, 6) ZEND_ARG_INFO(0, year) ZEND_ARG_INFO(0, month) @@ -4845,351 +5643,288 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_packDateValues, 0, 0, 6) ZEND_ARG_INFO(0, sec) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_unpackDate, 0, 0, 1) ZEND_ARG_INFO(0, date) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getActiveSheet, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getDefaultFont, 0, 0, 0) ZEND_END_ARG_INFO() -#if LIBXL_VERSION >= 0x03050300 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_isDate1904, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setDate1904, 0, 0, 1) ZEND_ARG_INFO(0, date_type) ZEND_END_ARG_INFO() -#endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setDefaultFont, 0, 0, 2) ZEND_ARG_INFO(0, font) ZEND_ARG_INFO(0, font_size) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setLocale, 0, 0, 1) ZEND_ARG_INFO(0, locale) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book___construct, 0, 0, 0) ZEND_ARG_INFO(0, license_name) ZEND_ARG_INFO(0, license_key) ZEND_ARG_INFO(0, excel_2007) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setActiveSheet, 0, 0, 1) ZEND_ARG_INFO(0, sheet) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addPictureFromFile, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addPictureFromString, 0, 0, 1) ZEND_ARG_INFO(0, data) ZEND_END_ARG_INFO() -#ifdef LIBXL_VERSION -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_rgbMode, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setRGBMode, 0, 0, 1) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_colorPack, 0, 0, 3) ZEND_ARG_INFO(0, r) ZEND_ARG_INFO(0, g) ZEND_ARG_INFO(0, b) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_colorUnpack, 0, 0, 1) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03020000 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setRefR1C1, 0, 0, 1) ZEND_ARG_INFO(0, active) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_biffVersion, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getRefR1C1, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getPicture, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getNumPictures, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_insertSheet, 0, 0, 2) ZEND_ARG_INFO(0, index) ZEND_ARG_INFO(0, name) ZEND_ARG_OBJ_INFO(0, sheet, ExcelSheet, 0) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03050401 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_isTemplate, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_setTemplate, 0, 0, 1) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getRightToLeft, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setRightToLeft, 0, 0, 1) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03060000 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_sheetType, 0, 0, 1) ZEND_ARG_INFO(0, sheet) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getLibXlVersion, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getPhpExcelVersion, 0, 0, 0) +ZEND_END_ARG_INFO() + +#if LIBXL_VERSION >= 0x03080300 +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_loadInfo, 0, 0, 1) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_getSheetName, 0, 0, 1) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() #endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_size, 0, 0, 0) ZEND_ARG_INFO(0, size) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_italics, 0, 0, 0) ZEND_ARG_INFO(0, size) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_strike, 0, 0, 0) ZEND_ARG_INFO(0, strike) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_bold, 0, 0, 0) ZEND_ARG_INFO(0, bold) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_color, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_mode, 0, 0, 0) ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_underline, 0, 0, 0) ZEND_ARG_INFO(0, underline_style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font_name, 0, 0, 0) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format___construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, book, ExcelBook, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Font___construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, book, ExcelBook, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_setFont, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, font, ExcelFont, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_getFont, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_numberFormat, 0, 0, 0) ZEND_ARG_INFO(0, format) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_horizontalAlign, 0, 0, 0) ZEND_ARG_INFO(0, align_mode) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_verticalAlign, 0, 0, 0) ZEND_ARG_INFO(0, align_mode) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_wrap, 0, 0, 0) ZEND_ARG_INFO(0, wrap) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_rotate, 0, 0, 0) ZEND_ARG_INFO(0, angle) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_indent, 0, 0, 0) ZEND_ARG_INFO(0, indent) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_shrinkToFit, 0, 0, 0) ZEND_ARG_INFO(0, shrink) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderLeftStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderLeftColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderRightStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderRightColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderTopStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderTopColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderBottomStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderBottomColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderDiagonalStyle, 0, 0, 0) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_borderDiagonalColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_fillPattern, 0, 0, 0) ZEND_ARG_INFO(0, patern) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_patternForegroundColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_patternBackgroundColor, 0, 0, 0) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_locked, 0, 0, 0) ZEND_ARG_INFO(0, locked) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Format_hidden, 0, 0, 0) ZEND_ARG_INFO(0, hidden) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet___construct, 0, 0, 2) ZEND_ARG_OBJ_INFO(0, book, ExcelBook, 0) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_cellType, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_cellFormat, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -#ifdef HAVE_LIBXL_243_PLUS -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setCellFormat, 0, 0, 3) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_ARG_OBJ_INFO(0, format, ExcelFormat, 0) ZEND_END_ARG_INFO() -#endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_readRow, 0, 0, 1) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, start_col) @@ -5197,7 +5932,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_readRow, 0, 0, 1) ZEND_ARG_INFO(0, read_formula) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_readCol, 0, 0, 1) ZEND_ARG_INFO(0, column) ZEND_ARG_INFO(0, start_row) @@ -5205,7 +5939,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_readCol, 0, 0, 1) ZEND_ARG_INFO(0, read_formula) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_read, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) @@ -5213,7 +5946,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_read, 0, 0, 2) ZEND_ARG_INFO(0, read_formula) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_write, 0, 0, 3) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) @@ -5222,7 +5954,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_write, 0, 0, 3) ZEND_ARG_INFO(0, datatype) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeRow, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, data) @@ -5230,7 +5961,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeRow, 0, 0, 2) ZEND_ARG_OBJ_INFO(0, format, ExcelFormat, 1) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeCol, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, data) @@ -5239,59 +5969,61 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeCol, 0, 0, 2) ZEND_ARG_INFO(0, data_type) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_isFormula, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_isDate, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_insertRow, 0, 0, 2) ZEND_ARG_INFO(0, row_first) ZEND_ARG_INFO(0, row_last) +#if LIBXL_VERSION >= 0x03080301 + ZEND_ARG_INFO(0, update_named_ranges) +#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_insertCol, 0, 0, 2) ZEND_ARG_INFO(0, col_first) ZEND_ARG_INFO(0, col_last) +#if LIBXL_VERSION >= 0x03080301 + ZEND_ARG_INFO(0, update_named_ranges) +#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeRow, 0, 0, 2) ZEND_ARG_INFO(0, row_first) ZEND_ARG_INFO(0, row_last) +#if LIBXL_VERSION >= 0x03080301 + ZEND_ARG_INFO(0, update_named_ranges) +#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeCol, 0, 0, 2) ZEND_ARG_INFO(0, col_first) ZEND_ARG_INFO(0, col_last) +#if LIBXL_VERSION >= 0x03080301 + ZEND_ARG_INFO(0, update_named_ranges) +#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_colWidth, 0, 0, 1) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_rowHeight, 0, 0, 1) ZEND_ARG_INFO(0, row) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_readComment, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeComment, 0, 0, 6) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) @@ -5301,7 +6033,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeComment, 0, 0, 6) ZEND_ARG_INFO(0, height) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setColWidth, 0, 0, 3) ZEND_ARG_INFO(0, column_start) ZEND_ARG_INFO(0, column_end) @@ -5310,7 +6041,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setColWidth, 0, 0, 3) ZEND_ARG_OBJ_INFO(0, format, ExcelFormat, 1) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setRowHeight, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, height) @@ -5318,13 +6048,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setRowHeight, 0, 0, 2) ZEND_ARG_INFO(0, hidden) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getMerge, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMerge, 0, 0, 4) ZEND_ARG_INFO(0, row_start) ZEND_ARG_INFO(0, row_end) @@ -5332,84 +6060,70 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMerge, 0, 0, 4) ZEND_ARG_INFO(0, col_end) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_deleteMerge, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addPictureScaled, 0, 0, 4) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_ARG_INFO(0, pic_id) ZEND_ARG_INFO(0, scale) -#if LIBXL_VERSION >= 0x03040000 ZEND_ARG_INFO(0, x_offset) ZEND_ARG_INFO(0, y_offset) -#endif #if LIBXL_VERSION >= 0x03060300 ZEND_ARG_INFO(0, pos) #endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addPictureDim, 0, 0, 5) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_ARG_INFO(0, pic_id) ZEND_ARG_INFO(0, width) ZEND_ARG_INFO(0, height) -#if LIBXL_VERSION >= 0x03040000 ZEND_ARG_INFO(0, x_offset) ZEND_ARG_INFO(0, y_offset) -#endif #if LIBXL_VERSION >= 0x03060300 ZEND_ARG_INFO(0, pos) #endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_horPageBreak, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, break) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_verPageBreak, 0, 0, 2) ZEND_ARG_INFO(0, col) ZEND_ARG_INFO(0, break) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_splitSheet, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_groupRows, 0, 0, 2) ZEND_ARG_INFO(0, start_row) ZEND_ARG_INFO(0, end_row) ZEND_ARG_INFO(0, collapse) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_groupCols, 0, 0, 2) ZEND_ARG_INFO(0, start_column) ZEND_ARG_INFO(0, end_column) ZEND_ARG_INFO(0, collapse) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_clear, 0, 0, 4) ZEND_ARG_INFO(0, row_s) ZEND_ARG_INFO(0, row_e) ZEND_ARG_INFO(0, col_s) - ZEND_ARG_INFO(0, col_s) + ZEND_ARG_INFO(0, col_e) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_copy, 0, 0, 4) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, col) @@ -5417,67 +6131,50 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_copy, 0, 0, 4) ZEND_ARG_INFO(0, to_col) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_firstRow, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_lastRow, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_firstCol, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_lastCol, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_displayGridlines, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_printGridlines, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setDisplayGridlines, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintGridlines, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_zoom, 0, 0, 0) ZEND_END_ARG_INFO() -#if LIBXL_VERSION >= 0x03020300 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_isHidden, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setHidden, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03020400 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getTopLeftView, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setTopLeftView, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_rowColToAddr, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, column) @@ -5485,187 +6182,148 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_rowColToAddr, 0, 0, 2) ZEND_ARG_INFO(0, col_relative) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addrToRowCol, 0, 0, 1) ZEND_ARG_INFO(0, cell_reference) ZEND_END_ARG_INFO() -#endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_zoomPrint, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setZoom, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setZoomPrint, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setLandscape, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_landscape, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_paper, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPaper, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_header, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_footer, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setHeader, 0, 0, 2) ZEND_ARG_INFO(0, header) ZEND_ARG_INFO(0, margin) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setFooter, 0, 0, 2) ZEND_ARG_INFO(0, footer) ZEND_ARG_INFO(0, margin) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_headerMargin, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_footerMargin, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_hcenter, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_vcenter, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setHCenter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setVCenter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_marginLeft, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_marginRight, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_marginTop, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_marginBottom, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMarginLeft, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMarginRight, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMarginTop, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setMarginBottom, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_printHeaders, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintHeaders, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_name, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setName, 0, 0, 1) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_protect, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setProtect, 0, 0, 1) ZEND_ARG_INFO(0, value) +#if LIBXL_VERSION >= 0x03070000 + ZEND_ARG_INFO(0, password) + ZEND_ARG_INFO(0, enhancedProtection) +#endif ZEND_END_ARG_INFO() -#if LIBXL_VERSION >= 0x03010000 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setNamedRange, 0, 0, 5) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, col) ZEND_ARG_INFO(0, to_row) ZEND_ARG_INFO(0, to_col) -#if LIBXL_VERSION >= 0x03050401 ZEND_ARG_INFO(0, scope_id) -#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_delNamedRange, 0, 0, 1) ZEND_ARG_INFO(0, name) -#if LIBXL_VERSION >= 0x03050401 ZEND_ARG_INFO(0, scope_id) -#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintRepeatRows, 0, 0, 2) ZEND_ARG_INFO(0, row_start) ZEND_ARG_INFO(0, row_end) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintRepeatCols, 0, 0, 2) ZEND_ARG_INFO(0, col_start) ZEND_ARG_INFO(0, col_end) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintArea, 0, 0, 4) ZEND_ARG_INFO(0, row_first) ZEND_ARG_INFO(0, row_last) @@ -5673,108 +6331,79 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintArea, 0, 0, 4) ZEND_ARG_INFO(0, col_last) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_clearPrintRepeats, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_clearPrintArea, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getGroupSummaryRight, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getGroupSummaryBelow, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setGroupSummaryBelow, 0, 0, 1) ZEND_ARG_INFO(0, direction) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setGroupSummaryRight, 0, 0, 1) ZEND_ARG_INFO(0, direction) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03020000 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setPrintFit, 0, 0, 2) ZEND_ARG_INFO(0, wPages) ZEND_ARG_INFO(0, hPages) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getPrintFit, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getNamedRange, 0, 0, 1) ZEND_ARG_INFO(0, name) -#if LIBXL_VERSION >= 0x03050401 ZEND_ARG_INFO(0, scope_id) -#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getIndexRange, 0, 0, 1) ZEND_ARG_INFO(0, index) -#if LIBXL_VERSION >= 0x03050401 ZEND_ARG_INFO(0, scope_id) -#endif ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_namedRangeSize, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getVerPageBreak, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getVerPageBreakSize, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getHorPageBreak, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getHorPageBreakSize, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getPictureInfo, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_getNumPictures, 0, 0, 0) ZEND_END_ARG_INFO() -#endif -#if LIBXL_VERSION >= 0x03060000 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_hyperlinkSize, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_hyperlink, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_delHyperlink, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addHyperlink, 0, 0, 5) ZEND_ARG_INFO(0, hyperlink) ZEND_ARG_INFO(0, row_first) @@ -5783,53 +6412,42 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addHyperlink, 0, 0, 5) ZEND_ARG_INFO(0, col_last) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_mergeSize, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_merge, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_delMergeByIndex, 0, 0, 1) ZEND_ARG_INFO(0, index) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_splitInfo, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_colHidden, 0, 0, 1) ZEND_ARG_INFO(0, col) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_rowHidden, 0, 0, 1) ZEND_ARG_INFO(0, row) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setColHidden, 0, 0, 2) ZEND_ARG_INFO(0, col) ZEND_ARG_INFO(0, hidden) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setRowHidden, 0, 0, 2) ZEND_ARG_INFO(0, row) ZEND_ARG_INFO(0, hidden) ZEND_END_ARG_INFO() -#endif -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_isLicensed, 0, 0, 0) ZEND_END_ARG_INFO() #if LIBXL_VERSION >= 0x03060200 -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setAutoFitArea, 0, 0, 0) ZEND_ARG_INFO(0, row_start) ZEND_ARG_INFO(0, row_end) @@ -5837,28 +6455,198 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setAutoFitArea, 0, 0, 0) ZEND_ARG_INFO(0, col_end) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_printRepeatRows, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_printRepeatCols, 0, 0, 0) ZEND_END_ARG_INFO() -PHP_EXCEL_ARGINFO ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_printArea, 0, 0, 0) ZEND_END_ARG_INFO() #endif +#if LIBXL_VERSION >= 0x03070000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_setTabColor, 0, 0, 0) + ZEND_ARG_INFO(0, color) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_table, 0, 0, 1) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addIgnoredError, 0, 0, 1) + ZEND_ARG_INFO(0, iError) + ZEND_ARG_INFO(0, rowFirst) + ZEND_ARG_INFO(0, colFirst) + ZEND_ARG_INFO(0, rowLast) + ZEND_ARG_INFO(0, colLast) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeComment, 0, 0, 2) + ZEND_ARG_INFO(0, row) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_writeError, 0, 0, 0) + ZEND_ARG_INFO(0, row) + ZEND_ARG_INFO(0, col) + ZEND_ARG_INFO(0, iError) + ZEND_ARG_OBJ_INFO(0, format, ExcelFormat, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_applyFilter, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_autoFilter, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeFilter, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter___construct, 0, 0, 0) + ZEND_ARG_OBJ_INFO(0, sheet, ExcelSheet, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_getRef, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_setRef, 0, 0, 0) + ZEND_ARG_INFO(0, row_first) + ZEND_ARG_INFO(0, col_first) + ZEND_ARG_INFO(0, row_last) + ZEND_ARG_INFO(0, col_last) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_column, 0, 0, 1) + ZEND_ARG_INFO(0, colId) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_columnSize, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_columnByIndex, 0, 0, 1) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_getSortRange, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_getSort, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_AutoFilter_setSort, 0, 0, 2) + ZEND_ARG_INFO(0, columnIndex) + ZEND_ARG_INFO(0, descending) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn___construct, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, autoFilter, AutoFilter, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_index, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_filterType, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_filterSize, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_filter, 0, 0, 1) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_addFilter, 0, 0, 1) + ZEND_ARG_INFO(0, filterValue) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_getTop10, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_setTop10, 0, 0, 1) + ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, top) + ZEND_ARG_INFO(0, percent) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_getCustomFilter, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_setCustomFilter, 0, 0, 2) + ZEND_ARG_INFO(0, operator_1) + ZEND_ARG_INFO(0, value_1) + ZEND_ARG_INFO(0, operator_2) + ZEND_ARG_INFO(0, value_2) + ZEND_ARG_INFO(0, andOp) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_FilterColumn_clear, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + +#if LIBXL_VERSION >= 0x03080000 +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_addPictureAsLink, 0, 0, 1) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, insert) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Book_moveSheet, 0, 0, 2) + ZEND_ARG_INFO(0, src_index) + ZEND_ARG_INFO(0, dest_index) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addDataValidation, 0, 0, 7) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, op) + ZEND_ARG_INFO(0, row_first) + ZEND_ARG_INFO(0, row_last) + ZEND_ARG_INFO(0, col_first) + ZEND_ARG_INFO(0, col_last) + ZEND_ARG_INFO(0, val_1) + ZEND_ARG_INFO(0, val_2) + ZEND_ARG_INFO(0, allow_blank) + ZEND_ARG_INFO(0, hide_dropdown) + ZEND_ARG_INFO(0, show_inputmessage) + ZEND_ARG_INFO(0, show_errormessage) + ZEND_ARG_INFO(0, prompt_title) + ZEND_ARG_INFO(0, prompt) + ZEND_ARG_INFO(0, error_title) + ZEND_ARG_INFO(0, error) + ZEND_ARG_INFO(0, error_style) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_addDataValidationDouble, 0, 0, 7) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, op) + ZEND_ARG_INFO(0, row_first) + ZEND_ARG_INFO(0, row_last) + ZEND_ARG_INFO(0, col_first) + ZEND_ARG_INFO(0, col_last) + ZEND_ARG_INFO(0, val_1) + ZEND_ARG_INFO(0, val_2) + ZEND_ARG_INFO(0, allow_blank) + ZEND_ARG_INFO(0, hide_dropdown) + ZEND_ARG_INFO(0, show_inputmessage) + ZEND_ARG_INFO(0, show_errormessage) + ZEND_ARG_INFO(0, prompt_title) + ZEND_ARG_INFO(0, prompt) + ZEND_ARG_INFO(0, error_title) + ZEND_ARG_INFO(0, error) + ZEND_ARG_INFO(0, error_style) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeDataValidations, 0, 0, 0) +ZEND_END_ARG_INFO() +#endif + #define EXCEL_ME(class_name, function_name, arg_info, flags) \ - PHP_ME( Excel ## class_name, function_name, arg_info, flags) + PHP_ME(Excel ## class_name, function_name, arg_info, flags) zend_function_entry excel_funcs_book[] = { + EXCEL_ME(Book, requiresKey, arginfo_Book_requiresKey, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) EXCEL_ME(Book, addFont, arginfo_Book_addFont, 0) EXCEL_ME(Book, addFormat, arginfo_Book_addFormat, 0) -#ifdef HAVE_LIBXL_243_PLUS EXCEL_ME(Book, getAllFormats, arginfo_Book_getAllFormats, 0) -#endif EXCEL_ME(Book, getError, arginfo_Book_getError, 0) EXCEL_ME(Book, loadFile, arginfo_Book_loadFile, 0) EXCEL_ME(Book, load, arginfo_Book_load, 0) @@ -5882,31 +6670,31 @@ zend_function_entry excel_funcs_book[] = { EXCEL_ME(Book, setLocale, arginfo_Book_setLocale, 0) EXCEL_ME(Book, addPictureFromFile, arginfo_Book_addPictureFromFile, 0) EXCEL_ME(Book, addPictureFromString, arginfo_Book_addPictureFromString, 0) -#ifdef LIBXL_VERSION EXCEL_ME(Book, rgbMode, arginfo_Book_rgbMode, 0) EXCEL_ME(Book, setRGBMode, arginfo_Book_setRGBMode, 0) EXCEL_ME(Book, colorPack, arginfo_Book_colorPack, 0) EXCEL_ME(Book, colorUnpack, arginfo_Book_colorUnpack, 0) -#endif -#if LIBXL_VERSION >= 0x03050300 EXCEL_ME(Book, isDate1904, arginfo_Book_isDate1904, 0) EXCEL_ME(Book, setDate1904, arginfo_Book_setDate1904, 0) -#endif EXCEL_ME(Book, __construct, arginfo_Book___construct, 0) -#if LIBXL_VERSION >= 0x03020000 EXCEL_ME(Book, biffVersion, arginfo_Book_biffVersion, 0) EXCEL_ME(Book, setRefR1C1, arginfo_Book_setRefR1C1, 0) EXCEL_ME(Book, getRefR1C1, arginfo_Book_getRefR1C1, 0) EXCEL_ME(Book, getPicture, arginfo_Book_getPicture, 0) EXCEL_ME(Book, getNumPictures, arginfo_Book_getNumPictures, 0) EXCEL_ME(Book, insertSheet, arginfo_Book_insertSheet, 0) -#endif -#if LIBXL_VERSION >= 0x03050401 EXCEL_ME(Book, isTemplate, arginfo_Book_isTemplate, 0) EXCEL_ME(Book, setTemplate, arginfo_Book_setTemplate, 0) -#endif -#if LIBXL_VERSION >= 0x03060000 EXCEL_ME(Book, sheetType, arginfo_Book_sheetType, 0) + EXCEL_ME(Book, getLibXlVersion, arginfo_Book_getLibXlVersion, 0) + EXCEL_ME(Book, getPhpExcelVersion, arginfo_Book_getPhpExcelVersion, 0) +#if LIBXL_VERSION >= 0x03080000 + EXCEL_ME(Book, addPictureAsLink, arginfo_Book_addPictureAsLink, 0) + EXCEL_ME(Book, moveSheet, arginfo_Book_moveSheet, 0) +#endif +#if LIBXL_VERSION >= 0x03080300 + EXCEL_ME(Book, loadInfo, arginfo_Book_loadInfo, 0) + EXCEL_ME(Book, getSheetName, arginfo_Book_getSheetName, 0) #endif {NULL, NULL, NULL} }; @@ -5915,9 +6703,7 @@ zend_function_entry excel_funcs_sheet[] = { EXCEL_ME(Sheet, __construct, arginfo_Sheet___construct, 0) EXCEL_ME(Sheet, cellType, arginfo_Sheet_cellType, 0) EXCEL_ME(Sheet, cellFormat, arginfo_Sheet_cellFormat, 0) -#ifdef HAVE_LIBXL_243_PLUS EXCEL_ME(Sheet, setCellFormat, arginfo_Sheet_setCellFormat, 0) -#endif EXCEL_ME(Sheet, read, arginfo_Sheet_read, 0) EXCEL_ME(Sheet, readRow, arginfo_Sheet_readRow, 0) EXCEL_ME(Sheet, readCol, arginfo_Sheet_readCol, 0) @@ -5988,7 +6774,6 @@ zend_function_entry excel_funcs_sheet[] = { EXCEL_ME(Sheet, setName, arginfo_Sheet_setName, 0) EXCEL_ME(Sheet, protect, arginfo_Sheet_protect, 0) EXCEL_ME(Sheet, setProtect, arginfo_Sheet_setProtect, 0) -#if LIBXL_VERSION >= 0x03010000 EXCEL_ME(Sheet, setNamedRange, arginfo_Sheet_setNamedRange, 0) EXCEL_ME(Sheet, delNamedRange, arginfo_Sheet_delNamedRange, 0) EXCEL_ME(Sheet, setPrintRepeatRows, arginfo_Sheet_setPrintRepeatRows, 0) @@ -6000,8 +6785,6 @@ zend_function_entry excel_funcs_sheet[] = { EXCEL_ME(Sheet, setGroupSummaryBelow, arginfo_Sheet_setGroupSummaryBelow, 0) EXCEL_ME(Sheet, getGroupSummaryBelow, arginfo_Sheet_getGroupSummaryBelow, 0) EXCEL_ME(Sheet, setGroupSummaryRight, arginfo_Sheet_setGroupSummaryRight, 0) -#endif -#if LIBXL_VERSION >= 0x03020000 EXCEL_ME(Sheet, setPrintFit, arginfo_Sheet_setPrintFit, 0) EXCEL_ME(Sheet, getPrintFit, arginfo_Sheet_getPrintFit, 0) EXCEL_ME(Sheet, getNamedRange, arginfo_Sheet_getNamedRange, 0) @@ -6013,22 +6796,14 @@ zend_function_entry excel_funcs_sheet[] = { EXCEL_ME(Sheet, getHorPageBreakSize, arginfo_Sheet_getHorPageBreakSize, 0) EXCEL_ME(Sheet, getNumPictures, arginfo_Sheet_getNumPictures, 0) EXCEL_ME(Sheet, getPictureInfo, arginfo_Sheet_getPictureInfo, 0) -#endif -#if LIBXL_VERSION >= 0x03020300 EXCEL_ME(Sheet, setHidden, arginfo_Sheet_setHidden, 0) EXCEL_ME(Sheet, isHidden, arginfo_Sheet_isHidden, 0) -#endif -#if LIBXL_VERSION >= 0x03020400 EXCEL_ME(Sheet, setTopLeftView, arginfo_Sheet_setTopLeftView, 0) EXCEL_ME(Sheet, getTopLeftView, arginfo_Sheet_getTopLeftView, 0) EXCEL_ME(Sheet, rowColToAddr, arginfo_Sheet_rowColToAddr, 0) EXCEL_ME(Sheet, addrToRowCol, arginfo_Sheet_addrToRowCol, 0) -#endif -#if LIBXL_VERSION >= 0x03050401 EXCEL_ME(Sheet, getRightToLeft, arginfo_Sheet_getRightToLeft, 0) EXCEL_ME(Sheet, setRightToLeft, arginfo_Sheet_setRightToLeft, 0) -#endif -#if LIBXL_VERSION >= 0x03060000 EXCEL_ME(Sheet, hyperlinkSize, arginfo_Sheet_hyperlinkSize, 0) EXCEL_ME(Sheet, hyperlink, arginfo_Sheet_hyperlink, 0) EXCEL_ME(Sheet, delHyperlink, arginfo_Sheet_delHyperlink, 0) @@ -6042,13 +6817,26 @@ zend_function_entry excel_funcs_sheet[] = { EXCEL_ME(Sheet, rowHidden, arginfo_Sheet_rowHidden, 0) EXCEL_ME(Sheet, setColHidden, arginfo_Sheet_setColHidden, 0) EXCEL_ME(Sheet, setRowHidden, arginfo_Sheet_setRowHidden, 0) -#endif EXCEL_ME(Sheet, isLicensed, arginfo_Sheet_isLicensed, 0) #if LIBXL_VERSION >= 0x03060200 EXCEL_ME(Sheet, setAutoFitArea, arginfo_Sheet_setAutoFitArea, 0) EXCEL_ME(Sheet, printRepeatRows, arginfo_Sheet_printRepeatRows, 0) EXCEL_ME(Sheet, printRepeatCols, arginfo_Sheet_printRepeatCols, 0) EXCEL_ME(Sheet, printArea, arginfo_Sheet_printArea, 0) +#endif +#if LIBXL_VERSION >= 0x03070000 + EXCEL_ME(Sheet, setTabColor, arginfo_Sheet_setTabColor, 0) + EXCEL_ME(Sheet, applyFilter, arginfo_Sheet_applyFilter, 0) + EXCEL_ME(Sheet, autoFilter, arginfo_Sheet_autoFilter, 0) + EXCEL_ME(Sheet, removeFilter, arginfo_Sheet_removeFilter, 0) + EXCEL_ME(Sheet, table, arginfo_Sheet_table, 0) + EXCEL_ME(Sheet, writeError, arginfo_Sheet_writeError, 0) + EXCEL_ME(Sheet, addIgnoredError, arginfo_Sheet_addIgnoredError, 0) +#endif +#if LIBXL_VERSION >= 0x03080000 + EXCEL_ME(Sheet, addDataValidation, arginfo_Sheet_addDataValidation, 0) + EXCEL_ME(Sheet, addDataValidationDouble, arginfo_Sheet_addDataValidationDouble, 0) + EXCEL_ME(Sheet, removeDataValidations, arginfo_Sheet_removeDataValidations, 0) #endif {NULL, NULL, NULL} }; @@ -6097,16 +6885,50 @@ zend_function_entry excel_funcs_format[] = { {NULL, NULL, NULL} }; +#if LIBXL_VERSION >= 0x03070000 +zend_function_entry excel_funcs_autofilter[] = { + EXCEL_ME(AutoFilter, __construct, arginfo_AutoFilter___construct, 0) + EXCEL_ME(AutoFilter, getRef, arginfo_AutoFilter_getRef, 0) + EXCEL_ME(AutoFilter, setRef, arginfo_AutoFilter_setRef, 0) + EXCEL_ME(AutoFilter, column, arginfo_AutoFilter_column, 0) + EXCEL_ME(AutoFilter, columnSize, arginfo_AutoFilter_columnSize, 0) + EXCEL_ME(AutoFilter, columnByIndex, arginfo_AutoFilter_columnByIndex, 0) + EXCEL_ME(AutoFilter, getSortRange, arginfo_AutoFilter_getSortRange, 0) + EXCEL_ME(AutoFilter, getSort, arginfo_AutoFilter_getSort, 0) + EXCEL_ME(AutoFilter, setSort, arginfo_AutoFilter_setSort, 0) + {NULL, NULL, NULL} +}; + +zend_function_entry excel_funcs_filtercolumn[] = { + EXCEL_ME(FilterColumn, __construct, arginfo_FilterColumn___construct, 0) + EXCEL_ME(FilterColumn, index, arginfo_FilterColumn_index, 0) + EXCEL_ME(FilterColumn, filterType, arginfo_FilterColumn_filterType, 0) + EXCEL_ME(FilterColumn, filterSize, arginfo_FilterColumn_filterSize, 0) + EXCEL_ME(FilterColumn, filter, arginfo_FilterColumn_filter, 0) + EXCEL_ME(FilterColumn, addFilter, arginfo_FilterColumn_addFilter, 0) + EXCEL_ME(FilterColumn, getTop10, arginfo_FilterColumn_getTop10, 0) + EXCEL_ME(FilterColumn, setTop10, arginfo_FilterColumn_setTop10, 0) + EXCEL_ME(FilterColumn, getCustomFilter, arginfo_FilterColumn_getCustomFilter, 0) + EXCEL_ME(FilterColumn, setCustomFilter, arginfo_FilterColumn_setCustomFilter, 0) + EXCEL_ME(FilterColumn, clear, arginfo_FilterColumn_clear, 0) + {NULL, NULL, NULL} +}; +#endif + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(excel) { REGISTER_INI_ENTRIES(); - REGISTER_EXCEL_CLASS(Book, book, NULL); - REGISTER_EXCEL_CLASS(Sheet, sheet, NULL); - REGISTER_EXCEL_CLASS(Format, format, excel_format_object_clone); - REGISTER_EXCEL_CLASS(Font, font, excel_font_object_clone); + REGISTER_EXCEL_CLASS(Book, book, NULL); + REGISTER_EXCEL_CLASS(Sheet, sheet, NULL); + REGISTER_EXCEL_CLASS(Format, format, excel_format_object_clone); + REGISTER_EXCEL_CLASS(Font, font, excel_font_object_clone); +#if LIBXL_VERSION >= 0x03070000 + REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); + REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); +#endif REGISTER_EXCEL_CLASS_CONST_LONG(font, "NORMAL", SCRIPT_NORMAL); REGISTER_EXCEL_CLASS_CONST_LONG(font, "SUBSCRIPT", SCRIPT_SUB); @@ -6257,11 +7079,7 @@ PHP_MINIT_FUNCTION(excel) REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_GRAY50", FILLPATTERN_GRAY50); REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_GRAY75", FILLPATTERN_GRAY75); REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_GRAY25", FILLPATTERN_GRAY25); -#ifdef HAVE_LIBXL_243_PLUS REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_HORSTRIPE", FILLPATTERN_HORSTRIPE); -#else - REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_HORSTRIPE", FILLPATTEN_HORSTRIPE); -#endif REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_VERSTRIPE", FILLPATTERN_VERSTRIPE); REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_REVDIAGSTRIPE", FILLPATTERN_REVDIAGSTRIPE); REGISTER_EXCEL_CLASS_CONST_LONG(format, "FILLPATTERN_DIAGSTRIPE", FILLPATTERN_DIAGSTRIPE); @@ -6290,6 +7108,7 @@ PHP_MINIT_FUNCTION(excel) REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "ERRORTYPE_VALUE", ERRORTYPE_VALUE); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "ERRORTYPE_DIV_0", ERRORTYPE_DIV_0); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "ERRORTYPE_NULL", ERRORTYPE_NULL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "ERRORTYPE_NOERROR", ERRORTYPE_NOERROR); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PAPER_DEFAULT", PAPER_DEFAULT); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PAPER_LETTER", PAPER_LETTER); @@ -6333,7 +7152,7 @@ PHP_MINIT_FUNCTION(excel) REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PAPER_FANFOLD", PAPER_FANFOLD); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PAPER_GERMAN_STD_FANFOLD", PAPER_GERMAN_STD_FANFOLD); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PAPER_GERMAN_LEGAL_FANFOLD", PAPER_GERMAN_LEGAL_FANFOLD); -#if LIBXL_VERSION >= 0x03020000 + REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_PNG", PICTURETYPE_PNG); REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_JPEG", PICTURETYPE_JPEG); REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_WMF", PICTURETYPE_WMF); @@ -6341,24 +7160,96 @@ PHP_MINIT_FUNCTION(excel) REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_EMF", PICTURETYPE_EMF); REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_PICT", PICTURETYPE_PICT); REGISTER_EXCEL_CLASS_CONST_LONG(book, "PICTURETYPE_TIFF", PICTURETYPE_TIFF); -#endif -#if LIBXL_VERSION >= 0x03050401 + REGISTER_EXCEL_CLASS_CONST_LONG(book, "SCOPE_UNDEFINED", SCOPE_UNDEFINED); REGISTER_EXCEL_CLASS_CONST_LONG(book, "SCOPE_WORKBOOK", SCOPE_WORKBOOK); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "RIGHT_TO_LEFT", 1); REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "LEFT_TO_RIGHT", 0); -#endif -#if LIBXL_VERSION >= 0x03060000 + REGISTER_EXCEL_CLASS_CONST_LONG(book, "SHEETTYPE_SHEET", SHEETTYPE_SHEET); REGISTER_EXCEL_CLASS_CONST_LONG(book, "SHEETTYPE_CHART", SHEETTYPE_CHART); REGISTER_EXCEL_CLASS_CONST_LONG(book, "SHEETTYPE_UNKNOWN", SHEETTYPE_UNKNOWN); -#endif + #if LIBXL_VERSION >= 0x03060300 REGISTER_EXCEL_CLASS_CONST_LONG(book, "POSITION_MOVE_AND_SIZE", POSITION_MOVE_AND_SIZE); REGISTER_EXCEL_CLASS_CONST_LONG(book, "POSITION_ONLY_MOVE", POSITION_ONLY_MOVE); REGISTER_EXCEL_CLASS_CONST_LONG(book, "POSITION_ABSOLUTE", POSITION_ABSOLUTE); #endif +#if LIBXL_VERSION >= 0x03070000 + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_DEFAULT", PROT_DEFAULT); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_ALL", PROT_ALL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_OBJECTS", PROT_OBJECTS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_SCENARIOS", PROT_SCENARIOS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_FORMAT_CELLS", PROT_FORMAT_CELLS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_FORMAT_COLUMNS", PROT_FORMAT_COLUMNS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_FORMAT_ROWS", PROT_FORMAT_ROWS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_INSERT_COLUMNS", PROT_INSERT_COLUMNS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_INSERT_ROWS", PROT_INSERT_ROWS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_INSERT_HYPERLINKS", PROT_INSERT_HYPERLINKS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_DELETE_COLUMNS", PROT_DELETE_COLUMNS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_DELETE_ROWS", PROT_DELETE_ROWS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_SEL_LOCKED_CELLS", PROT_SEL_LOCKED_CELLS); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_SORT", PROT_SORT); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_AUTOFILTER", PROT_AUTOFILTER); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_PIVOTTABLES", PROT_PIVOTTABLES); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "PROT_SEL_UNLOCKED_CELLS", PROT_SEL_UNLOCKED_CELLS); + + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "SHEETSTATE_VISIBLE", SHEETSTATE_VISIBLE); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "SHEETSTATE_HIDDEN", SHEETSTATE_HIDDEN); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "SHEETSTATE_VERYHIDDEN", SHEETSTATE_VERYHIDDEN); + + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_EVAL_ERROR", IERR_EVAL_ERROR); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_EMPTY_CELLREF", IERR_EMPTY_CELLREF); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_NUMBER_STORED_AS_TEXT", IERR_NUMBER_STORED_AS_TEXT); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_INCONSIST_RANGE", IERR_INCONSIST_RANGE); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_INCONSIST_FMLA", IERR_INCONSIST_FMLA); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_TWODIG_TEXTYEAR", IERR_TWODIG_TEXTYEAR); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_UNLOCK_FMLA", IERR_UNLOCK_FMLA); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "IERR_DATA_VALIDATION", IERR_DATA_VALIDATION); + + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_EQUAL", OPERATOR_EQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_GREATER_THAN", OPERATOR_GREATER_THAN); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_GREATER_THAN_OR_EQUAL", OPERATOR_GREATER_THAN_OR_EQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_LESS_THAN", OPERATOR_LESS_THAN); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_LESS_THAN_OR_EQUAL", OPERATOR_LESS_THAN_OR_EQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "OPERATOR_NOT_EQUAL", OPERATOR_NOT_EQUAL); + + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_VALUE", FILTER_VALUE); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_TOP10", FILTER_TOP10); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_CUSTOM", FILTER_CUSTOM); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_DYNAMIC", FILTER_DYNAMIC); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_COLOR", FILTER_COLOR); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_ICON", FILTER_ICON); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_EXT", FILTER_EXT); + REGISTER_EXCEL_CLASS_CONST_LONG(filtercolumn, "FILTER_NOT_SET", FILTER_NOT_SET); +#endif + +#if LIBXL_VERSION >= 0x03080000 + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_NONE", VALIDATION_TYPE_NONE); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_WHOLE", VALIDATION_TYPE_WHOLE); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_DECIMAL", VALIDATION_TYPE_DECIMAL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_LIST", VALIDATION_TYPE_LIST); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_DATE", VALIDATION_TYPE_DATE); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_TIME", VALIDATION_TYPE_TIME); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_TEXTLENGTH", VALIDATION_TYPE_TEXTLENGTH); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_TYPE_CUSTOM", VALIDATION_TYPE_CUSTOM); + + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_BETWEEN", VALIDATION_OP_BETWEEN); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_NOTBETWEEN", VALIDATION_OP_NOTBETWEEN); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_EQUAL", VALIDATION_OP_EQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_NOTEQUAL", VALIDATION_OP_NOTEQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_LESSTHAN", VALIDATION_OP_LESSTHAN); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_LESSTHANOREQUAL", VALIDATION_OP_LESSTHANOREQUAL); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_GREATERTHAN", VALIDATION_OP_GREATERTHAN); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_OP_GREATERTHANOREQUAL", VALIDATION_OP_GREATERTHANOREQUAL); + + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_ERRSTYLE_STOP", VALIDATION_ERRSTYLE_STOP); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_ERRSTYLE_WARNING", VALIDATION_ERRSTYLE_WARNING); + REGISTER_EXCEL_CLASS_CONST_LONG(sheet, "VALIDATION_ERRSTYLE_INFORMATION", VALIDATION_ERRSTYLE_INFORMATION); +#endif + return SUCCESS; } /* }}} */ diff --git a/package.xml b/package.xml index 1ecbe7f..3eef079 100644 --- a/package.xml +++ b/package.xml @@ -1,57 +1,57 @@ - - -excel - pecl.php.net - excel extension - + + +excel + pecl.php.net + excel extension + This extension uses libXl library to provide API for generating or parsing all Excel files. -libxl is a high-performance mechanism for working with Excel files and is -able to generate output readable on Blackberries, iPhone, Office Products, -Numbers, etc... - - - Ilia Alshanetsky - iliaa - ilia@ilia.ws - yes - - 2016-07-04 - - 1.0.2 - 1.0.2 - - - stable - stable - - PHP - - - Version 1.0.9 - - - - - - - - - - - - - - - - - - - - - +libxl is a high-performance mechanism for working with Excel files and is +able to generate output readable on Blackberries, iPhone, Office Products, +Numbers, etc... + + + Ilia Alshanetsky + iliaa + ilia@ilia.ws + yes + + 2016-07-04 + + 1.0.2 + 1.0.2 + + + stable + stable + + PHP + + - Version 1.0.9 + + + + + + + + + + + + + + + + + + + + + @@ -140,23 +140,26 @@ Numbers, etc... + + + - + - - - - - - 5.2.0 - - - 1.4.0b1 - - - - excel - - - + + + + + + 7.0.0 + + + 1.4.0b1 + + + + excel + + + diff --git a/php_excel.h b/php_excel.h index 7c281c3..8795010 100644 --- a/php_excel.h +++ b/php_excel.h @@ -39,21 +39,10 @@ ZEND_END_MODULE_GLOBALS(excel) #include "TSRM.h" #endif -#if ZEND_MODULE_API_NO >= 20100409 -#ifndef ZEND_ENGINE_2_4 -#define ZEND_ENGINE_2_4 -#endif -#endif - -#if PHP_VERSION_ID >= 50300 # define PHP_EXCEL_ERROR_HANDLING() \ zend_error_handling error_handling; \ - zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); -# define PHP_EXCEL_RESTORE_ERRORS() zend_restore_error_handling(&error_handling TSRMLS_CC); -#else -# define PHP_EXCEL_ERROR_HANDLING() php_set_error_handling(EH_THROW, NULL TSRMLS_CC); -# define PHP_EXCEL_RESTORE_ERRORS() php_std_error_handling(); -#endif + zend_replace_error_handling(EH_THROW, NULL, &error_handling); +# define PHP_EXCEL_RESTORE_ERRORS() zend_restore_error_handling(&error_handling); #ifndef Z_SET_ISREF_P # define Z_SET_ISREF_P(pz) (pz)->is_ref = 1 diff --git a/tests/000.phpt b/tests/000.phpt index ab9d5eb..07ebcc2 100644 --- a/tests/000.phpt +++ b/tests/000.phpt @@ -3,7 +3,7 @@ LibXL licensed version vs trial version test --INI-- date.timezone=America/Toronto --SKIPIF-- - + --FILE-- --FILE-- -unpackDate($x->packDate($tm)); if ($out != $tm) { - echo "source: {$tm} <> res: " . $out . " >> diff: ".($out - $tm)." packed: '".$x->packDate($tm)."'\n"; + echo "[1] source: {$tm} <> res: " . $out . " >> diff: ".($out - $tm)." packed: '".$x->packDate($tm)."'\n"; } } echo "OK\n"; - + for ($i = 0; $i < 1000; $i++) { $tm = time(); //rand(10000000, $t); - + $ed = $x->packDateValues( date('Y', $tm), date('m', $tm), @@ -30,7 +32,9 @@ Excel date pack/unpack tests ); $out = $x->unpackDate($ed); if ($out != $tm) { - echo "source: {$tm} <> res: " . $out . " >> diff: ".($out - $tm)." packed: '".$ed."'\n"; + // known to fail because LibXL packs/unpacks with OS based timezone - not with timezone set in PHP - + // to get this test pass change date.timezone=America/Toronto under --INI-- section to your OS timezone + echo "[2] source: {$tm} <> res: " . $out . " >> diff: ".($out - $tm)." packed: '".$ed."'\n"; } } echo "OK\n"; diff --git a/tests/005.phpt b/tests/005.phpt index 9bcac24..3fe8239 100644 --- a/tests/005.phpt +++ b/tests/005.phpt @@ -3,7 +3,7 @@ Date format tests --INI-- date.timezone=America/Toronto --SKIPIF-- - + --FILE-- --FILE-- -getMessage()); } echo "OK\n"; ?> ---EXPECTF-- +--EXPECT-- string(63) "ExcelFormat::__construct() expects exactly 1 parameter, 0 given" - -Catchable fatal error: Argument 1 passed to ExcelFormat::__construct() must be an instance of ExcelBook, string given in %s on line %d +string(94) "Argument 1 passed to ExcelFormat::__construct() must be an instance of ExcelBook, string given" +OK diff --git a/tests/021.phpt b/tests/021.phpt index 64b529d..616d618 100644 --- a/tests/021.phpt +++ b/tests/021.phpt @@ -5,7 +5,7 @@ date.timezone=America/Toronto --SKIPIF-- --FILE-- -getMessage()); } + echo "OK\n" ?> ---EXPECTF-- +--EXPECT-- string(61) "ExcelFont::__construct() expects exactly 1 parameter, 0 given" - -Catchable fatal error: Argument 1 passed to ExcelFont::__construct() must be an instance of ExcelBook, string given in %s on line %d +string(92) "Argument 1 passed to ExcelFont::__construct() must be an instance of ExcelBook, string given" +OK diff --git a/tests/051.phpt b/tests/051.phpt index 882a06a..103cc72 100644 --- a/tests/051.phpt +++ b/tests/051.phpt @@ -12,6 +12,8 @@ date.timezone=America/Toronto $s->write(1, 1, "Test"); + // fails for LibXl < 3.7.0 + // because setProtect() returns null var_dump( $s->protect(), $s->setProtect(true), @@ -22,6 +24,6 @@ date.timezone=America/Toronto ?> --EXPECT-- bool(false) -NULL +bool(true) bool(true) OK diff --git a/tests/053.phpt b/tests/053.phpt index e527d51..c1143cf 100644 --- a/tests/053.phpt +++ b/tests/053.phpt @@ -26,139 +26,139 @@ date.timezone=America/Toronto --EXPECT-- array(21) { [0]=> - &object(ExcelFormat)#2 (0) { + object(ExcelFormat)#2 (0) { } [1]=> - &object(ExcelFormat)#3 (0) { + object(ExcelFormat)#3 (0) { } [2]=> - &object(ExcelFormat)#4 (0) { + object(ExcelFormat)#4 (0) { } [3]=> - &object(ExcelFormat)#5 (0) { + object(ExcelFormat)#5 (0) { } [4]=> - &object(ExcelFormat)#6 (0) { + object(ExcelFormat)#6 (0) { } [5]=> - &object(ExcelFormat)#7 (0) { + object(ExcelFormat)#7 (0) { } [6]=> - &object(ExcelFormat)#8 (0) { + object(ExcelFormat)#8 (0) { } [7]=> - &object(ExcelFormat)#9 (0) { + object(ExcelFormat)#9 (0) { } [8]=> - &object(ExcelFormat)#10 (0) { + object(ExcelFormat)#10 (0) { } [9]=> - &object(ExcelFormat)#11 (0) { + object(ExcelFormat)#11 (0) { } [10]=> - &object(ExcelFormat)#12 (0) { + object(ExcelFormat)#12 (0) { } [11]=> - &object(ExcelFormat)#13 (0) { + object(ExcelFormat)#13 (0) { } [12]=> - &object(ExcelFormat)#14 (0) { + object(ExcelFormat)#14 (0) { } [13]=> - &object(ExcelFormat)#15 (0) { + object(ExcelFormat)#15 (0) { } [14]=> - &object(ExcelFormat)#16 (0) { + object(ExcelFormat)#16 (0) { } [15]=> - &object(ExcelFormat)#17 (0) { + object(ExcelFormat)#17 (0) { } [16]=> - &object(ExcelFormat)#18 (0) { + object(ExcelFormat)#18 (0) { } [17]=> - &object(ExcelFormat)#19 (0) { + object(ExcelFormat)#19 (0) { } [18]=> - &object(ExcelFormat)#20 (0) { + object(ExcelFormat)#20 (0) { } [19]=> - &object(ExcelFormat)#21 (0) { + object(ExcelFormat)#21 (0) { } [20]=> - &object(ExcelFormat)#22 (0) { + object(ExcelFormat)#22 (0) { } } bool(false) array(23) { [0]=> - &object(ExcelFormat)#20 (0) { + object(ExcelFormat)#20 (0) { } [1]=> - &object(ExcelFormat)#19 (0) { + object(ExcelFormat)#19 (0) { } [2]=> - &object(ExcelFormat)#18 (0) { + object(ExcelFormat)#18 (0) { } [3]=> - &object(ExcelFormat)#17 (0) { + object(ExcelFormat)#17 (0) { } [4]=> - &object(ExcelFormat)#16 (0) { + object(ExcelFormat)#16 (0) { } [5]=> - &object(ExcelFormat)#15 (0) { + object(ExcelFormat)#15 (0) { } [6]=> - &object(ExcelFormat)#14 (0) { + object(ExcelFormat)#14 (0) { } [7]=> - &object(ExcelFormat)#13 (0) { + object(ExcelFormat)#13 (0) { } [8]=> - &object(ExcelFormat)#12 (0) { + object(ExcelFormat)#12 (0) { } [9]=> - &object(ExcelFormat)#11 (0) { + object(ExcelFormat)#11 (0) { } [10]=> - &object(ExcelFormat)#10 (0) { + object(ExcelFormat)#10 (0) { } [11]=> - &object(ExcelFormat)#9 (0) { + object(ExcelFormat)#9 (0) { } [12]=> - &object(ExcelFormat)#8 (0) { + object(ExcelFormat)#8 (0) { } [13]=> - &object(ExcelFormat)#7 (0) { + object(ExcelFormat)#7 (0) { } [14]=> - &object(ExcelFormat)#6 (0) { + object(ExcelFormat)#6 (0) { } [15]=> - &object(ExcelFormat)#5 (0) { + object(ExcelFormat)#5 (0) { } [16]=> - &object(ExcelFormat)#4 (0) { + object(ExcelFormat)#4 (0) { } [17]=> - &object(ExcelFormat)#3 (0) { + object(ExcelFormat)#3 (0) { } [18]=> - &object(ExcelFormat)#2 (0) { + object(ExcelFormat)#2 (0) { } [19]=> - &object(ExcelFormat)#23 (0) { + object(ExcelFormat)#23 (0) { } [20]=> - &object(ExcelFormat)#24 (0) { + object(ExcelFormat)#24 (0) { } [21]=> - &object(ExcelFormat)#25 (0) { + object(ExcelFormat)#25 (0) { } [22]=> - &object(ExcelFormat)#26 (0) { + object(ExcelFormat)#26 (0) { } } OK diff --git a/tests/075.phpt b/tests/075.phpt index 13c43bb..31f62e6 100644 --- a/tests/075.phpt +++ b/tests/075.phpt @@ -1,7 +1,7 @@ --TEST-- Test the ExcelSheet::hyperlinkSize(), ExcelSheet::hyperlink(), ExcelSheet::delHyperlink(), ExcelSheet::addHyperlink() methods introduced in libxl 3.6.0. --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- int(7) } -OK \ No newline at end of file +OK diff --git a/tests/089.phpt b/tests/089.phpt new file mode 100644 index 0000000..7678d6b --- /dev/null +++ b/tests/089.phpt @@ -0,0 +1,37 @@ +--TEST-- +force string behaviout with single quoted strings +--INI-- +date.timezone=America/Toronto +--SKIPIF-- + +--FILE-- +setLocale('UTF-8'); + $xs = new ExcelSheet($xb, 'test'); + + var_dump($xs->write(1, 1, "'=3+4")); + var_dump($xs->write(1, 2, "'")); + var_dump($xs->write(1, 3, "'3")); + + var_dump($xs->isFormula(1, 1)); + var_dump($xs->isFormula(1, 2)); + var_dump($xs->isFormula(1, 3)); + + var_dump($xs->read(1, 1)); + var_dump($xs->read(1, 2)); + var_dump($xs->read(1, 3)); + + echo "OK\n"; +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +string(4) "=3+4" +string(0) "" +string(1) "3" +OK diff --git a/tests/090.phpt b/tests/090.phpt new file mode 100644 index 0000000..9a128f5 --- /dev/null +++ b/tests/090.phpt @@ -0,0 +1,17 @@ +--TEST-- +test Book::setLocale() +--SKIPIF-- + +--FILE-- +setLocale('UTF-8'); + +$sheet = $book->addSheet('Sheet1'); + +echo 'OK'; + +?> +--EXPECT-- +OK diff --git a/tests/091.phpt b/tests/091.phpt new file mode 100644 index 0000000..f411cb6 --- /dev/null +++ b/tests/091.phpt @@ -0,0 +1,34 @@ +--TEST-- +test Book::save() and Book::loadFile() +--SKIPIF-- + +--FILE-- +addSheet('Sheet1'); +$sheet->write(1, 1, 'foo'); +$book->save($tmp_filename); + +$book = new ExcelBook(); +$book->loadFile($tmp_filename); +$sheet = $book->getSheet(0); + +var_dump($sheet->read(1, 1)); + +echo 'OK'; + +?> +--CLEAN-- + +--EXPECT-- +string(3) "foo" +OK diff --git a/tests/092.phpt b/tests/092.phpt new file mode 100644 index 0000000..e694d95 --- /dev/null +++ b/tests/092.phpt @@ -0,0 +1,15 @@ +--TEST-- +Book::getLibXlVersion() +--SKIPIF-- + +--FILE-- +getLibXlVersion()) +); + +?> +--EXPECT-- +bool(true) \ No newline at end of file diff --git a/tests/093.phpt b/tests/093.phpt new file mode 100644 index 0000000..c5b1eaf --- /dev/null +++ b/tests/093.phpt @@ -0,0 +1,15 @@ +--TEST-- +Book::getPhpExcelVersion() +--SKIPIF-- + +--FILE-- +getPhpExcelVersion()) +); + +?> +--EXPECT-- +bool(true) \ No newline at end of file diff --git a/tests/094.phpt b/tests/094.phpt new file mode 100644 index 0000000..927463c --- /dev/null +++ b/tests/094.phpt @@ -0,0 +1,119 @@ +--TEST-- +Sheet::addDataValidation() +--SKIPIF-- + +--FILE-- +addDataValidation( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_BETWEEN, + 1, + 2, + 1, + 2, + '1' + ) + ); + + var_dump( + $sheet->addDataValidation( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_BETWEEN, + 1, + 2, + 1, + 2, + '1', + '3' + ) + ); + + var_dump( + $sheet->addDataValidation( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_BETWEEN, + 1, + 2, + 1, + 2, + '1', + '100', + 1, + 0, + 1, + 1, + 'Prompt_Title', + 'Prompt', + 'Error Title', + 'Error' + ) + ); + + var_dump( + $sheet->addDataValidationDouble( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_BETWEEN, + 1, + 2, + 1, + 2, + '1' + ) + ); + + var_dump( + $sheet->addDataValidationDouble( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_BETWEEN, + 1, + 2, + 1, + 2, + 1, + 2, + 1, + 0, + 1, + 3, + 'Prompt_Title', + 'Prompt', + 'Error Title', + 'Error' + ) + ); + + var_dump( + $sheet->addDataValidation( + \ExcelSheet::VALIDATION_TYPE_WHOLE, + \ExcelSheet::VALIDATION_OP_EQUAL, + 1, + 2, + 1, + 2, + '1' + ) + ); + + var_dump( + $sheet->removeDataValidations() + ); + + echo "OK\n"; + +?> +--EXPECTF-- +Warning: ExcelSheet::addDataValidation(): The second value can not be null when used with (not) between operator. in %s on line %d +bool(false) +bool(true) +bool(true) + +Warning: ExcelSheet::addDataValidationDouble(): The second value can not be null when used with (not) between operator. in %s on line %d +bool(false) +bool(true) +bool(true) +bool(true) +OK \ No newline at end of file diff --git a/tests/095.phpt b/tests/095.phpt new file mode 100644 index 0000000..ac90064 --- /dev/null +++ b/tests/095.phpt @@ -0,0 +1,68 @@ +--TEST-- +Book::moveSheet() +--SKIPIF-- + +--FILE-- +getSheet(0)->name(), + $book->getSheet(1)->name(), + $book->getSheet(2)->name(), + $book->getSheet(3)->name(), + $book->getSheet(4)->name() + ); + + var_dump( + $book->moveSheet(0,2) + ); + + var_dump( + $book->getSheet(0)->name(), + $book->getSheet(1)->name(), + $book->getSheet(2)->name(), + $book->getSheet(3)->name(), + $book->getSheet(4)->name() + ); + + var_dump( + $book->moveSheet(0,3) + ); + + var_dump( + $book->getSheet(0)->name(), + $book->getSheet(1)->name(), + $book->getSheet(2)->name(), + $book->getSheet(3)->name(), + $book->getSheet(4)->name() + ); + + echo "OK\n"; + +?> +--EXPECT-- +string(6) "sheet1" +string(6) "sheet2" +string(6) "sheet3" +string(6) "sheet4" +string(6) "sheet5" +bool(true) +string(6) "sheet2" +string(6) "sheet1" +string(6) "sheet3" +string(6) "sheet4" +string(6) "sheet5" +bool(true) +string(6) "sheet1" +string(6) "sheet3" +string(6) "sheet2" +string(6) "sheet4" +string(6) "sheet5" +OK