excel.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <?php
  2. return array(
  3. 'cache' => [
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Enable/Disable cell caching
  7. |--------------------------------------------------------------------------
  8. */
  9. 'enable' => true,
  10. /*
  11. |--------------------------------------------------------------------------
  12. | Caching driver
  13. |--------------------------------------------------------------------------
  14. |
  15. | Set the caching driver
  16. |
  17. | Available methods:
  18. | memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
  19. |
  20. */
  21. 'driver' => 'memory',
  22. /*
  23. |--------------------------------------------------------------------------
  24. | Cache settings
  25. |--------------------------------------------------------------------------
  26. */
  27. 'settings' => [
  28. 'memoryCacheSize' => '32MB',
  29. 'cacheTime' => 600
  30. ],
  31. /*
  32. |--------------------------------------------------------------------------
  33. | Memcache settings
  34. |--------------------------------------------------------------------------
  35. */
  36. 'memcache' => [
  37. 'host' => 'localhost',
  38. 'port' => 11211,
  39. ],
  40. /*
  41. |--------------------------------------------------------------------------
  42. | Cache dir (for discISAM)
  43. |--------------------------------------------------------------------------
  44. */
  45. 'dir' => storage_path('cache')
  46. ],
  47. 'properties' => [
  48. 'creator' => 'Maatwebsite',
  49. 'lastModifiedBy' => 'Maatwebsite',
  50. 'title' => 'Spreadsheet',
  51. 'description' => 'Default spreadsheet export',
  52. 'subject' => 'Spreadsheet export',
  53. 'keywords' => 'maatwebsite, excel, export',
  54. 'category' => 'Excel',
  55. 'manager' => 'Maatwebsite',
  56. 'company' => 'Maatwebsite',
  57. ],
  58. /*
  59. |--------------------------------------------------------------------------
  60. | Sheets settings
  61. |--------------------------------------------------------------------------
  62. */
  63. 'sheets' => [
  64. /*
  65. |--------------------------------------------------------------------------
  66. | Default page setup
  67. |--------------------------------------------------------------------------
  68. */
  69. 'pageSetup' => [
  70. 'orientation' => 'portrait',
  71. 'paperSize' => '9',
  72. 'scale' => '100',
  73. 'fitToPage' => false,
  74. 'fitToHeight' => true,
  75. 'fitToWidth' => true,
  76. 'columnsToRepeatAtLeft' => ['', ''],
  77. 'rowsToRepeatAtTop' => [0, 0],
  78. 'horizontalCentered' => false,
  79. 'verticalCentered' => false,
  80. 'printArea' => null,
  81. 'firstPageNumber' => null,
  82. ],
  83. ],
  84. /*
  85. |--------------------------------------------------------------------------
  86. | Creator
  87. |--------------------------------------------------------------------------
  88. |
  89. | The default creator of a new Excel file
  90. |
  91. */
  92. 'creator' => 'Maatwebsite',
  93. 'csv' => [
  94. /*
  95. |--------------------------------------------------------------------------
  96. | Delimiter
  97. |--------------------------------------------------------------------------
  98. |
  99. | The default delimiter which will be used to read out a CSV file
  100. |
  101. */
  102. 'delimiter' => ',',
  103. /*
  104. |--------------------------------------------------------------------------
  105. | Enclosure
  106. |--------------------------------------------------------------------------
  107. */
  108. 'enclosure' => '"',
  109. /*
  110. |--------------------------------------------------------------------------
  111. | Line endings
  112. |--------------------------------------------------------------------------
  113. */
  114. 'line_ending' => "\r\n",
  115. /*
  116. |--------------------------------------------------------------------------
  117. | setUseBom
  118. |--------------------------------------------------------------------------
  119. */
  120. 'use_bom' => false
  121. ],
  122. 'export' => [
  123. /*
  124. |--------------------------------------------------------------------------
  125. | Autosize columns
  126. |--------------------------------------------------------------------------
  127. |
  128. | Disable/enable column autosize or set the autosizing for
  129. | an array of columns ( array('A', 'B') )
  130. |
  131. */
  132. 'autosize' => true,
  133. /*
  134. |--------------------------------------------------------------------------
  135. | Autosize method
  136. |--------------------------------------------------------------------------
  137. |
  138. | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
  139. | The default is based on an estimate, which does its calculation based
  140. | on the number of characters in the cell value (applying any calculation
  141. | and format mask, and allowing for wordwrap and rotation) and with an
  142. | "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
  143. | defaulting to Calibri if any other font is used) and a proportional
  144. | adjustment for the font size.
  145. |
  146. | --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
  147. | The second method is more accurate, based on actual style formatting as
  148. | well (bold, italic, etc), and is calculated by generating a gd2 imagettf
  149. | bounding box and using its dimensions to determine the size; but this
  150. | method is significantly slower, and its accuracy is still dependent on
  151. | having the appropriate fonts installed.
  152. |
  153. */
  154. 'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
  155. /*
  156. |--------------------------------------------------------------------------
  157. | Auto generate table heading
  158. |--------------------------------------------------------------------------
  159. |
  160. | If set to true, the array indices (or model attribute names)
  161. | will automatically be used as first row (table heading)
  162. |
  163. */
  164. 'generate_heading_by_indices' => true,
  165. /*
  166. |--------------------------------------------------------------------------
  167. | Auto set alignment on merged cells
  168. |--------------------------------------------------------------------------
  169. */
  170. 'merged_cell_alignment' => 'left',
  171. /*
  172. |--------------------------------------------------------------------------
  173. | Pre-calculate formulas during export
  174. |--------------------------------------------------------------------------
  175. */
  176. 'calculate' => false,
  177. /*
  178. |--------------------------------------------------------------------------
  179. | Include Charts during export
  180. |--------------------------------------------------------------------------
  181. */
  182. 'includeCharts' => false,
  183. /*
  184. |--------------------------------------------------------------------------
  185. | Default sheet settings
  186. |--------------------------------------------------------------------------
  187. */
  188. 'sheets' => [
  189. /*
  190. |--------------------------------------------------------------------------
  191. | Default page margin
  192. |--------------------------------------------------------------------------
  193. |
  194. | 1) When set to false, default margins will be used
  195. | 2) It's possible to enter a single margin which will
  196. | be used for all margins.
  197. | 3) Alternatively you can pass an array with 4 margins
  198. | Default order: array(top, right, bottom, left)
  199. |
  200. */
  201. 'page_margin' => false,
  202. /*
  203. |--------------------------------------------------------------------------
  204. | Value in source array that stands for blank cell
  205. |--------------------------------------------------------------------------
  206. */
  207. 'nullValue' => null,
  208. /*
  209. |--------------------------------------------------------------------------
  210. | Insert array starting from this cell address as the top left coordinate
  211. |--------------------------------------------------------------------------
  212. */
  213. 'startCell' => 'A1',
  214. /*
  215. |--------------------------------------------------------------------------
  216. | Apply strict comparison when testing for null values in the array
  217. |--------------------------------------------------------------------------
  218. */
  219. 'strictNullComparison' => false
  220. ],
  221. /*
  222. |--------------------------------------------------------------------------
  223. | Store settings
  224. |--------------------------------------------------------------------------
  225. */
  226. 'store' => [
  227. /*
  228. |--------------------------------------------------------------------------
  229. | Path
  230. |--------------------------------------------------------------------------
  231. |
  232. | The path we want to save excel file to
  233. |
  234. */
  235. 'path' => storage_path('exports'),
  236. /*
  237. |--------------------------------------------------------------------------
  238. | Return info
  239. |--------------------------------------------------------------------------
  240. |
  241. | Whether we want to return information about the stored file or not
  242. |
  243. */
  244. 'returnInfo' => false
  245. ],
  246. /*
  247. |--------------------------------------------------------------------------
  248. | PDF Settings
  249. |--------------------------------------------------------------------------
  250. */
  251. 'pdf' => [
  252. /*
  253. |--------------------------------------------------------------------------
  254. | PDF Drivers
  255. |--------------------------------------------------------------------------
  256. | Supported: DomPDF, tcPDF, mPDF
  257. */
  258. 'driver' => 'DomPDF',
  259. /*
  260. |--------------------------------------------------------------------------
  261. | PDF Driver settings
  262. |--------------------------------------------------------------------------
  263. */
  264. 'drivers' => [
  265. /*
  266. |--------------------------------------------------------------------------
  267. | DomPDF settings
  268. |--------------------------------------------------------------------------
  269. */
  270. 'DomPDF' => [
  271. 'path' => base_path('vendor/dompdf/dompdf/')
  272. ],
  273. /*
  274. |--------------------------------------------------------------------------
  275. | tcPDF settings
  276. |--------------------------------------------------------------------------
  277. */
  278. 'tcPDF' => [
  279. 'path' => base_path('vendor/tecnick.com/tcpdf/')
  280. ],
  281. /*
  282. |--------------------------------------------------------------------------
  283. | mPDF settings
  284. |--------------------------------------------------------------------------
  285. */
  286. 'mPDF' => [
  287. 'path' => base_path('vendor/mpdf/mpdf/')
  288. ],
  289. ]
  290. ]
  291. ],
  292. 'filters' => [
  293. /*
  294. |--------------------------------------------------------------------------
  295. | Register read filters
  296. |--------------------------------------------------------------------------
  297. */
  298. 'registered' => [
  299. 'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
  300. ],
  301. /*
  302. |--------------------------------------------------------------------------
  303. | Enable certain filters for every file read
  304. |--------------------------------------------------------------------------
  305. */
  306. 'enabled' => []
  307. ],
  308. 'import' => [
  309. /*
  310. |--------------------------------------------------------------------------
  311. | Has heading
  312. |--------------------------------------------------------------------------
  313. |
  314. | The sheet has a heading (first) row which we can use as attribute names
  315. |
  316. | Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|hashed_with_lower|trans|original
  317. |
  318. */
  319. // 'heading' => 'slugged',//得到关联数组(键是Excel的A1行标题)
  320. 'heading' => false, //得到索引数组(从0开始到...)
  321. /*
  322. |--------------------------------------------------------------------------
  323. | First Row with data or heading of data
  324. |--------------------------------------------------------------------------
  325. |
  326. | If the heading row is not the first row, or the data doesn't start
  327. | on the first row, here you can change the start row.
  328. |
  329. */
  330. 'startRow' => 1,
  331. /*
  332. |--------------------------------------------------------------------------
  333. | Cell name word separator
  334. |--------------------------------------------------------------------------
  335. |
  336. | The default separator which is used for the cell names
  337. | Note: only applies to 'heading' settings 'true' && 'slugged'
  338. |
  339. */
  340. 'separator' => '_',
  341. /*
  342. |--------------------------------------------------------------------------
  343. | Slug whitelisting
  344. |--------------------------------------------------------------------------
  345. |
  346. | Here you can whitelist certain characters in the slug.
  347. | E.g. user.last_name will not remove . and _
  348. | Note: only applies to 'heading' settings 'true' && 'slugged'
  349. |
  350. */
  351. 'slug_whitelist' => '._',
  352. /*
  353. |--------------------------------------------------------------------------
  354. | Include Charts during import
  355. |--------------------------------------------------------------------------
  356. */
  357. 'includeCharts' => false,
  358. /*
  359. |--------------------------------------------------------------------------
  360. | Sheet heading conversion
  361. |--------------------------------------------------------------------------
  362. |
  363. | Convert headings to ASCII
  364. | Note: only applies to 'heading' settings 'true' && 'slugged'
  365. |
  366. */
  367. 'to_ascii' => false,
  368. /*
  369. |--------------------------------------------------------------------------
  370. | Import encoding
  371. |--------------------------------------------------------------------------
  372. */
  373. 'encoding' => [
  374. 'input' => 'UTF-8',
  375. 'output' => 'UTF-8'
  376. ],
  377. /*
  378. |--------------------------------------------------------------------------
  379. | Calculate
  380. |--------------------------------------------------------------------------
  381. |
  382. | By default cells with formulas will be calculated.
  383. |
  384. */
  385. 'calculate' => true,
  386. /*
  387. |--------------------------------------------------------------------------
  388. | Ignore empty cells
  389. |--------------------------------------------------------------------------
  390. |
  391. | By default empty cells are not ignored
  392. |
  393. */
  394. 'ignoreEmpty' => false,
  395. /*
  396. |--------------------------------------------------------------------------
  397. | Force sheet collection
  398. |--------------------------------------------------------------------------
  399. |
  400. | For a sheet collection even when there is only 1 sheets.
  401. | When set to false and only 1 sheet found, the parsed file will return
  402. | a row collection instead of a sheet collection.
  403. | When set to true, it will return a sheet collection instead.
  404. |
  405. */
  406. 'force_sheets_collection' => false,
  407. /*
  408. |--------------------------------------------------------------------------
  409. | Date format
  410. |--------------------------------------------------------------------------
  411. |
  412. | The format dates will be parsed to
  413. |
  414. */
  415. 'dates' => [
  416. /*
  417. |--------------------------------------------------------------------------
  418. | Enable/disable date formatting
  419. |--------------------------------------------------------------------------
  420. */
  421. 'enabled' => true,
  422. /*
  423. |--------------------------------------------------------------------------
  424. | Default date format
  425. |--------------------------------------------------------------------------
  426. |
  427. | If set to false, a carbon object will return
  428. |
  429. */
  430. 'format' => false,
  431. /*
  432. |--------------------------------------------------------------------------
  433. | Date columns
  434. |--------------------------------------------------------------------------
  435. */
  436. 'columns' => []
  437. ],
  438. /*
  439. |--------------------------------------------------------------------------
  440. | Import sheets by config
  441. |--------------------------------------------------------------------------
  442. */
  443. 'sheets' => [
  444. /*
  445. |--------------------------------------------------------------------------
  446. | Example sheet
  447. |--------------------------------------------------------------------------
  448. |
  449. | Example sheet "test" will grab the firstname at cell A2
  450. |
  451. */
  452. 'test' => [
  453. 'firstname' => 'A2'
  454. ]
  455. ]
  456. ],
  457. 'views' => [
  458. /*
  459. |--------------------------------------------------------------------------
  460. | Styles
  461. |--------------------------------------------------------------------------
  462. |
  463. | The default styles which will be used when parsing a view
  464. |
  465. */
  466. 'styles' => [
  467. /*
  468. |--------------------------------------------------------------------------
  469. | Table headings
  470. |--------------------------------------------------------------------------
  471. */
  472. 'th' => [
  473. 'font' => [
  474. 'bold' => true,
  475. 'size' => 12,
  476. ]
  477. ],
  478. /*
  479. |--------------------------------------------------------------------------
  480. | Strong tags
  481. |--------------------------------------------------------------------------
  482. */
  483. 'strong' => [
  484. 'font' => [
  485. 'bold' => true,
  486. 'size' => 12,
  487. ]
  488. ],
  489. /*
  490. |--------------------------------------------------------------------------
  491. | Bold tags
  492. |--------------------------------------------------------------------------
  493. */
  494. 'b' => [
  495. 'font' => [
  496. 'bold' => true,
  497. 'size' => 12,
  498. ]
  499. ],
  500. /*
  501. |--------------------------------------------------------------------------
  502. | Italic tags
  503. |--------------------------------------------------------------------------
  504. */
  505. 'i' => [
  506. 'font' => [
  507. 'italic' => true,
  508. 'size' => 12,
  509. ]
  510. ],
  511. /*
  512. |--------------------------------------------------------------------------
  513. | Heading 1
  514. |--------------------------------------------------------------------------
  515. */
  516. 'h1' => [
  517. 'font' => [
  518. 'bold' => true,
  519. 'size' => 24,
  520. ]
  521. ],
  522. /*
  523. |--------------------------------------------------------------------------
  524. | Heading 2
  525. |--------------------------------------------------------------------------
  526. */
  527. 'h2' => [
  528. 'font' => [
  529. 'bold' => true,
  530. 'size' => 18,
  531. ]
  532. ],
  533. /*
  534. |--------------------------------------------------------------------------
  535. | Heading 3
  536. |--------------------------------------------------------------------------
  537. */
  538. 'h3' => [
  539. 'font' => [
  540. 'bold' => true,
  541. 'size' => 13.5,
  542. ]
  543. ],
  544. /*
  545. |--------------------------------------------------------------------------
  546. | Heading 4
  547. |--------------------------------------------------------------------------
  548. */
  549. 'h4' => [
  550. 'font' => [
  551. 'bold' => true,
  552. 'size' => 12,
  553. ]
  554. ],
  555. /*
  556. |--------------------------------------------------------------------------
  557. | Heading 5
  558. |--------------------------------------------------------------------------
  559. */
  560. 'h5' => [
  561. 'font' => [
  562. 'bold' => true,
  563. 'size' => 10,
  564. ]
  565. ],
  566. /*
  567. |--------------------------------------------------------------------------
  568. | Heading 6
  569. |--------------------------------------------------------------------------
  570. */
  571. 'h6' => [
  572. 'font' => [
  573. 'bold' => true,
  574. 'size' => 7.5,
  575. ]
  576. ],
  577. /*
  578. |--------------------------------------------------------------------------
  579. | Hyperlinks
  580. |--------------------------------------------------------------------------
  581. */
  582. 'a' => [
  583. 'font' => [
  584. 'underline' => true,
  585. 'color' => ['argb' => 'FF0000FF'],
  586. ]
  587. ],
  588. /*
  589. |--------------------------------------------------------------------------
  590. | Horizontal rules
  591. |--------------------------------------------------------------------------
  592. */
  593. 'hr' => [
  594. 'borders' => [
  595. 'bottom' => [
  596. 'style' => 'thin',
  597. 'color' => ['FF000000']
  598. ],
  599. ]
  600. ]
  601. ]
  602. ]
  603. );