excel.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. | Cell Middleware
  142. |--------------------------------------------------------------------------
  143. |
  144. | Configure middleware that is executed on getting a cell value
  145. |
  146. */
  147. 'cells' => [
  148. 'middleware' => [
  149. //\Maatwebsite\Excel\Middleware\TrimCellValue::class,
  150. //\Maatwebsite\Excel\Middleware\ConvertEmptyCellValuesToNull::class,
  151. ],
  152. ],
  153. ],
  154. /*
  155. |--------------------------------------------------------------------------
  156. | Extension detector
  157. |--------------------------------------------------------------------------
  158. |
  159. | Configure here which writer/reader type should be used when the package
  160. | needs to guess the correct type based on the extension alone.
  161. |
  162. */
  163. 'extension_detector' => [
  164. 'xlsx' => Excel::XLSX,
  165. 'xlsm' => Excel::XLSX,
  166. 'xltx' => Excel::XLSX,
  167. 'xltm' => Excel::XLSX,
  168. 'xls' => Excel::XLS,
  169. 'xlt' => Excel::XLS,
  170. 'ods' => Excel::ODS,
  171. 'ots' => Excel::ODS,
  172. 'slk' => Excel::SLK,
  173. 'xml' => Excel::XML,
  174. 'gnumeric' => Excel::GNUMERIC,
  175. 'htm' => Excel::HTML,
  176. 'html' => Excel::HTML,
  177. 'csv' => Excel::CSV,
  178. 'tsv' => Excel::TSV,
  179. /*
  180. |--------------------------------------------------------------------------
  181. | PDF Extension
  182. |--------------------------------------------------------------------------
  183. |
  184. | Configure here which Pdf driver should be used by default.
  185. | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
  186. |
  187. */
  188. 'pdf' => Excel::DOMPDF,
  189. ],
  190. /*
  191. |--------------------------------------------------------------------------
  192. | Value Binder
  193. |--------------------------------------------------------------------------
  194. |
  195. | PhpSpreadsheet offers a way to hook into the process of a value being
  196. | written to a cell. In there some assumptions are made on how the
  197. | value should be formatted. If you want to change those defaults,
  198. | you can implement your own default value binder.
  199. |
  200. | Possible value binders:
  201. |
  202. | [x] Maatwebsite\Excel\DefaultValueBinder::class
  203. | [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
  204. | [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
  205. |
  206. */
  207. 'value_binder' => [
  208. 'default' => Maatwebsite\Excel\DefaultValueBinder::class,
  209. ],
  210. 'cache' => [
  211. /*
  212. |--------------------------------------------------------------------------
  213. | Default cell caching driver
  214. |--------------------------------------------------------------------------
  215. |
  216. | By default PhpSpreadsheet keeps all cell values in memory, however when
  217. | dealing with large files, this might result into memory issues. If you
  218. | want to mitigate that, you can configure a cell caching driver here.
  219. | When using the illuminate driver, it will store each value in the
  220. | cache store. This can slow down the process, because it needs to
  221. | store each value. You can use the "batch" store if you want to
  222. | only persist to the store when the memory limit is reached.
  223. |
  224. | Drivers: memory|illuminate|batch
  225. |
  226. */
  227. 'driver' => 'memory',
  228. /*
  229. |--------------------------------------------------------------------------
  230. | Batch memory caching
  231. |--------------------------------------------------------------------------
  232. |
  233. | When dealing with the "batch" caching driver, it will only
  234. | persist to the store when the memory limit is reached.
  235. | Here you can tweak the memory limit to your liking.
  236. |
  237. */
  238. 'batch' => [
  239. 'memory_limit' => 60000,
  240. ],
  241. /*
  242. |--------------------------------------------------------------------------
  243. | Illuminate cache
  244. |--------------------------------------------------------------------------
  245. |
  246. | When using the "illuminate" caching driver, it will automatically use
  247. | your default cache store. However if you prefer to have the cell
  248. | cache on a separate store, you can configure the store name here.
  249. | You can use any store defined in your cache config. When leaving
  250. | at "null" it will use the default store.
  251. |
  252. */
  253. 'illuminate' => [
  254. 'store' => null,
  255. ],
  256. /*
  257. |--------------------------------------------------------------------------
  258. | Cache Time-to-live (TTL)
  259. |--------------------------------------------------------------------------
  260. |
  261. | The TTL of items written to cache. If you want to keep the items cached
  262. | indefinitely, set this to null. Otherwise, set a number of seconds,
  263. | a \DateInterval, or a callable.
  264. |
  265. | Allowable types: callable|\DateInterval|int|null
  266. |
  267. */
  268. 'default_ttl' => 10800,
  269. ],
  270. /*
  271. |--------------------------------------------------------------------------
  272. | Transaction Handler
  273. |--------------------------------------------------------------------------
  274. |
  275. | By default the import is wrapped in a transaction. This is useful
  276. | for when an import may fail and you want to retry it. With the
  277. | transactions, the previous import gets rolled-back.
  278. |
  279. | You can disable the transaction handler by setting this to null.
  280. | Or you can choose a custom made transaction handler here.
  281. |
  282. | Supported handlers: null|db
  283. |
  284. */
  285. 'transactions' => [
  286. 'handler' => 'db',
  287. 'db' => [
  288. 'connection' => null,
  289. ],
  290. ],
  291. 'temporary_files' => [
  292. /*
  293. |--------------------------------------------------------------------------
  294. | Local Temporary Path
  295. |--------------------------------------------------------------------------
  296. |
  297. | When exporting and importing files, we use a temporary file, before
  298. | storing reading or downloading. Here you can customize that path.
  299. | permissions is an array with the permission flags for the directory (dir)
  300. | and the create file (file).
  301. |
  302. */
  303. 'local_path' => storage_path('framework/cache/laravel-excel'),
  304. /*
  305. |--------------------------------------------------------------------------
  306. | Local Temporary Path Permissions
  307. |--------------------------------------------------------------------------
  308. |
  309. | Permissions is an array with the permission flags for the directory (dir)
  310. | and the create file (file).
  311. | If omitted the default permissions of the filesystem will be used.
  312. |
  313. */
  314. 'local_permissions' => [
  315. // 'dir' => 0755,
  316. // 'file' => 0644,
  317. ],
  318. /*
  319. |--------------------------------------------------------------------------
  320. | Remote Temporary Disk
  321. |--------------------------------------------------------------------------
  322. |
  323. | When dealing with a multi server setup with queues in which you
  324. | cannot rely on having a shared local temporary path, you might
  325. | want to store the temporary file on a shared disk. During the
  326. | queue executing, we'll retrieve the temporary file from that
  327. | location instead. When left to null, it will always use
  328. | the local path. This setting only has effect when using
  329. | in conjunction with queued imports and exports.
  330. |
  331. */
  332. 'remote_disk' => null,
  333. 'remote_prefix' => null,
  334. /*
  335. |--------------------------------------------------------------------------
  336. | Force Resync
  337. |--------------------------------------------------------------------------
  338. |
  339. | When dealing with a multi server setup as above, it's possible
  340. | for the clean up that occurs after entire queue has been run to only
  341. | cleanup the server that the last AfterImportJob runs on. The rest of the server
  342. | would still have the local temporary file stored on it. In this case your
  343. | local storage limits can be exceeded and future imports won't be processed.
  344. | To mitigate this you can set this config value to be true, so that after every
  345. | queued chunk is processed the local temporary file is deleted on the server that
  346. | processed it.
  347. |
  348. */
  349. 'force_resync_remote' => null,
  350. ],
  351. ];