@@ -37,7 +37,9 @@ PHP_VTIFUL_API zend_object *vtiful_xls_objects_new(zend_class_entry *ce)
3737
3838 intern -> read_ptr .file_t = NULL ;
3939 intern -> read_ptr .sheet_t = NULL ;
40- intern -> format_ptr .format = NULL ;
40+
41+ intern -> format_ptr .format = NULL ;
42+ intern -> write_ptr .workbook = NULL ;
4143
4244 intern -> read_ptr .data_type_default = READ_TYPE_EMPTY ;
4345
@@ -51,16 +53,7 @@ static void vtiful_xls_objects_free(zend_object *object)
5153{
5254 xls_object * intern = php_vtiful_xls_fetch_object (object );
5355
54- lxw_workbook_free (intern -> write_ptr .workbook );
55-
56- #ifdef ENABLE_READER
57- xlsxioread_sheet_close (intern -> read_ptr .sheet_t );
58- xlsxioread_close (intern -> read_ptr .file_t );
59- #endif
60-
61- if (intern -> format_ptr .format != NULL ) {
62- intern -> format_ptr .format = NULL ;
63- }
56+ php_vtiful_close_resource (object );
6457
6558 zend_object_std_dtor (& intern -> zo );
6659}
@@ -72,6 +65,9 @@ ZEND_BEGIN_ARG_INFO_EX(xls_construct_arginfo, 0, 0, 1)
7265 ZEND_ARG_INFO (0 , config )
7366ZEND_END_ARG_INFO ()
7467
68+ ZEND_BEGIN_ARG_INFO_EX (xls_close_arginfo , 0 , 0 , 0 )
69+ ZEND_END_ARG_INFO ()
70+
7571ZEND_BEGIN_ARG_INFO_EX (xls_file_name_arginfo , 0 , 0 , 1 )
7672 ZEND_ARG_INFO (0 , file_name )
7773 ZEND_ARG_INFO (0 , sheet_name )
@@ -310,6 +306,16 @@ PHP_METHOD(vtiful_xls, __construct)
310306}
311307/* }}} */
312308
309+ /** {{{ \Vtiful\Kernel\Excel::close()
310+ */
311+ PHP_METHOD (vtiful_xls , close )
312+ {
313+ php_vtiful_close_resource (Z_OBJ_P (getThis ()));
314+
315+ ZVAL_COPY (return_value , getThis ());
316+ }
317+ /* }}} */
318+
313319/** {{{ \Vtiful\Kernel\Excel::filename(string $fileName [, string $sheetName])
314320 */
315321PHP_METHOD (vtiful_xls , fileName )
@@ -1489,6 +1495,7 @@ PHP_METHOD(vtiful_xls, nextCellCallback)
14891495*/
14901496zend_function_entry xls_methods [] = {
14911497 PHP_ME (vtiful_xls , __construct , xls_construct_arginfo , ZEND_ACC_PUBLIC )
1498+ PHP_ME (vtiful_xls , close , xls_close_arginfo , ZEND_ACC_PUBLIC )
14921499 PHP_ME (vtiful_xls , fileName , xls_file_name_arginfo , ZEND_ACC_PUBLIC )
14931500 PHP_ME (vtiful_xls , addSheet , xls_file_add_sheet , ZEND_ACC_PUBLIC )
14941501 PHP_ME (vtiful_xls , checkoutSheet , xls_file_checkout_sheet , ZEND_ACC_PUBLIC )
0 commit comments