excel.php 12 KB

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