You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.md 1.6 KiB

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