Skip to content

Commit a9efd65

Browse files
authored
Merge pull request #10 from viest/dev
Increase the autofilter
2 parents e94f8f9 + 70f25d1 commit a9efd65

File tree

4 files changed

+398
-7
lines changed

4 files changed

+398
-7
lines changed

kernel/excel.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ ZEND_BEGIN_ARG_INFO_EX(excel_insert_formula_arginfo, 0, 0, 3)
6161
ZEND_ARG_INFO(0, formula)
6262
ZEND_END_ARG_INFO()
6363

64+
ZEND_BEGIN_ARG_INFO_EX(excel_auto_filter_arginfo, 0, 0, 1)
65+
ZEND_ARG_INFO(0, range)
66+
ZEND_END_ARG_INFO()
67+
68+
excel_resource_t * zval_get_resource(zval *handle)
69+
{
70+
excel_resource_t *res;
71+
72+
if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_vtiful)) == NULL) {
73+
zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
74+
}
75+
76+
return res;
77+
}
78+
6479
/* {{{ \Vtiful\Kernel\Excel::__construct(array $config)
6580
*/
6681
PHP_METHOD(vtiful_excel, __construct)
@@ -310,13 +325,39 @@ PHP_METHOD(vtiful_excel, insertFormula)
310325
}
311326
/* }}} */
312327

328+
/* {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
329+
*/
330+
PHP_METHOD(vtiful_excel, autoFilter)
331+
{
332+
zval rv, res_handle;
333+
zval *attr_handle;
334+
zend_string *range;
335+
excel_resource_t *res;
336+
337+
ZEND_PARSE_PARAMETERS_START(1, 1)
338+
Z_PARAM_STR(range)
339+
ZEND_PARSE_PARAMETERS_END();
340+
341+
ZVAL_COPY(return_value, getThis());
342+
343+
attr_handle = zend_read_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), 0, &rv TSRMLS_DC);
344+
res = zval_get_resource(attr_handle);
345+
346+
auto_filter(range, res);
347+
348+
ZVAL_RES(&res_handle, zend_register_resource(res, le_vtiful));
349+
zend_update_property(vtiful_excel_ce, return_value, ZEND_STRL(V_EXCEL_HANDLE), &res_handle);
350+
}
351+
/* }}} */
352+
313353
zend_function_entry excel_methods[] = {
314354
PHP_ME(vtiful_excel, __construct, excel_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
315355
PHP_ME(vtiful_excel, fileName, excel_file_name_arginfo, ZEND_ACC_PUBLIC)
316356
PHP_ME(vtiful_excel, header, excel_header_arginfo, ZEND_ACC_PUBLIC)
317357
PHP_ME(vtiful_excel, data, excel_data_arginfo, ZEND_ACC_PUBLIC)
318358
PHP_ME(vtiful_excel, output, NULL, ZEND_ACC_PUBLIC)
319359
PHP_ME(vtiful_excel, getHandle, NULL, ZEND_ACC_PUBLIC)
360+
PHP_ME(vtiful_excel, autoFilter, excel_auto_filter_arginfo, ZEND_ACC_PUBLIC)
320361
PHP_ME(vtiful_excel, insertText, excel_insert_text_arginfo, ZEND_ACC_PUBLIC)
321362
PHP_ME(vtiful_excel, insertImage, excel_insert_image_arginfo, ZEND_ACC_PUBLIC)
322363
PHP_ME(vtiful_excel, insertFormula, excel_insert_formula_arginfo, ZEND_ACC_PUBLIC)

kernel/excel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ extern zend_class_entry *vtiful_excel_ce;
2929

3030
VTIFUL_STARTUP_FUNCTION(excel);
3131

32+
excel_resource_t * zval_get_resource(zval *handle);
33+
3234
#endif

0 commit comments

Comments
 (0)