excel.c 18 KB

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