excel.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?php
  2. use Maatwebsite\Excel\Excel;
  3. return [
  4. 'exports' => [
  5. /*
  6. |--------------------------------------------------------------------------
  7. | Chunk size
  8. |--------------------------------------------------------------------------
  9. |
  10. | When using FromQuery, the query is automatically chunked.
  11. | Here you can specify how big the chunk should be.
  12. |
  13. */
  14. 'chunk_size' => 1000,
  15. /*
  16. |--------------------------------------------------------------------------
  17. | Pre-calculate formulas during export
  18. |--------------------------------------------------------------------------
  19. */
  20. 'pre_calculate_formulas' => false,
  21. /*
  22. |--------------------------------------------------------------------------
  23. | CSV Settings
  24. |--------------------------------------------------------------------------
  25. |
  26. | Configure e.g. delimiter, enclosure and line ending for CSV exports.
  27. |
  28. */
  29. 'csv' => [
  30. 'delimiter' => ',',
  31. 'enclosure' => '"',
  32. 'line_ending' => PHP_EOL,
  33. 'use_bom' => true,
  34. 'include_separator_line' => false,
  35. 'excel_compatibility' => false,
  36. ],
  37. /*
  38. |--------------------------------------------------------------------------
  39. | Worksheet properties
  40. |--------------------------------------------------------------------------
  41. |
  42. | Configure e.g. default title, creator, subject,...
  43. |
  44. */
  45. 'properties' => [
  46. 'creator' => '',
  47. 'lastModifiedBy' => '',
  48. 'title' => '',
  49. 'description' => '',
  50. 'subject' => '',
  51. 'keywords' => '',
  52. 'category' => '',
  53. 'manager' => '',
  54. 'company' => '',
  55. ],
  56. ],
  57. 'imports' => [
  58. /*
  59. |--------------------------------------------------------------------------
  60. | Read Only
  61. |--------------------------------------------------------------------------
  62. |
  63. | When dealing with imports, you might only be interested in the
  64. | data that the sheet exists. By default we ignore all styles,
  65. | however if you want to do some logic based on style data
  66. | you can enable it by setting read_only to false.
  67. |
  68. */
  69. 'read_only' => true,
  70. /*
  71. |--------------------------------------------------------------------------
  72. | Heading Row Formatter
  73. |--------------------------------------------------------------------------
  74. |
  75. | Configure the heading row formatter.
  76. | Available options: none|slug|custom
  77. |
  78. */
  79. 'heading_row' => [
  80. 'formatter' => 'slug',
  81. ],
  82. /*
  83. |--------------------------------------------------------------------------
  84. | CSV Settings
  85. |--------------------------------------------------------------------------
  86. |
  87. | Configure e.g. delimiter, enclosure and line ending for CSV imports.
  88. |
  89. */
  90. 'csv' => [
  91. 'delimiter' => ',',
  92. 'enclosure' => '"',
  93. 'escape_character' => '\\',
  94. 'contiguous' => false,
  95. 'input_encoding' => 'UTF-8',
  96. ],
  97. /*
  98. |--------------------------------------------------------------------------
  99. | Worksheet properties
  100. |--------------------------------------------------------------------------
  101. |
  102. | Configure e.g. default title, creator, subject,...
  103. |
  104. */
  105. 'properties' => [
  106. 'creator' => '',
  107. 'lastModifiedBy' => '',
  108. 'title' => '',
  109. 'description' => '',
  110. 'subject' => '',
  111. 'keywords' => '',
  112. 'category' => '',
  113. 'manager' => '',
  114. 'company' => '',
  115. ],
  116. ],
  117. /*
  118. |--------------------------------------------------------------------------
  119. | Extension detector
  120. |--------------------------------------------------------------------------
  121. |
  122. | Configure here which writer/reader type should be used when the package
  123. | needs to guess the correct type based on the extension alone.
  124. |
  125. */
  126. 'extension_detector' => [
  127. 'xlsx' => Excel::XLSX,
  128. 'xlsm' => Excel::XLSX,
  129. 'xltx' => Excel::XLSX,
  130. 'xltm' => Excel::XLSX,
  131. 'xls' => Excel::XLS,
  132. 'xlt' => Excel::XLS,
  133. 'ods' => Excel::ODS,
  134. 'ots' => Excel::ODS,
  135. 'slk' => Excel::SLK,
  136. 'xml' => Excel::XML,
  137. 'gnumeric' => Excel::GNUMERIC,
  138. 'htm' => Excel::HTML,
  139. 'html' => Excel::HTML,
  140. 'csv' => Excel::CSV,
  141. 'tsv' => Excel::TSV,
  142. /*
  143. |--------------------------------------------------------------------------
  144. | PDF Extension
  145. |--------------------------------------------------------------------------
  146. |
  147. | Configure here which Pdf driver should be used by default.
  148. | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
  149. |
  150. */
  151. 'pdf' => Excel::DOMPDF,
  152. ],
  153. /*
  154. |--------------------------------------------------------------------------
  155. | Value Binder
  156. |--------------------------------------------------------------------------
  157. |
  158. | PhpSpreadsheet offers a way to hook into the process of a value being
  159. | written to a cell. In there some assumptions are made on how the
  160. | value should be formatted. If you want to change those defaults,
  161. | you can implement your own default value binder.
  162. |
  163. | Possible value binders:
  164. |
  165. | [x] Maatwebsite\Excel\DefaultValueBinder::class
  166. | [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
  167. | [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
  168. |
  169. */
  170. 'value_binder' => [
  171. 'default' => Maatwebsite\Excel\DefaultValueBinder::class,
  172. ],
  173. 'cache' => [
  174. /*
  175. |--------------------------------------------------------------------------
  176. | Default cell caching driver
  177. |--------------------------------------------------------------------------
  178. |
  179. | By default PhpSpreadsheet keeps all cell values in memory, however when
  180. | dealing with large files, this might result into memory issues. If you
  181. | want to mitigate that, you can configure a cell caching driver here.
  182. | When using the illuminate driver, it will store each value in a the
  183. | cache store. This can slow down the process, because it needs to
  184. | store each value. You can use the "batch" store if you want to
  185. | only persist to the store when the memory limit is reached.
  186. |
  187. | Drivers: memory|illuminate|batch
  188. |
  189. */
  190. 'driver' => 'memory',
  191. /*
  192. |--------------------------------------------------------------------------
  193. | Batch memory caching
  194. |--------------------------------------------------------------------------
  195. |
  196. | When dealing with the "batch" caching driver, it will only
  197. | persist to the store when the memory limit is reached.
  198. | Here you can tweak the memory limit to your liking.
  199. |
  200. */
  201. 'batch' => [
  202. 'memory_limit' => 60000,
  203. ],
  204. /*
  205. |--------------------------------------------------------------------------
  206. | Illuminate cache
  207. |--------------------------------------------------------------------------
  208. |
  209. | When using the "illuminate" caching driver, it will automatically use
  210. | your default cache store. However if you prefer to have the cell
  211. | cache on a separate store, you can configure the store name here.
  212. | You can use any store defined in your cache config. When leaving
  213. | at "null" it will use the default store.
  214. |
  215. */
  216. 'illuminate' => [
  217. 'store' => null,
  218. ],
  219. ],
  220. /*
  221. |--------------------------------------------------------------------------
  222. | Transaction Handler
  223. |--------------------------------------------------------------------------
  224. |
  225. | By default the import is wrapped in a transaction. This is useful
  226. | for when an import may fail and you want to retry it. With the
  227. | transactions, the previous import gets rolled-back.
  228. |
  229. | You can disable the transaction handler by setting this to null.
  230. | Or you can choose a custom made transaction handler here.
  231. |
  232. | Supported handlers: null|db
  233. |
  234. */
  235. 'transactions' => [
  236. 'handler' => 'db',
  237. ],
  238. 'temporary_files' => [
  239. /*
  240. |--------------------------------------------------------------------------
  241. | Local Temporary Path
  242. |--------------------------------------------------------------------------
  243. |
  244. | When exporting and importing files, we use a temporary file, before
  245. | storing reading or downloading. Here you can customize that path.
  246. |
  247. */
  248. 'local_path' => storage_path('framework/laravel-excel'),
  249. /*
  250. |--------------------------------------------------------------------------
  251. | Remote Temporary Disk
  252. |--------------------------------------------------------------------------
  253. |
  254. | When dealing with a multi server setup with queues in which you
  255. | cannot rely on having a shared local temporary path, you might
  256. | want to store the temporary file on a shared disk. During the
  257. | queue executing, we'll retrieve the temporary file from that
  258. | location instead. When left to null, it will always use
  259. | the local path. This setting only has effect when using
  260. | in conjunction with queued imports and exports.
  261. |
  262. */
  263. 'remote_disk' => null,
  264. 'remote_prefix' => null,
  265. /*
  266. |--------------------------------------------------------------------------
  267. | Force Resync
  268. |--------------------------------------------------------------------------
  269. |
  270. | When dealing with a multi server setup as above, it's possible
  271. | for the clean up that occurs after entire queue has been run to only
  272. | cleanup the server that the last AfterImportJob runs on. The rest of the server
  273. | would still have the local temporary file stored on it. In this case your
  274. | local storage limits can be exceeded and future imports won't be processed.
  275. | To mitigate this you can set this config value to be true, so that after every
  276. | queued chunk is processed the local temporary file is deleted on the server that
  277. | processed it.
  278. |
  279. */
  280. 'force_resync_remote' => null,
  281. ],
  282. ];