説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

excel.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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' => false,
  34. 'include_separator_line' => false,
  35. 'excel_compatibility' => false,
  36. ],
  37. ],
  38. 'imports' => [
  39. 'read_only' => true,
  40. 'heading_row' => [
  41. /*
  42. |--------------------------------------------------------------------------
  43. | Heading Row Formatter
  44. |--------------------------------------------------------------------------
  45. |
  46. | Configure the heading row formatter.
  47. | Available options: none|slug|custom
  48. |
  49. */
  50. 'formatter' => 'slug',
  51. ],
  52. /*
  53. |--------------------------------------------------------------------------
  54. | CSV Settings
  55. |--------------------------------------------------------------------------
  56. |
  57. | Configure e.g. delimiter, enclosure and line ending for CSV imports.
  58. |
  59. */
  60. 'csv' => [
  61. 'delimiter' => ',',
  62. 'enclosure' => '"',
  63. 'escape_character' => '\\',
  64. 'contiguous' => false,
  65. 'input_encoding' => 'UTF-8',
  66. ],
  67. ],
  68. /*
  69. |--------------------------------------------------------------------------
  70. | Extension detector
  71. |--------------------------------------------------------------------------
  72. |
  73. | Configure here which writer type should be used when
  74. | the package needs to guess the correct type
  75. | based on the extension alone.
  76. |
  77. */
  78. 'extension_detector' => [
  79. 'xlsx' => Excel::XLSX,
  80. 'xlsm' => Excel::XLSX,
  81. 'xltx' => Excel::XLSX,
  82. 'xltm' => Excel::XLSX,
  83. 'xls' => Excel::XLS,
  84. 'xlt' => Excel::XLS,
  85. 'ods' => Excel::ODS,
  86. 'ots' => Excel::ODS,
  87. 'slk' => Excel::SLK,
  88. 'xml' => Excel::XML,
  89. 'gnumeric' => Excel::GNUMERIC,
  90. 'htm' => Excel::HTML,
  91. 'html' => Excel::HTML,
  92. 'csv' => Excel::CSV,
  93. 'tsv' => Excel::TSV,
  94. /*
  95. |--------------------------------------------------------------------------
  96. | PDF Extension
  97. |--------------------------------------------------------------------------
  98. |
  99. | Configure here which Pdf driver should be used by default.
  100. | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
  101. |
  102. */
  103. 'pdf' => Excel::DOMPDF,
  104. ],
  105. 'value_binder' => [
  106. /*
  107. |--------------------------------------------------------------------------
  108. | Default Value Binder
  109. |--------------------------------------------------------------------------
  110. |
  111. | PhpSpreadsheet offers a way to hook into the process of a value being
  112. | written to a cell. In there some assumptions are made on how the
  113. | value should be formatted. If you want to change those defaults,
  114. | you can implement your own default value binder.
  115. |
  116. */
  117. 'default' => Maatwebsite\Excel\DefaultValueBinder::class,
  118. ],
  119. 'transactions' => [
  120. /*
  121. |--------------------------------------------------------------------------
  122. | Transaction Handler
  123. |--------------------------------------------------------------------------
  124. |
  125. | By default the import is wrapped in a transaction. This is useful
  126. | for when an import may fail and you want to retry it. With the
  127. | transactions, the previous import gets rolled-back.
  128. |
  129. | You can disable the transaction handler by setting this to null.
  130. | Or you can choose a custom made transaction handler here.
  131. |
  132. | Supported handlers: null|db
  133. |
  134. */
  135. 'handler' => 'db',
  136. ],
  137. 'temporary_files' => [
  138. /*
  139. |--------------------------------------------------------------------------
  140. | Local Temporary Path
  141. |--------------------------------------------------------------------------
  142. |
  143. | When exporting and importing files, we use a temporary file, before
  144. | storing reading or downloading. Here you can customize that path.
  145. |
  146. */
  147. 'local_path' => sys_get_temp_dir(),
  148. /*
  149. |--------------------------------------------------------------------------
  150. | Remote Temporary Disk
  151. |--------------------------------------------------------------------------
  152. |
  153. | When dealing with a multi server setup with queues in which you
  154. | cannot rely on having a shared local temporary path, you might
  155. | want to store the temporary file on a shared disk. During the
  156. | queue executing, we'll retrieve the temporary file from that
  157. | location instead. When left to null, it will always use
  158. | the local path. This setting only has effect when using
  159. | in conjunction with queued imports and exports.
  160. |
  161. */
  162. 'remote_disk' => null,
  163. 'remote_prefix' => null,
  164. /*
  165. |--------------------------------------------------------------------------
  166. | Force Resync
  167. |--------------------------------------------------------------------------
  168. |
  169. | When dealing with a multi server setup as above, it's possible
  170. | for the clean up that occurs after entire queue has been run to only
  171. | cleanup the server that the last AfterImportJob runs on. The rest of the server
  172. | would still have the local temporary file stored on it. In this case your
  173. | local storage limits can be exceeded and future imports won't be processed.
  174. | To mitigate this you can set this config value to be true, so that after every
  175. | queued chunk is processed the local temporary file is deleted on the server that
  176. | processed it.
  177. |
  178. */
  179. 'force_resync_remote' => null,
  180. ],
  181. ];