excel.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. +----------------------------------------------------------------------+
  3. | XlsWriter Extension |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2017-2018 The Viest |
  6. +----------------------------------------------------------------------+
  7. | http://www.viest.me |
  8. +----------------------------------------------------------------------+
  9. | Author: viest <[email protected]> |
  10. +----------------------------------------------------------------------+
  11. */
  12. #include "xlswriter.h"
  13. zend_class_entry *vtiful_xls_ce;
  14. static zend_object_handlers vtiful_xls_handlers;
  15. static zend_always_inline void *vtiful_object_alloc(size_t obj_size, zend_class_entry *ce) {
  16. void *obj = emalloc(obj_size + zend_object_properties_size(ce));
  17. memset(obj, 0, obj_size);
  18. return obj;
  19. }
  20. /* {{{ xls_objects_new
  21. */
  22. PHP_VTIFUL_API zend_object *vtiful_xls_objects_new(zend_class_entry *ce)
  23. {
  24. xls_object *intern = vtiful_object_alloc(sizeof(xls_object), ce);
  25. SHEET_LINE_INIT(intern)
  26. zend_object_std_init(&intern->zo, ce);
  27. object_properties_init(&intern->zo, ce);
  28. intern->zo.handlers = &vtiful_xls_handlers;
  29. return &intern->zo;
  30. }
  31. /* }}} */
  32. /* {{{ vtiful_xls_objects_free
  33. */
  34. static void vtiful_xls_objects_free(zend_object *object)
  35. {
  36. xls_object *intern = php_vtiful_xls_fetch_object(object);
  37. lxw_workbook_free(intern->ptr.workbook);
  38. zend_object_std_dtor(&intern->zo);
  39. }
  40. /* }}} */
  41. /* {{{ ARG_INFO
  42. */
  43. ZEND_BEGIN_ARG_INFO_EX(xls_construct_arginfo, 0, 0, 1)
  44. ZEND_ARG_INFO(0, config)
  45. ZEND_END_ARG_INFO()
  46. ZEND_BEGIN_ARG_INFO_EX(xls_file_name_arginfo, 0, 0, 1)
  47. ZEND_ARG_INFO(0, file_name)
  48. ZEND_ARG_INFO(0, sheet_name)
  49. ZEND_END_ARG_INFO()
  50. ZEND_BEGIN_ARG_INFO_EX(xls_const_memory_arginfo, 0, 0, 1)
  51. ZEND_ARG_INFO(0, file_name)
  52. ZEND_ARG_INFO(0, sheet_name)
  53. ZEND_END_ARG_INFO()
  54. ZEND_BEGIN_ARG_INFO_EX(xls_file_add_sheet, 0, 0, 1)
  55. ZEND_ARG_INFO(0, sheet_name)
  56. ZEND_END_ARG_INFO()
  57. ZEND_BEGIN_ARG_INFO_EX(xls_file_checkout_sheet, 0, 0, 1)
  58. ZEND_ARG_INFO(0, sheet_name)
  59. ZEND_END_ARG_INFO()
  60. ZEND_BEGIN_ARG_INFO_EX(xls_header_arginfo, 0, 0, 1)
  61. ZEND_ARG_INFO(0, header)
  62. ZEND_END_ARG_INFO()
  63. ZEND_BEGIN_ARG_INFO_EX(xls_data_arginfo, 0, 0, 1)
  64. ZEND_ARG_INFO(0, data)
  65. ZEND_END_ARG_INFO()
  66. ZEND_BEGIN_ARG_INFO_EX(xls_insert_text_arginfo, 0, 0, 4)
  67. ZEND_ARG_INFO(0, row)
  68. ZEND_ARG_INFO(0, column)
  69. ZEND_ARG_INFO(0, data)
  70. ZEND_ARG_INFO(0, format_handle)
  71. ZEND_END_ARG_INFO()
  72. ZEND_BEGIN_ARG_INFO_EX(xls_insert_url_arginfo, 0, 0, 4)
  73. ZEND_ARG_INFO(0, row)
  74. ZEND_ARG_INFO(0, column)
  75. ZEND_ARG_INFO(0, url)
  76. ZEND_ARG_INFO(0, format)
  77. ZEND_END_ARG_INFO()
  78. ZEND_BEGIN_ARG_INFO_EX(xls_insert_chart_arginfo, 0, 0, 3)
  79. ZEND_ARG_INFO(0, row)
  80. ZEND_ARG_INFO(0, column)
  81. ZEND_ARG_INFO(0, chart_resource)
  82. ZEND_END_ARG_INFO()
  83. ZEND_BEGIN_ARG_INFO_EX(xls_insert_image_arginfo, 0, 0, 3)
  84. ZEND_ARG_INFO(0, row)
  85. ZEND_ARG_INFO(0, column)
  86. ZEND_ARG_INFO(0, image)
  87. ZEND_ARG_INFO(0, width)
  88. ZEND_ARG_INFO(0, height)
  89. ZEND_END_ARG_INFO()
  90. ZEND_BEGIN_ARG_INFO_EX(xls_insert_formula_arginfo, 0, 0, 3)
  91. ZEND_ARG_INFO(0, row)
  92. ZEND_ARG_INFO(0, column)
  93. ZEND_ARG_INFO(0, formula)
  94. ZEND_END_ARG_INFO()
  95. ZEND_BEGIN_ARG_INFO_EX(xls_auto_filter_arginfo, 0, 0, 1)
  96. ZEND_ARG_INFO(0, range)
  97. ZEND_END_ARG_INFO()
  98. ZEND_BEGIN_ARG_INFO_EX(xls_merge_cells_arginfo, 0, 0, 2)
  99. ZEND_ARG_INFO(0, range)
  100. ZEND_ARG_INFO(0, data)
  101. ZEND_END_ARG_INFO()
  102. ZEND_BEGIN_ARG_INFO_EX(xls_set_column_arginfo, 0, 0, 3)
  103. ZEND_ARG_INFO(0, format_handle)
  104. ZEND_ARG_INFO(0, range)
  105. ZEND_ARG_INFO(0, width)
  106. ZEND_END_ARG_INFO()
  107. ZEND_BEGIN_ARG_INFO_EX(xls_set_row_arginfo, 0, 0, 3)
  108. ZEND_ARG_INFO(0, format_handle)
  109. ZEND_ARG_INFO(0, range)
  110. ZEND_ARG_INFO(0, height)
  111. ZEND_END_ARG_INFO()
  112. /* }}} */
  113. /** {{{ \Vtiful\Kernel\xls::__construct(array $config)
  114. */
  115. PHP_METHOD(vtiful_xls, __construct)
  116. {
  117. zval *config, *c_path;
  118. ZEND_PARSE_PARAMETERS_START(1, 1)
  119. Z_PARAM_ARRAY(config)
  120. ZEND_PARSE_PARAMETERS_END();
  121. if((c_path = zend_hash_str_find(Z_ARRVAL_P(config), ZEND_STRL(V_XLS_PAT))) == NULL)
  122. {
  123. zend_throw_exception(vtiful_exception_ce, "Lack of 'path' configuration", 110);
  124. return;
  125. }
  126. if(Z_TYPE_P(c_path) != IS_STRING)
  127. {
  128. zend_throw_exception(vtiful_exception_ce, "Configure 'path' must be a string type", 120);
  129. return;
  130. }
  131. add_property_zval(getThis(), V_XLS_COF, config);
  132. }
  133. /* }}} */
  134. /** {{{ \Vtiful\Kernel\xls::filename(string $fileName [, string $sheetName])
  135. */
  136. PHP_METHOD(vtiful_xls, fileName)
  137. {
  138. zval file_path, *dir_path = NULL;
  139. zend_string *zs_file_name = NULL, *zs_sheet_name = NULL;
  140. char *sheet_name = NULL;
  141. ZEND_PARSE_PARAMETERS_START(1, 2)
  142. Z_PARAM_STR(zs_file_name)
  143. Z_PARAM_OPTIONAL
  144. Z_PARAM_STR(zs_sheet_name)
  145. ZEND_PARSE_PARAMETERS_END();
  146. ZVAL_COPY(return_value, getThis());
  147. GET_CONFIG_PATH(dir_path, vtiful_xls_ce, return_value);
  148. xls_object *obj = Z_XLS_P(getThis());
  149. if(obj->ptr.workbook == NULL) {
  150. xls_file_path(zs_file_name, dir_path, &file_path);
  151. if(zs_sheet_name != NULL) {
  152. sheet_name = ZSTR_VAL(zs_sheet_name);
  153. }
  154. obj->ptr.workbook = workbook_new(Z_STRVAL(file_path));
  155. obj->ptr.worksheet = workbook_add_worksheet(obj->ptr.workbook, sheet_name);
  156. add_property_zval(return_value, V_XLS_FIL, &file_path);
  157. zval_ptr_dtor(&file_path);
  158. }
  159. }
  160. /* }}} */
  161. /** {{{ \Vtiful\Kernel\xls::addSheet(string $sheetName)
  162. */
  163. PHP_METHOD(vtiful_xls, addSheet)
  164. {
  165. zend_string *zs_sheet_name = NULL;
  166. char *sheet_name = NULL;
  167. ZEND_PARSE_PARAMETERS_START(0, 1)
  168. Z_PARAM_OPTIONAL
  169. Z_PARAM_STR(zs_sheet_name)
  170. ZEND_PARSE_PARAMETERS_END();
  171. ZVAL_COPY(return_value, getThis());
  172. xls_object *obj = Z_XLS_P(getThis());
  173. SHEET_LINE_INIT(obj)
  174. if(obj->ptr.workbook == NULL) {
  175. zend_throw_exception(vtiful_exception_ce, "Please create a file first, use the filename method", 130);
  176. return;
  177. }
  178. if(zs_sheet_name != NULL) {
  179. sheet_name = ZSTR_VAL(zs_sheet_name);
  180. }
  181. obj->ptr.worksheet = workbook_add_worksheet(obj->ptr.workbook, sheet_name);
  182. }
  183. /* }}} */
  184. /** {{{ \Vtiful\Kernel\xls::checkoutSheet(string $sheetName)
  185. */
  186. PHP_METHOD(vtiful_xls, checkoutSheet)
  187. {
  188. int line = 0;
  189. lxw_worksheet *sheet_t = NULL;
  190. zend_string *zs_sheet_name = NULL;
  191. ZEND_PARSE_PARAMETERS_START(1, 1)
  192. Z_PARAM_STR(zs_sheet_name)
  193. ZEND_PARSE_PARAMETERS_END();
  194. ZVAL_COPY(return_value, getThis());
  195. xls_object *obj = Z_XLS_P(getThis());
  196. if(obj->ptr.workbook == NULL) {
  197. zend_throw_exception(vtiful_exception_ce, "Please create a file first, use the filename method", 130);
  198. return;
  199. }
  200. if ((sheet_t = workbook_get_worksheet_by_name(obj->ptr.workbook, ZSTR_VAL(zs_sheet_name))) == NULL) {
  201. zend_throw_exception(vtiful_exception_ce, "Sheet not fund", 140);
  202. return;
  203. }
  204. line = sheet_t->table->cached_row_num;
  205. SHEET_LINE_SET(obj, line);
  206. obj->ptr.worksheet = sheet_t;
  207. }
  208. /* }}} */
  209. /** {{{ \Vtiful\Kernel\xls::constMemory(string $fileName [, string $sheetName])
  210. */
  211. PHP_METHOD(vtiful_xls, constMemory)
  212. {
  213. zval file_path, *dir_path = NULL;
  214. zend_string *zs_file_name = NULL, *zs_sheet_name = NULL;
  215. char *sheet_name = NULL;
  216. ZEND_PARSE_PARAMETERS_START(1, 2)
  217. Z_PARAM_STR(zs_file_name)
  218. Z_PARAM_OPTIONAL
  219. Z_PARAM_STR(zs_sheet_name)
  220. ZEND_PARSE_PARAMETERS_END();
  221. ZVAL_COPY(return_value, getThis());
  222. GET_CONFIG_PATH(dir_path, vtiful_xls_ce, return_value);
  223. xls_object *obj = Z_XLS_P(getThis());
  224. if(obj->ptr.workbook == NULL) {
  225. xls_file_path(zs_file_name, dir_path, &file_path);
  226. lxw_workbook_options options = {.constant_memory = LXW_TRUE, .tmpdir = NULL};
  227. if(zs_sheet_name != NULL) {
  228. sheet_name = ZSTR_VAL(zs_sheet_name);
  229. }
  230. obj->ptr.workbook = workbook_new_opt(Z_STRVAL(file_path), &options);
  231. obj->ptr.worksheet = workbook_add_worksheet(obj->ptr.workbook, sheet_name);
  232. add_property_zval(return_value, V_XLS_FIL, &file_path);
  233. zval_ptr_dtor(&file_path);
  234. }
  235. }
  236. /* }}} */
  237. /** {{{ \Vtiful\Kernel\xls::header(array $header)
  238. */
  239. PHP_METHOD(vtiful_xls, header)
  240. {
  241. zval *header, *header_value;
  242. zend_long header_l_key;
  243. ZEND_PARSE_PARAMETERS_START(1, 1)
  244. Z_PARAM_ARRAY(header)
  245. ZEND_PARSE_PARAMETERS_END();
  246. ZVAL_COPY(return_value, getThis());
  247. xls_object *obj = Z_XLS_P(getThis());
  248. ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(header), header_l_key, header_value)
  249. type_writer(header_value, 0, header_l_key, &obj->ptr, NULL);
  250. zval_ptr_dtor(header_value);
  251. ZEND_HASH_FOREACH_END();
  252. }
  253. /* }}} */
  254. /** {{{ \Vtiful\Kernel\xls::data(array $data)
  255. */
  256. PHP_METHOD(vtiful_xls, data)
  257. {
  258. zval *data = NULL, *data_r_value = NULL;
  259. ZEND_PARSE_PARAMETERS_START(1, 1)
  260. Z_PARAM_ARRAY(data)
  261. ZEND_PARSE_PARAMETERS_END();
  262. ZVAL_COPY(return_value, getThis());
  263. xls_object *obj = Z_XLS_P(getThis());
  264. ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), data_r_value)
  265. if(Z_TYPE_P(data_r_value) == IS_ARRAY) {
  266. SHEET_LINE_ADD(obj)
  267. ZEND_HASH_FOREACH_BUCKET(Z_ARRVAL_P(data_r_value), Bucket *bucket)
  268. type_writer(&bucket->val, SHEET_CURRENT_LINE(obj), bucket->h, &obj->ptr, NULL);
  269. zval_ptr_dtor(&bucket->val);
  270. ZEND_HASH_FOREACH_END();
  271. }
  272. ZEND_HASH_FOREACH_END();
  273. }
  274. /* }}} */
  275. /** {{{ \Vtiful\Kernel\xls::output()
  276. */
  277. PHP_METHOD(vtiful_xls, output)
  278. {
  279. zval rv, *file_path;
  280. file_path = zend_read_property(vtiful_xls_ce, getThis(), ZEND_STRL(V_XLS_FIL), 0, &rv TSRMLS_DC);
  281. xls_object *obj = Z_XLS_P(getThis());
  282. workbook_file(&obj->ptr);
  283. add_property_null(getThis(), V_XLS_HANDLE);
  284. add_property_null(getThis(), V_XLS_PAT);
  285. ZVAL_COPY(return_value, file_path);
  286. }
  287. /* }}} */
  288. /** {{{ \Vtiful\Kernel\xls::getHandle()
  289. */
  290. PHP_METHOD(vtiful_xls, getHandle)
  291. {
  292. xls_object *obj = Z_XLS_P(getThis());
  293. RETURN_RES(zend_register_resource(&obj->ptr, le_xls_writer));
  294. }
  295. /* }}} */
  296. /** {{{ \Vtiful\Kernel\xls::insertText(int $row, int $column, string|int|double $data)
  297. */
  298. PHP_METHOD(vtiful_xls, insertText)
  299. {
  300. zval *data;
  301. zend_long row, column;
  302. zend_string *format = NULL;
  303. ZEND_PARSE_PARAMETERS_START(3, 4)
  304. Z_PARAM_LONG(row)
  305. Z_PARAM_LONG(column)
  306. Z_PARAM_ZVAL(data)
  307. Z_PARAM_OPTIONAL
  308. Z_PARAM_STR(format)
  309. ZEND_PARSE_PARAMETERS_END();
  310. ZVAL_COPY(return_value, getThis());
  311. xls_object *obj = Z_XLS_P(getThis());
  312. type_writer(data, row, column, &obj->ptr, format);
  313. }
  314. /* }}} */
  315. /** {{{ \Vtiful\Kernel\xls::insertChart(int $row, int $column, resource $chartResource)
  316. */
  317. PHP_METHOD(vtiful_xls, insertChart)
  318. {
  319. zval *chart_resource;
  320. zend_long row, column;
  321. ZEND_PARSE_PARAMETERS_START(3, 3)
  322. Z_PARAM_LONG(row)
  323. Z_PARAM_LONG(column)
  324. Z_PARAM_ZVAL(chart_resource)
  325. ZEND_PARSE_PARAMETERS_END();
  326. ZVAL_COPY(return_value, getThis());
  327. xls_object *obj = Z_XLS_P(getThis());
  328. chart_writer(row, column, zval_get_chart(chart_resource), &obj->ptr);
  329. }
  330. /* }}} */
  331. /** {{{ \Vtiful\Kernel\xls::insertUrl(int $row, int $column, string $url)
  332. */
  333. PHP_METHOD(vtiful_xls, insertUrl)
  334. {
  335. zend_long row, column;
  336. zend_string *url = NULL;
  337. zval *format_handle = NULL;
  338. int argc = ZEND_NUM_ARGS();
  339. ZEND_PARSE_PARAMETERS_START(3, 4)
  340. Z_PARAM_LONG(row)
  341. Z_PARAM_LONG(column)
  342. Z_PARAM_STR(url)
  343. Z_PARAM_OPTIONAL
  344. Z_PARAM_RESOURCE(format_handle)
  345. ZEND_PARSE_PARAMETERS_END();
  346. ZVAL_COPY(return_value, getThis());
  347. xls_object *obj = Z_XLS_P(getThis());
  348. if (argc == 4) {
  349. url_writer(row, column, &obj->ptr, url, zval_get_format(format_handle));
  350. }
  351. if (argc == 3) {
  352. url_writer(row, column, &obj->ptr, url, NULL);
  353. }
  354. }
  355. /* }}} */
  356. /** {{{ \Vtiful\Kernel\xls::insertImage(int $row, int $column, string $imagePath)
  357. */
  358. PHP_METHOD(vtiful_xls, insertImage)
  359. {
  360. zval *image;
  361. zend_long row, column;
  362. double width = 1, height = 1;
  363. ZEND_PARSE_PARAMETERS_START(3, 5)
  364. Z_PARAM_LONG(row)
  365. Z_PARAM_LONG(column)
  366. Z_PARAM_ZVAL(image)
  367. Z_PARAM_OPTIONAL
  368. Z_PARAM_DOUBLE(width)
  369. Z_PARAM_DOUBLE(height)
  370. ZEND_PARSE_PARAMETERS_END();
  371. ZVAL_COPY(return_value, getThis());
  372. xls_object *obj = Z_XLS_P(getThis());
  373. image_writer(image, row, column, width, height, &obj->ptr);
  374. }
  375. /* }}} */
  376. /** {{{ \Vtiful\Kernel\xls::insertImage(int $row, int $column, string $imagePath)
  377. */
  378. PHP_METHOD(vtiful_xls, insertFormula)
  379. {
  380. zval *formula;
  381. zend_long row, column;
  382. ZEND_PARSE_PARAMETERS_START(3, 3)
  383. Z_PARAM_LONG(row)
  384. Z_PARAM_LONG(column)
  385. Z_PARAM_ZVAL(formula)
  386. ZEND_PARSE_PARAMETERS_END();
  387. ZVAL_COPY(return_value, getThis());
  388. xls_object *obj = Z_XLS_P(getThis());
  389. formula_writer(formula, row, column, &obj->ptr);
  390. }
  391. /* }}} */
  392. /** {{{ \Vtiful\Kernel\xls::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
  393. */
  394. PHP_METHOD(vtiful_xls, autoFilter)
  395. {
  396. zend_string *range;
  397. ZEND_PARSE_PARAMETERS_START(1, 1)
  398. Z_PARAM_STR(range)
  399. ZEND_PARSE_PARAMETERS_END();
  400. ZVAL_COPY(return_value, getThis());
  401. xls_object *obj = Z_XLS_P(getThis());
  402. auto_filter(range, &obj->ptr);
  403. }
  404. /* }}} */
  405. /** {{{ \Vtiful\Kernel\xls::mergeCells(string $range, string $data)
  406. */
  407. PHP_METHOD(vtiful_xls, mergeCells)
  408. {
  409. zend_string *range, *data;
  410. ZEND_PARSE_PARAMETERS_START(2, 2)
  411. Z_PARAM_STR(range)
  412. Z_PARAM_STR(data)
  413. ZEND_PARSE_PARAMETERS_END();
  414. ZVAL_COPY(return_value, getThis());
  415. xls_object *obj = Z_XLS_P(getThis());
  416. merge_cells(range, data, &obj->ptr);
  417. }
  418. /* }}} */
  419. /** {{{ \Vtiful\Kernel\xls::setColumn(resource $format, string $range [, int $width])
  420. */
  421. PHP_METHOD(vtiful_xls, setColumn)
  422. {
  423. zval *format_handle;
  424. zend_string *range;
  425. double width = 0;
  426. int argc = ZEND_NUM_ARGS();
  427. ZEND_PARSE_PARAMETERS_START(2, 3)
  428. Z_PARAM_STR(range)
  429. Z_PARAM_DOUBLE(width)
  430. Z_PARAM_OPTIONAL
  431. Z_PARAM_RESOURCE(format_handle)
  432. ZEND_PARSE_PARAMETERS_END();
  433. ZVAL_COPY(return_value, getThis());
  434. xls_object *obj = Z_XLS_P(getThis());
  435. if (argc == 3) {
  436. set_column(range, width, &obj->ptr, zval_get_format(format_handle));
  437. }
  438. if (argc == 2) {
  439. set_column(range, width, &obj->ptr, NULL);
  440. }
  441. }
  442. /* }}} */
  443. /** {{{ \Vtiful\Kernel\xls::setRow(resource $format, string $range [, int $heitght])
  444. */
  445. PHP_METHOD(vtiful_xls, setRow)
  446. {
  447. zval *format_handle;
  448. zend_string *range;
  449. double height = 0;
  450. int argc = ZEND_NUM_ARGS();
  451. ZEND_PARSE_PARAMETERS_START(2, 3)
  452. Z_PARAM_STR(range)
  453. Z_PARAM_DOUBLE(height)
  454. Z_PARAM_OPTIONAL
  455. Z_PARAM_RESOURCE(format_handle)
  456. ZEND_PARSE_PARAMETERS_END();
  457. ZVAL_COPY(return_value, getThis());
  458. xls_object *obj = Z_XLS_P(getThis());
  459. if (argc == 3) {
  460. set_row(range, height, &obj->ptr, zval_get_format(format_handle));
  461. }
  462. if (argc == 2) {
  463. set_row(range, height, &obj->ptr, NULL);
  464. }
  465. }
  466. /* }}} */
  467. /** {{{ xls_methods
  468. */
  469. zend_function_entry xls_methods[] = {
  470. PHP_ME(vtiful_xls, __construct, xls_construct_arginfo, ZEND_ACC_PUBLIC)
  471. PHP_ME(vtiful_xls, fileName, xls_file_name_arginfo, ZEND_ACC_PUBLIC)
  472. PHP_ME(vtiful_xls, addSheet, xls_file_add_sheet, ZEND_ACC_PUBLIC)
  473. PHP_ME(vtiful_xls, checkoutSheet, xls_file_checkout_sheet, ZEND_ACC_PUBLIC)
  474. PHP_ME(vtiful_xls, constMemory, xls_const_memory_arginfo, ZEND_ACC_PUBLIC)
  475. PHP_ME(vtiful_xls, header, xls_header_arginfo, ZEND_ACC_PUBLIC)
  476. PHP_ME(vtiful_xls, data, xls_data_arginfo, ZEND_ACC_PUBLIC)
  477. PHP_ME(vtiful_xls, output, NULL, ZEND_ACC_PUBLIC)
  478. PHP_ME(vtiful_xls, getHandle, NULL, ZEND_ACC_PUBLIC)
  479. PHP_ME(vtiful_xls, autoFilter, xls_auto_filter_arginfo, ZEND_ACC_PUBLIC)
  480. PHP_ME(vtiful_xls, insertText, xls_insert_text_arginfo, ZEND_ACC_PUBLIC)
  481. PHP_ME(vtiful_xls, insertChart, xls_insert_chart_arginfo, ZEND_ACC_PUBLIC)
  482. PHP_ME(vtiful_xls, insertUrl, xls_insert_url_arginfo, ZEND_ACC_PUBLIC)
  483. PHP_ME(vtiful_xls, insertImage, xls_insert_image_arginfo, ZEND_ACC_PUBLIC)
  484. PHP_ME(vtiful_xls, insertFormula, xls_insert_formula_arginfo, ZEND_ACC_PUBLIC)
  485. PHP_ME(vtiful_xls, mergeCells, xls_merge_cells_arginfo, ZEND_ACC_PUBLIC)
  486. PHP_ME(vtiful_xls, setColumn, xls_set_column_arginfo, ZEND_ACC_PUBLIC)
  487. PHP_ME(vtiful_xls, setRow, xls_set_row_arginfo, ZEND_ACC_PUBLIC)
  488. PHP_FE_END
  489. };
  490. /* }}} */
  491. /** {{{ VTIFUL_STARTUP_FUNCTION
  492. */
  493. VTIFUL_STARTUP_FUNCTION(excel) {
  494. zend_class_entry ce;
  495. INIT_NS_CLASS_ENTRY(ce, "Vtiful\\Kernel", "Excel", xls_methods);
  496. ce.create_object = vtiful_xls_objects_new;
  497. vtiful_xls_ce = zend_register_internal_class(&ce);
  498. memcpy(&vtiful_xls_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
  499. vtiful_xls_handlers.offset = XtOffsetOf(xls_object, zo);
  500. vtiful_xls_handlers.free_obj = vtiful_xls_objects_free;
  501. REGISTER_CLASS_PROPERTY_NULL(vtiful_xls_ce, V_XLS_COF, ZEND_ACC_PRIVATE);
  502. REGISTER_CLASS_PROPERTY_NULL(vtiful_xls_ce, V_XLS_FIL, ZEND_ACC_PRIVATE);
  503. return SUCCESS;
  504. }
  505. /* }}} */