helper.php 12 KB

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