excel.php 12 KB

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