helper.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <?php
  2. namespace Vtiful\Kernel;
  3. /**
  4. * Class Excel
  5. *
  6. * @author viest
  7. *
  8. * @package Vtiful\Kernel
  9. */
  10. class Excel
  11. {
  12. const TYPE_STRING = 0x01;
  13. const TYPE_INT = 0x02;
  14. const TYPE_DOUBLE = 0x04;
  15. const TYPE_TIMESTAMP = 0x08;
  16. const SKIP_NONE = 0x00;
  17. const SKIP_EMPTY_ROW = 0x01;
  18. const SKIP_EMPTY_CELLS = 0x02;
  19. /**
  20. * Excel constructor.
  21. *
  22. * @param array $config
  23. */
  24. public function __construct(array $config)
  25. {
  26. //
  27. }
  28. /**
  29. * File Name
  30. *
  31. * @param string $fileName
  32. * @param string $sheetName
  33. *
  34. * @return Excel
  35. *
  36. * @author viest
  37. */
  38. public function fileName(string $fileName, string $sheetName = 'Sheet1'): self
  39. {
  40. return $this;
  41. }
  42. /**
  43. * Const memory model
  44. *
  45. * @param string $fileName
  46. * @param string $sheetName
  47. *
  48. * @return Excel
  49. *
  50. * @author viest
  51. */
  52. public function constMemory(string $fileName, string $sheetName = 'Sheet1'): self
  53. {
  54. return $this;
  55. }
  56. /**
  57. * Add a new worksheet to a workbook.
  58. *
  59. * The worksheet name must be a valid Excel worksheet name, i.e. it must be
  60. * less than 32 character and it cannot contain any of the characters:
  61. *
  62. * / \ [ ] : * ?
  63. *
  64. * In addition, you cannot use the same, case insensitive, `$sheetName` for more
  65. * than one worksheet.
  66. *
  67. * @param string|NULL $sheetName
  68. *
  69. * @return Excel
  70. *
  71. * @author viest
  72. */
  73. public function addSheet(?string $sheetName): self
  74. {
  75. return $this;
  76. }
  77. /**
  78. * Checkout worksheet
  79. *
  80. * @param string $sheetName
  81. *
  82. * @return Excel
  83. *
  84. * @author viest
  85. */
  86. public function checkoutSheet(string $sheetName): self
  87. {
  88. return $this;
  89. }
  90. /**
  91. * Insert data on the first line of the worksheet
  92. *
  93. * @param array $header
  94. *
  95. * @return Excel
  96. *
  97. * @author viest
  98. */
  99. public function header(array $header): self
  100. {
  101. return $this;
  102. }
  103. /**
  104. * Insert data on the worksheet
  105. *
  106. * @param array $data
  107. *
  108. * @return Excel
  109. *
  110. * @author viest
  111. */
  112. public function data(array $data): self
  113. {
  114. return $this;
  115. }
  116. /**
  117. * Generate file
  118. *
  119. * @return string
  120. *
  121. * @author viest
  122. */
  123. public function output(): string
  124. {
  125. return 'FilePath';
  126. }
  127. /**
  128. * Get file resource
  129. *
  130. * @return resource
  131. *
  132. * @author viest
  133. */
  134. public function getHandle()
  135. {
  136. //
  137. }
  138. /**
  139. * Auto filter on the worksheet
  140. *
  141. * @param string $range
  142. *
  143. * @return Excel
  144. *
  145. * @author viest
  146. */
  147. public function autoFilter(string $range): self
  148. {
  149. return $this;
  150. }
  151. /**
  152. * Insert data on the cell
  153. *
  154. * @param int $row
  155. * @param int $column
  156. * @param int|string|double $data
  157. * @param string|null $format
  158. * @param resource|null $formatHandle
  159. *
  160. * @return Excel
  161. *
  162. * @author viest
  163. */
  164. public function insertText(int $row, int $column, $data, string $format = NULL, $formatHandle = NULL): self
  165. {
  166. return $this;
  167. }
  168. /**
  169. * Insert date on the cell
  170. *
  171. * @param int $row
  172. * @param int $column
  173. * @param int $timestamp
  174. * @param string|NULL $format
  175. * @param resource|null $formatHandle
  176. *
  177. * @return Excel
  178. *
  179. * @author viest
  180. */
  181. public function insertDate(int $row, int $column, int $timestamp, string $format = NULL, $formatHandle = NULL): self
  182. {
  183. return $this;
  184. }
  185. /**
  186. * Insert chart on the cell
  187. *
  188. * @param int $row
  189. * @param int $column
  190. * @param resource $chartResource
  191. *
  192. * @return Excel
  193. *
  194. * @author viest
  195. */
  196. public function insertChart(int $row, int $column, $chartResource): self
  197. {
  198. return $this;
  199. }
  200. /**
  201. * Insert url on the cell
  202. *
  203. * @param int $row
  204. * @param int $column
  205. * @param string $url
  206. * @param resource|null $formatHandle
  207. *
  208. * @return Excel
  209. *
  210. * @author viest
  211. */
  212. public function insertUrl(int $row, int $column, string $url, $formatHandle = NULL): self
  213. {
  214. return $this;
  215. }
  216. /**
  217. * Insert image on the cell
  218. *
  219. * @param int $row
  220. * @param int $column
  221. * @param string $imagePath
  222. * @param float $width
  223. * @param float $height
  224. *
  225. * @return Excel
  226. *
  227. * @author viest
  228. */
  229. public function insertImage(int $row, int $column, string $imagePath, float $width = 1, float $height = 1): self
  230. {
  231. return $this;
  232. }
  233. /**
  234. * Insert Formula on the cell
  235. *
  236. * @param int $row
  237. * @param int $column
  238. * @param string $formula
  239. *
  240. * @return Excel
  241. *
  242. * @author viest
  243. */
  244. public function insertFormula(int $row, int $column, string $formula): self
  245. {
  246. return $this;
  247. }
  248. /**
  249. * Merge cells
  250. *
  251. * @param string $range
  252. * @param string $data
  253. *
  254. * @return Excel
  255. *
  256. * @author viest
  257. */
  258. public function MergeCells(string $range, string $data): self
  259. {
  260. return $this;
  261. }
  262. /**
  263. * Set column cells width or format
  264. *
  265. * @param string $range
  266. * @param float $cellWidth
  267. * @param resource|null $formatHandle
  268. *
  269. * @return Excel
  270. *
  271. * @author viest
  272. */
  273. public function setColumn(string $range, float $cellWidth, $formatHandle = NULL): self
  274. {
  275. return $this;
  276. }
  277. /**
  278. * Set row cells height or format
  279. *
  280. * @param string $range
  281. * @param float $cellHeight
  282. * @param resource|null $formatHandle
  283. *
  284. * @return Excel
  285. *
  286. * @author viest
  287. */
  288. public function setRow(string $range, float $cellHeight, $formatHandle = NULL): self
  289. {
  290. return $this;
  291. }
  292. /**
  293. * Open xlsx file
  294. *
  295. * @param string $fileName
  296. *
  297. * @return Excel
  298. *
  299. * @author viest
  300. */
  301. public function openFile(string $fileName): self
  302. {
  303. return $this;
  304. }
  305. /**
  306. * Open sheet
  307. *
  308. * default open first sheet
  309. *
  310. * @param string|NULL $sheetName
  311. * @param int skipFlag
  312. *
  313. * @return Excel
  314. *
  315. * @author viest
  316. */
  317. public function openSheet(string $sheetName = NULL, int $skipFlag = 0x00): self
  318. {
  319. return $this;
  320. }
  321. /**
  322. * Set row cell data type
  323. *
  324. * @param array $types
  325. *
  326. * @return Excel
  327. *
  328. * @author viest
  329. */
  330. public function setType(array $types): self
  331. {
  332. return $this;
  333. }
  334. /**
  335. * Read values from the sheet
  336. *
  337. * @return array
  338. *
  339. * @author viest
  340. */
  341. public function getSheetData(): array
  342. {
  343. return [];
  344. }
  345. /**
  346. * Read values from the sheet
  347. *
  348. * @return array
  349. *
  350. * @author viest
  351. */
  352. public function nextRow(): array
  353. {
  354. return [];
  355. }
  356. /**
  357. * Next Cell In Callback
  358. *
  359. * @param callable $callback function(int $row, int $cell, string $data)
  360. * @param string|NULL $sheetName sheet name
  361. *
  362. * @author viest
  363. */
  364. public function nextCellCallback(callable $callback, string $sheetName = NULL): void
  365. {
  366. //
  367. }
  368. }
  369. /**
  370. * Class Format
  371. *
  372. * @author viest
  373. *
  374. * @package Vtiful\Kernel
  375. */
  376. class Format
  377. {
  378. const UNDERLINE_SINGLE = 0x00;
  379. const UNDERLINE_DOUBLE = 0x00;
  380. const UNDERLINE_SINGLE_ACCOUNTING = 0x00;
  381. const UNDERLINE_DOUBLE_ACCOUNTING = 0x00;
  382. const FORMAT_ALIGN_LEFT = 0x00;
  383. const FORMAT_ALIGN_CENTER = 0x00;
  384. const FORMAT_ALIGN_RIGHT = 0x00;
  385. const FORMAT_ALIGN_FILL = 0x00;
  386. const FORMAT_ALIGN_JUSTIFY = 0x00;
  387. const FORMAT_ALIGN_CENTER_ACROSS = 0x00;
  388. const FORMAT_ALIGN_DISTRIBUTED = 0x00;
  389. const FORMAT_ALIGN_VERTICAL_TOP = 0x00;
  390. const FORMAT_ALIGN_VERTICAL_BOTTOM = 0x00;
  391. const FORMAT_ALIGN_VERTICAL_CENTER = 0x00;
  392. const FORMAT_ALIGN_VERTICAL_JUSTIFY = 0x00;
  393. const FORMAT_ALIGN_VERTICAL_DISTRIBUTED = 0x00;
  394. const COLOR_BLACK = 0x00;
  395. const COLOR_BLUE = 0x00;
  396. const COLOR_BROWN = 0x00;
  397. const COLOR_CYAN = 0x00;
  398. const COLOR_GRAY = 0x00;
  399. const COLOR_GREEN = 0x00;
  400. const COLOR_LIME = 0x00;
  401. const COLOR_MAGENTA = 0x00;
  402. const COLOR_NAVY = 0x00;
  403. const COLOR_ORANGE = 0x00;
  404. const COLOR_PINK = 0x00;
  405. const COLOR_PURPLE = 0x00;
  406. const COLOR_RED = 0x00;
  407. const COLOR_SILVER = 0x00;
  408. const COLOR_WHITE = 0x00;
  409. const COLOR_YELLOW = 0x00;
  410. const PATTERN_NONE = 0x00;
  411. const PATTERN_SOLID = 0x00;
  412. const PATTERN_MEDIUM_GRAY = 0x00;
  413. const PATTERN_DARK_GRAY = 0x00;
  414. const PATTERN_LIGHT_GRAY = 0x00;
  415. const PATTERN_DARK_HORIZONTAL = 0x00;
  416. const PATTERN_DARK_VERTICAL = 0x00;
  417. const PATTERN_DARK_DOWN = 0x00;
  418. const PATTERN_DARK_UP = 0x00;
  419. const PATTERN_DARK_GRID = 0x00;
  420. const PATTERN_DARK_TRELLIS = 0x00;
  421. const PATTERN_LIGHT_HORIZONTAL = 0x00;
  422. const PATTERN_LIGHT_VERTICAL = 0x00;
  423. const PATTERN_LIGHT_DOWN = 0x00;
  424. const PATTERN_LIGHT_UP = 0x00;
  425. const PATTERN_LIGHT_GRID = 0x00;
  426. const PATTERN_LIGHT_TRELLIS = 0x00;
  427. const PATTERN_GRAY_125 = 0x00;
  428. const PATTERN_GRAY_0625 = 0x00;
  429. const BORDER_THIN = 0x00;
  430. const BORDER_MEDIUM = 0x00;
  431. const BORDER_DASHED = 0x00;
  432. const BORDER_DOTTED = 0x00;
  433. const BORDER_THICK = 0x00;
  434. const BORDER_DOUBLE = 0x00;
  435. const BORDER_HAIR = 0x00;
  436. const BORDER_MEDIUM_DASHED = 0x00;
  437. const BORDER_DASH_DOT = 0x00;
  438. const BORDER_MEDIUM_DASH_DOT = 0x00;
  439. const BORDER_DASH_DOT_DOT = 0x00;
  440. const BORDER_MEDIUM_DASH_DOT_DOT = 0x00;
  441. const BORDER_SLANT_DASH_DOT = 0x00;
  442. /**
  443. * Format constructor.
  444. *
  445. * @param resource $fileHandle
  446. */
  447. public function __construct($fileHandle)
  448. {
  449. //
  450. }
  451. /**
  452. * Wrap
  453. *
  454. * @return Format
  455. *
  456. * @author viest
  457. */
  458. public function wrap(): self
  459. {
  460. return $this;
  461. }
  462. /**
  463. * Bold
  464. *
  465. * @return Format
  466. *
  467. * @author viest
  468. */
  469. public function bold(): self
  470. {
  471. return $this;
  472. }
  473. /**
  474. * Italic
  475. *
  476. * @return Format
  477. *
  478. * @author viest
  479. */
  480. public function italic(): self
  481. {
  482. return $this;
  483. }
  484. /**
  485. * Cells border
  486. *
  487. * @param int $style const BORDER_***
  488. *
  489. * @return Format
  490. *
  491. * @author viest
  492. */
  493. public function border(int $style): self
  494. {
  495. return $this;
  496. }
  497. /**
  498. * Align
  499. *
  500. * @param int ...$style const FORMAT_ALIGN_****
  501. *
  502. * @return Format
  503. *
  504. * @author viest
  505. */
  506. public function align(...$style): self
  507. {
  508. return $this;
  509. }
  510. /**
  511. * Number format
  512. *
  513. * @param string $format
  514. *
  515. * #,##0
  516. *
  517. * @return Format
  518. *
  519. * @author viest
  520. */
  521. public function number(string $format): self
  522. {
  523. return $this;
  524. }
  525. /**
  526. * Font color
  527. *
  528. * @param int $color const COLOR_****
  529. *
  530. * @return Format
  531. *
  532. * @author viest
  533. */
  534. public function fontColor(int $color): self
  535. {
  536. return $this;
  537. }
  538. /**
  539. * Font size
  540. *
  541. * @param float $size
  542. *
  543. * @return Format
  544. *
  545. * @author viest
  546. */
  547. public function fontSize(float $size): self
  548. {
  549. return $this;
  550. }
  551. /**
  552. * String strikeout
  553. *
  554. * @return Format
  555. *
  556. * @author viest
  557. */
  558. public function strikeout(): self
  559. {
  560. return $this;
  561. }
  562. /**
  563. * Underline
  564. *
  565. * @param int $style const UNDERLINE_****
  566. *
  567. * @return Format
  568. *
  569. * @author viest
  570. */
  571. public function underline(int $style): self
  572. {
  573. return $this;
  574. }
  575. /**
  576. * Cell background
  577. *
  578. * @param int $pattern const PATTERN_****
  579. * @param int $color const COLOR_****
  580. *
  581. * @return Format
  582. *
  583. * @author viest
  584. */
  585. public function background(int $pattern, int $color): self
  586. {
  587. return $this;
  588. }
  589. /**
  590. * Format to resource
  591. *
  592. * @return resource
  593. *
  594. * @author viest
  595. */
  596. public function toResource()
  597. {
  598. //
  599. }
  600. }