| 1 |
# Configuration Settings |
| 2 |
|
| 3 |
Once you have included the PhpSpreadsheet files in your script, but |
| 4 |
before instantiating a `Spreadsheet` object or loading a workbook file, |
| 5 |
there are a number of configuration options that can be set which will |
| 6 |
affect the subsequent behaviour of the script. |
| 7 |
|
| 8 |
## Cell collection caching |
| 9 |
|
| 10 |
By default, PhpSpreadsheet holds all cell objects in memory, but |
| 11 |
you can specify alternatives to reduce memory consumption at the cost of speed. |
| 12 |
Read more about [](./memory_saving.mdmemory saving](./memory_saving.md](./memory_saving.md). |
| 13 |
|
| 14 |
To enable cell caching, you must provide your own implementation of cache like so: |
| 15 |
|
| 16 |
``` php |
| 17 |
$cache = new MyCustomPsr16Implementation(); |
| 18 |
|
| 19 |
\PhpOffice\PhpSpreadsheet\Settings::setCache($cache); |
| 20 |
``` |
| 21 |
|
| 22 |
## Language/Locale |
| 23 |
|
| 24 |
Some localisation elements have been included in PhpSpreadsheet. You can |
| 25 |
set a locale by changing the settings. To set the locale to Brazilian |
| 26 |
Portuguese you would use: |
| 27 |
|
| 28 |
``` php |
| 29 |
$locale = 'pt_br'; |
| 30 |
$validLocale = \PhpOffice\PhpSpreadsheet\Settings::setLocale($locale); |
| 31 |
if (!$validLocale) { |
| 32 |
echo 'Unable to set locale to ' . $locale . " - reverting to en_us" . PHP_EOL; |
| 33 |
} |
| 34 |
``` |
| 35 |
|
| 36 |
- If Brazilian Portuguese language files aren't available, then Portuguese |
| 37 |
will be enabled instead |
| 38 |
- If Portuguese language files aren't available, |
| 39 |
then the `setLocale()` method will return an error, and American English |
| 40 |
(en\_us) settings will be used throughout. |
| 41 |
|
| 42 |
More details of the features available once a locale has been set, |
| 43 |
including a list of the languages and locales currently supported, can |
| 44 |
be found in [Locale Settings for |
| 45 |
Formulae](./recipes.md#locale-settings-for-formulae). |
| 46 |
|