excel.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. 'default' => \PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
  196. ],
  197. 'cache' => [
  198. /*
  199. |--------------------------------------------------------------------------
  200. | Default cell caching driver
  201. |--------------------------------------------------------------------------
  202. |
  203. | By default PhpSpreadsheet keeps all cell values in memory, however when
  204. | dealing with large files, this might result into memory issues. If you
  205. | want to mitigate that, you can configure a cell caching driver here.
  206. | When using the illuminate driver, it will store each value in the
  207. | cache store. This can slow down the process, because it needs to
  208. | store each value. You can use the "batch" store if you want to
  209. | only persist to the store when the memory limit is reached.
  210. |
  211. | Drivers: memory|illuminate|batch
  212. |
  213. */
  214. 'driver' => 'memory',
  215. /*
  216. |--------------------------------------------------------------------------
  217. | Batch memory caching
  218. |--------------------------------------------------------------------------
  219. |
  220. | When dealing with the "batch" caching driver, it will only
  221. | persist to the store when the memory limit is reached.
  222. | Here you can tweak the memory limit to your liking.
  223. |
  224. */
  225. 'batch' => [
  226. 'memory_limit' => 60000,
  227. ],
  228. /*
  229. |--------------------------------------------------------------------------
  230. | Illuminate cache
  231. |--------------------------------------------------------------------------
  232. |
  233. | When using the "illuminate" caching driver, it will automatically use
  234. | your default cache store. However if you prefer to have the cell
  235. | cache on a separate store, you can configure the store name here.
  236. | You can use any store defined in your cache config. When leaving
  237. | at "null" it will use the default store.
  238. |
  239. */
  240. 'illuminate' => [
  241. 'store' => null,
  242. ],
  243. ],
  244. /*
  245. |--------------------------------------------------------------------------
  246. | Transaction Handler
  247. |--------------------------------------------------------------------------
  248. |
  249. | By default the import is wrapped in a transaction. This is useful
  250. | for when an import may fail and you want to retry it. With the
  251. | transactions, the previous import gets rolled-back.
  252. |
  253. | You can disable the transaction handler by setting this to null.
  254. | Or you can choose a custom made transaction handler here.
  255. |
  256. | Supported handlers: null|db
  257. |
  258. */
  259. 'transactions' => [
  260. 'handler' => 'db',
  261. 'db' => [
  262. 'connection' => null,
  263. ],
  264. ],
  265. 'temporary_files' => [
  266. /*
  267. |--------------------------------------------------------------------------
  268. | Local Temporary Path
  269. |--------------------------------------------------------------------------
  270. |
  271. | When exporting and importing files, we use a temporary file, before
  272. | storing reading or downloading. Here you can customize that path.
  273. |
  274. */
  275. 'local_path' => storage_path('framework/cache/laravel-excel'),
  276. /*
  277. |--------------------------------------------------------------------------
  278. | Remote Temporary Disk
  279. |--------------------------------------------------------------------------
  280. |
  281. | When dealing with a multi server setup with queues in which you
  282. | cannot rely on having a shared local temporary path, you might
  283. | want to store the temporary file on a shared disk. During the
  284. | queue executing, we'll retrieve the temporary file from that
  285. | location instead. When left to null, it will always use
  286. | the local path. This setting only has effect when using
  287. | in conjunction with queued imports and exports.
  288. |
  289. */
  290. 'remote_disk' => null,
  291. 'remote_prefix' => null,
  292. /*
  293. |--------------------------------------------------------------------------
  294. | Force Resync
  295. |--------------------------------------------------------------------------
  296. |
  297. | When dealing with a multi server setup as above, it's possible
  298. | for the clean up that occurs after entire queue has been run to only
  299. | cleanup the server that the last AfterImportJob runs on. The rest of the server
  300. | would still have the local temporary file stored on it. In this case your
  301. | local storage limits can be exceeded and future imports won't be processed.
  302. | To mitigate this you can set this config value to be true, so that after every
  303. | queued chunk is processed the local temporary file is deleted on the server that
  304. | processed it.
  305. |
  306. */
  307. 'force_resync_remote' => null,
  308. ],
  309. ];