mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 08:46:03 +03:00
documentation markdown
This commit is contained in:
parent
b075996eee
commit
8a25f345b8
@ -1,9 +1,9 @@
|
|||||||
# PHPExcel Developer Documentation
|
# PHPExcel Developer Documentation
|
||||||
|
|
||||||
|
|
||||||
## 1. Prerequisites, Installation, FAQ and Links
|
## Prerequisites, Installation, FAQ and Links
|
||||||
|
|
||||||
### 1.1 Software requirements
|
### Software requirements
|
||||||
|
|
||||||
The following software is required to develop using PHPExcel:
|
The following software is required to develop using PHPExcel:
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ The following software is required to develop using PHPExcel:
|
|||||||
|
|
||||||
[^phpzip_footnote]: __php_zip__ is only needed by __PHPExcel_Reader_Excel2007__, __PHPExcel_Writer_Excel2007__ and __PHPExcel_Reader_OOCalc__. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not. You can remove this dependency for writing Excel2007 files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled.
|
[^phpzip_footnote]: __php_zip__ is only needed by __PHPExcel_Reader_Excel2007__, __PHPExcel_Writer_Excel2007__ and __PHPExcel_Reader_OOCalc__. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not. You can remove this dependency for writing Excel2007 files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled.
|
||||||
|
|
||||||
### 1.2 Installation instructions
|
### Installation instructions
|
||||||
|
|
||||||
Installation is quite easy: copy the contents of the Classes folder to any location within your application source directories.
|
Installation is quite easy: copy the contents of the Classes folder to any location within your application source directories.
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ If your web root folder is /var/www/ you may want to create a subfolder called /
|
|||||||
/var/www/Classes/PHPExcel/Cell.php
|
/var/www/Classes/PHPExcel/Cell.php
|
||||||
...
|
...
|
||||||
|
|
||||||
### 1.3 Getting started
|
### Getting started
|
||||||
|
|
||||||
A good way to get started is to run some of the tests included in the download.
|
A good way to get started is to run some of the tests included in the download.
|
||||||
Copy the "Examples" folder next to your "Classes" folder from above so you end up with:
|
Copy the "Examples" folder next to your "Classes" folder from above so you end up with:
|
||||||
@ -44,11 +44,11 @@ http://example.com/Tests/02types.php
|
|||||||
|
|
||||||
Note: It may be necessary to modify the include/require statements at the beginning of each of the test scripts if your "Classes" folder from above is named differently.
|
Note: It may be necessary to modify the include/require statements at the beginning of each of the test scripts if your "Classes" folder from above is named differently.
|
||||||
|
|
||||||
### 1.4 Useful links and tools
|
### Useful links and tools
|
||||||
|
|
||||||
There are some links and tools which are very useful when developing using PHPExcel. Please refer to the [PHPExcel CodePlex pages][2] for an update version of the list below.
|
There are some links and tools which are very useful when developing using PHPExcel. Please refer to the [PHPExcel CodePlex pages][2] for an update version of the list below.
|
||||||
|
|
||||||
#### 1.4.1 OpenXML / SpreadsheetML
|
#### OpenXML / SpreadsheetML
|
||||||
|
|
||||||
- __File format documentation__
|
- __File format documentation__
|
||||||
[http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm][3]
|
[http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm][3]
|
||||||
@ -59,7 +59,7 @@ There are some links and tools which are very useful when developing using PHPEx
|
|||||||
- __OpenXML Package Explorer__
|
- __OpenXML Package Explorer__
|
||||||
[http://www.codeplex.com/PackageExplorer/][6]
|
[http://www.codeplex.com/PackageExplorer/][6]
|
||||||
|
|
||||||
#### 1.4.2 Frequently asked questions
|
#### Frequently asked questions
|
||||||
|
|
||||||
The up-to-date F.A.Q. page for PHPExcel can be found on [http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements][7].
|
The up-to-date F.A.Q. page for PHPExcel can be found on [http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements][7].
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ The short answer is that PHPExcel uses a measure where padding is included. See
|
|||||||
|
|
||||||
Thanks to peterrlynch for the following advice on resolving issues between the [PHPExcel autoloader and Joomla Autoloader][17]
|
Thanks to peterrlynch for the following advice on resolving issues between the [PHPExcel autoloader and Joomla Autoloader][17]
|
||||||
|
|
||||||
#### 1.4.3 Tutorials
|
#### Tutorials
|
||||||
|
|
||||||
- __English PHPExcel tutorial__
|
- __English PHPExcel tutorial__
|
||||||
[http://openxmldeveloper.org][18]
|
[http://openxmldeveloper.org][18]
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
### Schematical
|
### Schematical
|
||||||
|
|
||||||
|
![01-schematic.png](./images/01-schematic.png "")
|
||||||
|
|
||||||
### Lazy Loader
|
### Lazy Loader
|
||||||
|
|
||||||
@ -39,6 +39,9 @@ On its own, PHPExcel does not provide the functionality to read from or write to
|
|||||||
|
|
||||||
By default, the PHPExcel package provides some readers and writers, including one for the Open XML spreadsheet format (a.k.a. Excel 2007 file format). You are not limited to the default readers and writers, as you are free to implement the PHPExcel_Writer_IReader and PHPExcel_Writer_IWriter interface in a custom class.
|
By default, the PHPExcel package provides some readers and writers, including one for the Open XML spreadsheet format (a.k.a. Excel 2007 file format). You are not limited to the default readers and writers, as you are free to implement the PHPExcel_Writer_IReader and PHPExcel_Writer_IWriter interface in a custom class.
|
||||||
|
|
||||||
|
![02-readers-writers.png](./images/02-readers-writers.png "")
|
||||||
|
|
||||||
|
|
||||||
### Fluent interfaces
|
### Fluent interfaces
|
||||||
|
|
||||||
PHPExcel supports fluent interfaces in most locations. This means that you can easily "chain"" calls to specific methods without requiring a new PHP statement. For example, take the following code:
|
PHPExcel supports fluent interfaces in most locations. This means that you can easily "chain"" calls to specific methods without requiring a new PHP statement. For example, take the following code:
|
||||||
|
33
Documentation/markdown/Overview/03-Creating-a-Spreadsheet.md
Normal file
33
Documentation/markdown/Overview/03-Creating-a-Spreadsheet.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# PHPExcel Developer Documentation
|
||||||
|
|
||||||
|
## Creating a spreadsheet
|
||||||
|
|
||||||
|
### The PHPExcel class
|
||||||
|
|
||||||
|
The PHPExcel class is the core of PHPExcel. It contains references to the contained worksheets, document security settings and document meta data.
|
||||||
|
|
||||||
|
To simplify the PHPExcel concept: the PHPExcel class represents your workbook.
|
||||||
|
|
||||||
|
Typically, you will create a workbook in one of two ways, either by loading it from a spreadsheet file, or creating it manually. A third option, though less commonly used, is cloning an existing workbook that has been created using one of the previous two methods.
|
||||||
|
|
||||||
|
#### Loading a Workbook from a file
|
||||||
|
|
||||||
|
Details of the different spreadsheet formats supported, and the options available to read them into a PHPExcel object are described fully in the PHPExcel User Documentation - Reading Spreadsheet Files document.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
|
/** Load $inputFileName to a PHPExcel Object **/
|
||||||
|
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Creating a new workbook
|
||||||
|
|
||||||
|
If you want to create a new workbook, rather than load one from file, then you simply need to instantiate it as a new PHPExcel object.
|
||||||
|
|
||||||
|
```php
|
||||||
|
/** Create a new PHPExcel Object **/
|
||||||
|
$objPHPExcel = new PHPExcel();
|
||||||
|
```
|
||||||
|
|
||||||
|
A new workbook will always be created with a single worksheet.
|
139
Documentation/markdown/Overview/04-Configuration-Settings.md
Normal file
139
Documentation/markdown/Overview/04-Configuration-Settings.md
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
# PHPExcel Developer Documentation
|
||||||
|
|
||||||
|
## Configuration Settings
|
||||||
|
|
||||||
|
Once you have included the PHPExcel files in your script, but before instantiating a PHPExcel object or loading a workbook file, there are a number of configuration options that can be set which will affect the subsequent behaviour of the script.
|
||||||
|
|
||||||
|
### Cell Caching
|
||||||
|
|
||||||
|
PHPExcel uses an average of about 1k/cell in your worksheets, so large workbooks can quickly use up available memory. Cell caching provides a mechanism that allows PHPExcel to maintain the cell objects in a smaller size of memory, on disk, or in APC, memcache or Wincache, rather than in PHP memory. This allows you to reduce the memory usage for large workbooks, although at a cost of speed to access cell data.
|
||||||
|
|
||||||
|
By default, PHPExcel still holds all cell objects in memory, but you can specify alternatives. To enable cell caching, you must call the PHPExcel_Settings::setCacheStorageMethod() method, passing in the caching method that you wish to use.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory;
|
||||||
|
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
||||||
|
```
|
||||||
|
|
||||||
|
setCacheStorageMethod() will return a boolean true on success, false on failure (for example if trying to cache to APC when APC is not enabled).
|
||||||
|
|
||||||
|
A separate cache is maintained for each individual worksheet, and is automatically created when the worksheet is instantiated based on the caching method and settings that you have configured. You cannot change the configuration settings once you have started to read a workbook, or have created your first worksheet.
|
||||||
|
|
||||||
|
Currently, the following caching methods are available.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_in_memory
|
||||||
|
|
||||||
|
The default. If you don't initialise any caching method, then this is the method that PHPExcel will use. Cell objects are maintained in PHP memory as at present.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized
|
||||||
|
|
||||||
|
Using this caching method, cells are held in PHP memory as an array of serialized objects, which reduces the memory footprint with minimal performance overhead.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip
|
||||||
|
|
||||||
|
Like cache_in_memory_serialized, this method holds cells in PHP memory as an array of serialized objects, but gzipped to reduce the memory usage still further, although access to read or write a cell is slightly slower.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_igbinary
|
||||||
|
|
||||||
|
Uses PHPs igbinary extension (if its available) to serialize cell objects in memory. This is normally faster and uses less memory than standard PHP serialization, but isnt available in most hosting environments.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_discISAM
|
||||||
|
|
||||||
|
When using cache_to_discISAM all cells are held in a temporary disk file, with only an index to their location in that file maintained in PHP memory. This is slower than any of the cache_in_memory methods, but significantly reduces the memory footprint. By default, PHPExcel will use PHP's temp directory for the cache file, but you can specify a different directory when initialising cache_to_discISAM.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_discISAM;
|
||||||
|
$cacheSettings = array(
|
||||||
|
'dir' => '/usr/local/tmp'
|
||||||
|
);
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||||
|
```
|
||||||
|
|
||||||
|
The temporary disk file is automatically deleted when your script terminates.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp
|
||||||
|
|
||||||
|
Like cache_to_discISAM, when using cache_to_phpTemp all cells are held in the php://temp I/O stream, with only an index to their location maintained in PHP memory. In PHP, the php://memory wrapper stores data in the memory: php://temp behaves similarly, but uses a temporary file for storing the data when a certain memory limit is reached. The default is 1 MB, but you can change this when initialising cache_to_phpTemp.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
|
||||||
|
$cacheSettings = array(
|
||||||
|
'memoryCacheSize' => '8MB'
|
||||||
|
);
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||||
|
```
|
||||||
|
|
||||||
|
The php://temp file is automatically deleted when your script terminates.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_apc
|
||||||
|
|
||||||
|
When using cache_to_apc, cell objects are maintained in APC with only an index maintained in PHP memory to identify that the cell exists. By default, an APC cache timeout of 600 seconds is used, which should be enough for most applications: although it is possible to change this when initialising cache_to_APC.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_APC;
|
||||||
|
$cacheSettings = array(
|
||||||
|
'cacheTime' => 600
|
||||||
|
);
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||||
|
```
|
||||||
|
|
||||||
|
When your script terminates all entries will be cleared from APC, regardless of the cacheTime value, so it cannot be used for persistent storage using this mechanism.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_memcache
|
||||||
|
|
||||||
|
When using cache_to_memcache, cell objects are maintained in memcache with only an index maintained in PHP memory to identify that the cell exists.
|
||||||
|
|
||||||
|
By default, PHPExcel looks for a memcache server on localhost at port 11211. It also sets a memcache timeout limit of 600 seconds. If you are running memcache on a different server or port, then you can change these defaults when you initialise cache_to_memcache:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
|
||||||
|
$cacheSettings = array(
|
||||||
|
'memcacheServer' => 'localhost',
|
||||||
|
'memcachePort' => 11211,
|
||||||
|
'cacheTime' => 600
|
||||||
|
);
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||||
|
```
|
||||||
|
|
||||||
|
When your script terminates all entries will be cleared from memcache, regardless of the cacheTime value, so it cannot be used for persistent storage using this mechanism.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_wincache
|
||||||
|
|
||||||
|
When using cache_to_wincache, cell objects are maintained in Wincache with only an index maintained in PHP memory to identify that the cell exists. By default, a Wincache cache timeout of 600 seconds is used, which should be enough for most applications: although it is possible to change this when initialising cache_to_wincache.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_wincache;
|
||||||
|
$cacheSettings = array(
|
||||||
|
'cacheTime' => 600
|
||||||
|
);
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
|
||||||
|
```
|
||||||
|
|
||||||
|
When your script terminates all entries will be cleared from Wincache, regardless of the cacheTime value, so it cannot be used for persistent storage using this mechanism.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_sqlite
|
||||||
|
|
||||||
|
Uses an SQLite 2 "in-memory"" database for caching cell data. Unlike other caching methods, neither cells nor an index are held in PHP memory - an indexed database table makes it unnecessary to hold any index in PHP memory, which makes this the most memory-efficient of the cell caching methods.
|
||||||
|
|
||||||
|
#### PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
|
||||||
|
|
||||||
|
Uses an SQLite 3 "in-memory" database for caching cell data. Unlike other caching methods, neither cells nor an index are held in PHP memory - an indexed database table makes it unnecessary to hold any index in PHP memory, which makes this the most memory-efficient of the cell caching methods.
|
||||||
|
|
||||||
|
|
||||||
|
### Language/Locale
|
||||||
|
|
||||||
|
Some localisation elements have been included in PHPExcel. You can set a locale by changing the settings. To set the locale to Brazilian Portuguese you would use:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$locale = 'pt_br';
|
||||||
|
$validLocale = PHPExcel_Settings::setLocale($locale);
|
||||||
|
if (!$validLocale) {
|
||||||
|
echo 'Unable to set locale to '.$locale." - reverting to en_us<br />\n";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If Brazilian Portuguese language files aren't available, then the Portuguese will be enabled instead: if Portuguese language files aren't available, then the setLocale() method will return an error, and American English (en_us) settings will be used throughout.
|
||||||
|
|
||||||
|
More details of the features available once a locale has been set, including a list of the languages and locales currently supported, can be found in the section of this document entitled "Locale Settings for Formulae".
|
||||||
|
|
@ -1,240 +1,5 @@
|
|||||||
# PHPExcel Developer Documentation
|
# PHPExcel Developer Documentation
|
||||||
|
|
||||||
|
|
||||||
## 1. Prerequisites
|
|
||||||
|
|
||||||
### 1.1 Software requirements
|
|
||||||
|
|
||||||
The following software is required to develop using PHPExcel:
|
|
||||||
|
|
||||||
- PHP version 5.2.0 or newer
|
|
||||||
- PHP extension php_zip enabled [^phpzip_footnote]
|
|
||||||
- PHP extension php_xml enabled
|
|
||||||
- PHP extension php_gd2 enabled (if not compiled in)
|
|
||||||
|
|
||||||
[^phpzip_footnote]: ____php_zip__ is only needed by __PHPExcel_Reader_Excel2007__, __PHPExcel_Writer_Excel2007__ and __PHPExcel_Reader_OOCalc__. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not.You can remove this dependency for writing Excel2007 files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled.
|
|
||||||
|
|
||||||
### 1.2 Installation instructions
|
|
||||||
|
|
||||||
Installation is quite easy: copy the contents of the Classes folder to any location within your application source directories.
|
|
||||||
|
|
||||||
*Example:*
|
|
||||||
|
|
||||||
If your web root folder is /var/www/ you may want to create a subfolder called /var/www/Classes/ and copy the files into that folder so you end up with files:
|
|
||||||
|
|
||||||
/var/www/Classes/PHPExcel.php
|
|
||||||
/var/www/Classes/PHPExcel/Calculation.php
|
|
||||||
/var/www/Classes/PHPExcel/Cell.php
|
|
||||||
...
|
|
||||||
|
|
||||||
### 1.3 Getting started
|
|
||||||
|
|
||||||
A good way to get started is to run some of the tests included in the download.
|
|
||||||
|
|
||||||
Copy the "Examples" folder next to your "Classes" folder from above so you end up with:
|
|
||||||
|
|
||||||
/var/www/Examples/01simple.php
|
|
||||||
/var/www/Examples/02types.php
|
|
||||||
...
|
|
||||||
|
|
||||||
Start running the tests by pointing your browser to the test scripts:
|
|
||||||
|
|
||||||
http://example.com/Tests/01simple.php
|
|
||||||
http://example.com/Tests/02types.php
|
|
||||||
...
|
|
||||||
|
|
||||||
Note: It may be necessary to modify the include/require statements at the beginning of each of the test scripts if your "Classes" folder from above is named differently.
|
|
||||||
|
|
||||||
### 1.4 Useful links and tools
|
|
||||||
|
|
||||||
There are some links and tools which are very useful when developing using PHPExcel. Please refer to the [PHPExcel CodePlex pages][2] for an update version of the list below.
|
|
||||||
|
|
||||||
#### 1.4.1 OpenXML / SpreadsheetML
|
|
||||||
|
|
||||||
- __File format documentation__
|
|
||||||
[http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm][3]
|
|
||||||
- __OpenXML Explained e-book__
|
|
||||||
[http://openxmldeveloper.org/articles/1970.aspx][4]
|
|
||||||
- __Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats__
|
|
||||||
[http://www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en][5]
|
|
||||||
- __OpenXML Package Explorer__
|
|
||||||
[http://www.codeplex.com/PackageExplorer/][6]
|
|
||||||
|
|
||||||
#### 1.4.2 Frequently asked questions
|
|
||||||
|
|
||||||
The up-to-date F.A.Q. page for PHPExcel can be found on [http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements][7].
|
|
||||||
|
|
||||||
##### There seems to be a problem with character encoding...
|
|
||||||
|
|
||||||
It is necessary to use UTF-8 encoding for all texts in PHPExcel. If the script uses different encoding then you can convert those texts with PHP's iconv() or mb_convert_encoding() functions.
|
|
||||||
|
|
||||||
##### PHP complains about ZipArchive not being found
|
|
||||||
|
|
||||||
Make sure you meet all requirements, especially php_zip extension should be enabled.
|
|
||||||
|
|
||||||
The ZipArchive class is only required when reading or writing formats that use Zip compression (Excel2007 and OOCalc). Since version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class.
|
|
||||||
|
|
||||||
This can be enabled by calling:
|
|
||||||
```php
|
|
||||||
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
|
|
||||||
```
|
|
||||||
*before* calling the save method of the Excel2007 Writer.
|
|
||||||
|
|
||||||
You can revert to using ZipArchive by calling:
|
|
||||||
```php
|
|
||||||
PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);
|
|
||||||
```
|
|
||||||
At present, this only allows you to write Excel2007 files without the need for ZipArchive (not to read Excel2007 or OOCalc)
|
|
||||||
|
|
||||||
##### Excel 2007 cannot open the file generated by PHPExcel_Writer_2007 on Windows
|
|
||||||
|
|
||||||
*"Excel found unreadable content in '*.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes."<22>*
|
|
||||||
|
|
||||||
Some older versions of the 5.2.x php_zip extension on Windows contain an error when creating ZIP files. The version that can be found on [http://snaps.php.net/win32/php5.2-win32-latest.zip][8] should work at all times.
|
|
||||||
|
|
||||||
Alternatively, upgrading to at least PHP 5.2.9 should solve the problem.
|
|
||||||
|
|
||||||
If you can't locate a clean copy of ZipArchive, then you can use the PCLZip library as an alternative when writing Excel2007 files, as described above.
|
|
||||||
|
|
||||||
##### Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa
|
|
||||||
|
|
||||||
PHPExcel holds an "in memory" representation of a spreadsheet, so it is susceptible to PHP's memory limitations. The memory made available to PHP can be increased by editing the value of the memory_limit directive in your php.ini file, or by using ini_set('memory_limit', '128M') within your code (ISP permitting).
|
|
||||||
|
|
||||||
Some Readers and Writers are faster than others, and they also use differing amounts of memory. You can find some indication of the relative performance and memory usage for the different Readers and Writers, over the different versions of PHPExcel, on the [discussion board][9].
|
|
||||||
|
|
||||||
If you've already increased memory to a maximum, or can't change your memory limit, then [this discussion][10] on the board describes some of the methods that can be applied to reduce the memory usage of your scripts using PHPExcel.
|
|
||||||
|
|
||||||
##### Protection on my worksheet is not working?
|
|
||||||
|
|
||||||
When you make use of any of the worksheet protection features (e.g. cell range protection, prohibiting deleting rows, ...), make sure you enable worksheet security. This can for example be done like this:
|
|
||||||
```php
|
|
||||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Feature X is not working with PHPExcel_Reader_Y / PHPExcel_Writer_Z
|
|
||||||
|
|
||||||
Not all features of PHPExcel are implemented in all of the Reader / Writer classes. This is mostly due to underlying libraries not supporting a specific feature or not having implemented a specific feature.
|
|
||||||
|
|
||||||
For example autofilter is not implemented in PEAR Spreadsheet_Excel_writer, which is the base of our Excel5 writer.
|
|
||||||
|
|
||||||
We are slowly building up a list of features, together with the different readers and writers that support them, in the "Functionality Cross-Reference.xls" file in the /Documentation folder.
|
|
||||||
|
|
||||||
##### Formulas don''t seem to be calculated in Excel2003 using compatibility pack?
|
|
||||||
|
|
||||||
This is normal behaviour of the compatibility pack, Excel2007 displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003.
|
|
||||||
|
|
||||||
##### Setting column width is not 100% accurate
|
|
||||||
|
|
||||||
Trying to set column width, I experience one problem. When I open the file in Excel, the actual width is 0.71 less than it should be.
|
|
||||||
|
|
||||||
The short answer is that PHPExcel uses a measure where padding is included. See section: "Setting a column's width"" for more details.
|
|
||||||
|
|
||||||
##### How do I use PHPExcel with my framework
|
|
||||||
|
|
||||||
- There are some instructions for using PHPExcel with Joomla on the [Joomla message board][11]
|
|
||||||
- A page of advice on using [PHPExcel in the Yii framework][12]
|
|
||||||
- [The Bakery][13] has some helper classes for reading and writing with PHPExcel within CakePHP
|
|
||||||
- Integrating [PHPExcel into Kohana][14] http://www.flynsarmy.com/2010/07/phpexcel-module-for-kohana-3/ and [?????????? PHPExcel ? Kohana Framework][15]
|
|
||||||
- Using [PHPExcel with Typo3][16]
|
|
||||||
|
|
||||||
##### Joomla Autoloader interferes with PHPExcel Autoloader
|
|
||||||
|
|
||||||
Thanks to peterrlynch for the following advice on resolving issues between the [PHPExcel autoloader and Joomla Autoloader][17]
|
|
||||||
|
|
||||||
#### 1.4.3 Tutorials
|
|
||||||
|
|
||||||
- __English PHPExcel tutorial__
|
|
||||||
http://openxmldeveloper.org
|
|
||||||
- __French PHPExcel tutorial__
|
|
||||||
[http://g-ernaelsten.developpez.com/tutoriels/excel2007/][18]
|
|
||||||
- __Russian PHPExcel Blog Postings__
|
|
||||||
http://www.web-junior.net/sozdanie-excel-fajjlov-s-pomoshhyu-phpexcel/
|
|
||||||
- __A Japanese-language introduction to PHPExcel__
|
|
||||||
[http://journal.mycom.co.jp/articles/2009/03/06/phpexcel/index.html][19]
|
|
||||||
|
|
||||||
|
|
||||||
# Architecture
|
|
||||||
|
|
||||||
## Schematical
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Lazy Loader
|
|
||||||
|
|
||||||
PHPExcel implements an autoloader or "lazy loader"<22>, which means that it is not necessary to include every file within PHPExcel. It is only necessary to include the initial PHPExcel class file, then the autoloader will include other class files as and when required, so only those files that are actually required by your script will be loaded into PHP memory. The main benefit of this is that it reduces the memory footprint of PHPExcel itself, so that it uses less PHP memory.
|
|
||||||
|
|
||||||
If your own scripts already define an autoload function, then this may be overwritten by the PHPExcel autoload function. For example, if you have:
|
|
||||||
|
|
||||||
function __autoload($class) {
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Do this instead:
|
|
||||||
|
|
||||||
function myAutoload($class) {
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
spl_autoload_register('myAutoload');
|
|
||||||
|
|
||||||
Your autoloader will then co-exist with the autoloader of PHPExcel.
|
|
||||||
|
|
||||||
## Spreadsheet in memory
|
|
||||||
|
|
||||||
PHPExcel’s architecture is built in a way that it can serve as an in-memory spreadsheet. This means that, if one would want to create a web based view of a spreadsheet which communicates with PHPExcel’s object model, he would only have to write the front-end code.
|
|
||||||
|
|
||||||
Just like desktop spreadsheet software, PHPExcel represents a spreadsheet containing one or more worksheets, which contain cells with data, formulas, images, …
|
|
||||||
|
|
||||||
## Readers and writers
|
|
||||||
|
|
||||||
On its own, PHPExcel does not provide the functionality to read from or write to a persisted spreadsheet (on disk or in a database). To provide that functionality, readers and writers can be used.
|
|
||||||
|
|
||||||
By default, the PHPExcel package provides some readers and writers, including one for the Open XML spreadsheet format (a.k.a. Excel 2007 file format). You are not limited to the default readers and writers, as you are free to implement the PHPExcel_Writer_IReader and PHPExcel_Writer_IWriter interface in a custom class.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Fluent interfaces
|
|
||||||
|
|
||||||
PHPExcel supports fluent interfaces in most locations. This means that you can easily “chainâ€<C3A2> calls to specific methods without requiring a new PHP statement. For example, take the following code:
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()->setCategory("Test result file");
|
|
||||||
|
|
||||||
This can be rewritten as:
|
|
||||||
|
|
||||||
$objPHPExcel->getProperties()
|
|
||||||
->setCreator("Maarten Balliauw")
|
|
||||||
|
|
||||||
->setLastModifiedBy("Maarten Balliauw")
|
|
||||||
|
|
||||||
->setTitle("Office 2007 XLSX Test Document")
|
|
||||||
|
|
||||||
->setSubject("Office 2007 XLSX Test Document")
|
|
||||||
|
|
||||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
|
||||||
|
|
||||||
->setKeywords("office 2007 openxml php")
|
|
||||||
|
|
||||||
->setCategory("Test result file");
|
|
||||||
|
|
||||||
__Using fluent interfaces is not required__
|
|
||||||
Fluent interfaces have been implemented to provide a convenient programming API. Use of them is not required, but can make your code easier to read and maintain. It can also improve performance, as you are reducing the overall number of calls to PHPExcel methods.
|
|
||||||
|
|
||||||
# Creating a spreadsheet
|
# Creating a spreadsheet
|
||||||
|
|
||||||
## The PHPExcel class
|
## The PHPExcel class
|
||||||
|
Loading…
Reference in New Issue
Block a user