Browse Source

STYLE(CODE): EXCEL TO XLS

viest 7 years ago
parent
commit
0bbb26408e
16 changed files with 266 additions and 187 deletions
  1. 13 1
      kernel/common.c
  2. 101 102
      kernel/excel.c
  3. 11 11
      kernel/excel.h
  4. 2 2
      kernel/exception.c
  5. 4 4
      kernel/exception.h
  6. 15 15
      kernel/format.c
  7. 4 4
      kernel/format.h
  8. 31 19
      kernel/include.h
  9. 18 6
      kernel/resource.c
  10. 12 14
      kernel/write.c
  11. 4 4
      php_xls_writer.h
  12. 23 0
      tests/011.phpt
  13. 23 0
      tests/012.phpt
  14. BIN
      tests/tutorial01.xlsx
  15. BIN
      tests/tutorial02.xlsx
  16. 5 5
      xls_writer.c

+ 13 - 1
kernel/common.c

@@ -1,6 +1,18 @@
+/*
+  +----------------------------------------------------------------------+
+  | XlsWriter Extension                                                  |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2017-2018 The Viest                                    |
+  +----------------------------------------------------------------------+
+  | http://www.viest.me                                                  |
+  +----------------------------------------------------------------------+
+  | Author: viest <[email protected]>                                 |
+  +----------------------------------------------------------------------+
+*/
+
 #include "include.h"
 
-void excel_file_path(zend_string *file_name, zval *dir_path, zval *file_path)
+void xls_file_path(zend_string *file_name, zval *dir_path, zval *file_path)
 {
     zend_string *full_path, *zstr_path;
 

+ 101 - 102
kernel/excel.c

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -16,9 +16,9 @@
 
 #include "include.h"
 
-zend_class_entry *vtiful_excel_ce;
+zend_class_entry *vtiful_xls_ce;
 
-static zend_object_handlers vtiful_excel_handlers;
+static zend_object_handlers vtiful_xls_handlers;
 
 static zend_always_inline void *vtiful_object_alloc(size_t obj_size, zend_class_entry *ce) {
     void *obj = emalloc(obj_size + zend_object_properties_size(ce));
@@ -26,26 +26,26 @@ static zend_always_inline void *vtiful_object_alloc(size_t obj_size, zend_class_
     return obj;
 }
 
-/* {{{ excel_objects_new
+/* {{{ xls_objects_new
  */
-PHP_VTIFUL_API zend_object *excel_objects_new(zend_class_entry *ce)
+PHP_VTIFUL_API zend_object *vtiful_xls_objects_new(zend_class_entry *ce)
 {
-    excel_object *intern = vtiful_object_alloc(sizeof(excel_object), ce);
+    xls_object *intern = vtiful_object_alloc(sizeof(xls_object), ce);
 
     zend_object_std_init(&intern->zo, ce);
     object_properties_init(&intern->zo, ce);
 
-    intern->zo.handlers = &vtiful_excel_handlers;
+    intern->zo.handlers = &vtiful_xls_handlers;
 
     return &intern->zo;
 }
 /* }}} */
 
-/* {{{ vtiful_excel_objects_free
+/* {{{ vtiful_xls_objects_free
  */
-static void vtiful_excel_objects_free(zend_object *object)
+static void vtiful_xls_objects_free(zend_object *object)
 {
-    excel_object *intern = php_vtiful_excel_fetch_object(object);
+    xls_object *intern = php_vtiful_xls_fetch_object(object);
 
     lxw_workbook_free(intern->ptr.workbook);
 
@@ -55,66 +55,66 @@ static void vtiful_excel_objects_free(zend_object *object)
 
 /* {{{ ARG_INFO
  */
-ZEND_BEGIN_ARG_INFO_EX(excel_construct_arginfo, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(xls_construct_arginfo, 0, 0, 1)
                 ZEND_ARG_INFO(0, config)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_file_name_arginfo, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(xls_file_name_arginfo, 0, 0, 1)
                 ZEND_ARG_INFO(0, file_name)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_header_arginfo, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(xls_header_arginfo, 0, 0, 1)
                 ZEND_ARG_INFO(0, header)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_data_arginfo, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(xls_data_arginfo, 0, 0, 1)
                 ZEND_ARG_INFO(0, data)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_insert_text_arginfo, 0, 0, 4)
+ZEND_BEGIN_ARG_INFO_EX(xls_insert_text_arginfo, 0, 0, 4)
                 ZEND_ARG_INFO(0, row)
                 ZEND_ARG_INFO(0, column)
                 ZEND_ARG_INFO(0, data)
                 ZEND_ARG_INFO(0, format)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_insert_image_arginfo, 0, 0, 3)
+ZEND_BEGIN_ARG_INFO_EX(xls_insert_image_arginfo, 0, 0, 3)
                 ZEND_ARG_INFO(0, row)
                 ZEND_ARG_INFO(0, column)
                 ZEND_ARG_INFO(0, image)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_insert_formula_arginfo, 0, 0, 3)
+ZEND_BEGIN_ARG_INFO_EX(xls_insert_formula_arginfo, 0, 0, 3)
                 ZEND_ARG_INFO(0, row)
                 ZEND_ARG_INFO(0, column)
                 ZEND_ARG_INFO(0, formula)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_auto_filter_arginfo, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(xls_auto_filter_arginfo, 0, 0, 1)
                 ZEND_ARG_INFO(0, range)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_merge_cells_arginfo, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(xls_merge_cells_arginfo, 0, 0, 2)
                 ZEND_ARG_INFO(0, range)
                 ZEND_ARG_INFO(0, data)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_set_column_arginfo, 0, 0, 3)
+ZEND_BEGIN_ARG_INFO_EX(xls_set_column_arginfo, 0, 0, 3)
                 ZEND_ARG_INFO(0, format_handle)
                 ZEND_ARG_INFO(0, range)
                 ZEND_ARG_INFO(0, width)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(excel_set_row_arginfo, 0, 0, 3)
+ZEND_BEGIN_ARG_INFO_EX(xls_set_row_arginfo, 0, 0, 3)
                 ZEND_ARG_INFO(0, format_handle)
                 ZEND_ARG_INFO(0, range)
                 ZEND_ARG_INFO(0, height)
 ZEND_END_ARG_INFO()
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::__construct(array $config)
+/** {{{ \Vtiful\Kernel\xls::__construct(array $config)
  */
-PHP_METHOD(vtiful_excel, __construct)
+PHP_METHOD(vtiful_xls, __construct)
 {
     zval *config, *c_path;
 
@@ -122,7 +122,7 @@ PHP_METHOD(vtiful_excel, __construct)
             Z_PARAM_ARRAY(config)
     ZEND_PARSE_PARAMETERS_END();
 
-    if((c_path = zend_hash_str_find(Z_ARRVAL_P(config), ZEND_STRL(V_EXCEL_PAT))) == NULL)
+    if((c_path = zend_hash_str_find(Z_ARRVAL_P(config), ZEND_STRL(V_XLS_PAT))) == NULL)
     {
         zend_throw_exception(vtiful_exception_ce, "Lack of 'path' configuration", 110);
         return;
@@ -134,13 +134,13 @@ PHP_METHOD(vtiful_excel, __construct)
         return;
     }
 
-    add_property_zval(getThis(), V_EXCEL_COF, config);
+    add_property_zval(getThis(), V_XLS_COF, config);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::filename(string $fileName)
+/** {{{ \Vtiful\Kernel\xls::filename(string $fileName)
  */
-PHP_METHOD(vtiful_excel, fileName)
+PHP_METHOD(vtiful_xls, fileName)
 {
     zval file_path, *dir_path;
     zend_string *file_name;
@@ -151,26 +151,26 @@ PHP_METHOD(vtiful_excel, fileName)
 
     ZVAL_COPY(return_value, getThis());
 
-    GET_CONFIG_PATH(dir_path, vtiful_excel_ce, return_value);
+    GET_CONFIG_PATH(dir_path, vtiful_xls_ce, return_value);
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     if(obj->ptr.workbook == NULL) {
-        excel_file_path(file_name, dir_path, &file_path);
+        xls_file_path(file_name, dir_path, &file_path);
 
         obj->ptr.workbook  = workbook_new(Z_STRVAL(file_path));
         obj->ptr.worksheet = workbook_add_worksheet(obj->ptr.workbook, NULL);
 
-        add_property_zval(return_value, V_EXCEL_FIL, &file_path);
+        add_property_zval(return_value, V_XLS_FIL, &file_path);
 
         zval_ptr_dtor(&file_path);
     }
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::constMemory(string $fileName)
+/** {{{ \Vtiful\Kernel\xls::constMemory(string $fileName)
  */
-PHP_METHOD(vtiful_excel, constMemory)
+PHP_METHOD(vtiful_xls, constMemory)
 {
     zval file_path, *dir_path;
     zend_string *file_name;
@@ -181,19 +181,19 @@ PHP_METHOD(vtiful_excel, constMemory)
 
     ZVAL_COPY(return_value, getThis());
 
-    GET_CONFIG_PATH(dir_path, vtiful_excel_ce, return_value);
+    GET_CONFIG_PATH(dir_path, vtiful_xls_ce, return_value);
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     if(obj->ptr.workbook == NULL) {
-        excel_file_path(file_name, dir_path, &file_path);
+        xls_file_path(file_name, dir_path, &file_path);
 
         lxw_workbook_options options = {.constant_memory = LXW_TRUE, .tmpdir = NULL};
 
         obj->ptr.workbook  = workbook_new_opt(Z_STRVAL(file_path), &options);
         obj->ptr.worksheet = workbook_add_worksheet(obj->ptr.workbook, NULL);
 
-        add_property_zval(return_value, V_EXCEL_FIL, &file_path);
+        add_property_zval(return_value, V_XLS_FIL, &file_path);
 
         zval_ptr_dtor(&file_path);
     }
@@ -201,9 +201,9 @@ PHP_METHOD(vtiful_excel, constMemory)
 /* }}} */
 
 
-/** {{{ \Vtiful\Kernel\Excel::header(array $header)
+/** {{{ \Vtiful\Kernel\xls::header(array $header)
  */
-PHP_METHOD(vtiful_excel, header)
+PHP_METHOD(vtiful_xls, header)
 {
     zval *header, *header_value;
     zend_long header_l_key;
@@ -214,7 +214,7 @@ PHP_METHOD(vtiful_excel, header)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(header), header_l_key, header_value) {
          type_writer(header_value, 0, header_l_key, &obj->ptr, NULL);
@@ -223,9 +223,9 @@ PHP_METHOD(vtiful_excel, header)
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::data(array $data)
+/** {{{ \Vtiful\Kernel\xls::data(array $data)
  */
-PHP_METHOD(vtiful_excel, data)
+PHP_METHOD(vtiful_xls, data)
 {
     zval *data, *data_r_value, *data_l_value;
     zend_long data_r_key, data_l_key;
@@ -236,7 +236,7 @@ PHP_METHOD(vtiful_excel, data)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     ZEND_HASH_FOREACH_NUM_KEY_VAL(Z_ARRVAL_P(data), data_r_key, data_r_value) {
         if(Z_TYPE_P(data_r_value) == IS_ARRAY) {
@@ -249,38 +249,38 @@ PHP_METHOD(vtiful_excel, data)
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::output()
+/** {{{ \Vtiful\Kernel\xls::output()
  */
-PHP_METHOD(vtiful_excel, output)
+PHP_METHOD(vtiful_xls, output)
 {
     zval rv, *file_path;
 
-    file_path = zend_read_property(vtiful_excel_ce, getThis(), ZEND_STRL(V_EXCEL_FIL), 0, &rv TSRMLS_DC);
+    file_path = zend_read_property(vtiful_xls_ce, getThis(), ZEND_STRL(V_XLS_FIL), 0, &rv TSRMLS_DC);
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     workbook_file(&obj->ptr);
 
-    add_property_null(getThis(), V_EXCEL_HANDLE);
-    add_property_null(getThis(), V_EXCEL_PAT);
+    add_property_null(getThis(), V_XLS_HANDLE);
+    add_property_null(getThis(), V_XLS_PAT);
 
     ZVAL_COPY(return_value, file_path);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::getHandle()
+/** {{{ \Vtiful\Kernel\xls::getHandle()
  */
-PHP_METHOD(vtiful_excel, getHandle)
+PHP_METHOD(vtiful_xls, getHandle)
 {
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
-    RETURN_RES(zend_register_resource(&obj->ptr, le_excel_writer));
+    RETURN_RES(zend_register_resource(&obj->ptr, le_xls_writer));
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::insertText(int $row, int $column, string|int|double $data)
+/** {{{ \Vtiful\Kernel\xls::insertText(int $row, int $column, string|int|double $data)
  */
-PHP_METHOD(vtiful_excel, insertText)
+PHP_METHOD(vtiful_xls, insertText)
 {
     zval *data;
     zend_long row, column;
@@ -296,15 +296,15 @@ PHP_METHOD(vtiful_excel, insertText)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     type_writer(data, row, column, &obj->ptr, format);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
+/** {{{ \Vtiful\Kernel\xls::insertImage(int $row, int $column, string $imagePath)
  */
-PHP_METHOD(vtiful_excel, insertImage)
+PHP_METHOD(vtiful_xls, insertImage)
 {
     zval *image;
     zend_long row, column;
@@ -317,15 +317,15 @@ PHP_METHOD(vtiful_excel, insertImage)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     image_writer(image, row, column, &obj->ptr);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::insertImage(int $row, int $column, string $imagePath)
+/** {{{ \Vtiful\Kernel\xls::insertImage(int $row, int $column, string $imagePath)
  */
-PHP_METHOD(vtiful_excel, insertFormula)
+PHP_METHOD(vtiful_xls, insertFormula)
 {
     zval *formula;
     zend_long row, column;
@@ -338,15 +338,15 @@ PHP_METHOD(vtiful_excel, insertFormula)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     formula_writer(formula, row, column, &obj->ptr);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
+/** {{{ \Vtiful\Kernel\xls::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
  */
-PHP_METHOD(vtiful_excel, autoFilter)
+PHP_METHOD(vtiful_xls, autoFilter)
 {
     zend_string *range;
 
@@ -356,17 +356,16 @@ PHP_METHOD(vtiful_excel, autoFilter)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     auto_filter(range, &obj->ptr);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::mergeCells(string $range, string $data)
+/** {{{ \Vtiful\Kernel\xls::mergeCells(string $range, string $data)
  */
-PHP_METHOD(vtiful_excel, mergeCells)
+PHP_METHOD(vtiful_xls, mergeCells)
 {
-    zval res_handle;
     zend_string *range, *data;
 
     ZEND_PARSE_PARAMETERS_START(2, 2)
@@ -376,17 +375,17 @@ PHP_METHOD(vtiful_excel, mergeCells)
 
     ZVAL_COPY(return_value, getThis());
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     merge_cells(range, data, &obj->ptr);
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::setColumn(resource $format, string $range [, int $width])
+/** {{{ \Vtiful\Kernel\xls::setColumn(resource $format, string $range [, int $width])
  */
-PHP_METHOD(vtiful_excel, setColumn)
+PHP_METHOD(vtiful_xls, setColumn)
 {
-    zval *format_handle, res_handle;
+    zval *format_handle;
     zend_string *range;
 
     double width = 0;
@@ -405,17 +404,17 @@ PHP_METHOD(vtiful_excel, setColumn)
         width = 10;
     }
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     set_column(range, width, &obj->ptr, zval_get_format(format_handle));
 }
 /* }}} */
 
-/** {{{ \Vtiful\Kernel\Excel::setRow(resource $format, string $range [, int $heitght])
+/** {{{ \Vtiful\Kernel\xls::setRow(resource $format, string $range [, int $heitght])
  */
-PHP_METHOD(vtiful_excel, setRow)
+PHP_METHOD(vtiful_xls, setRow)
 {
-    zval *format_handle, res_handle;
+    zval *format_handle;
     zend_string *range;
 
     double height = 0;
@@ -434,29 +433,29 @@ PHP_METHOD(vtiful_excel, setRow)
         height = 18;
     }
 
-    excel_object *obj = Z_EXCEL_P(getThis());
+    xls_object *obj = Z_XLS_P(getThis());
 
     set_row(range, height, &obj->ptr, zval_get_format(format_handle));
 }
 /* }}} */
 
-/** {{{ excel_methods
+/** {{{ xls_methods
 */
-zend_function_entry excel_methods[] = {
-        PHP_ME(vtiful_excel, __construct,   excel_construct_arginfo,      ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-        PHP_ME(vtiful_excel, fileName,      excel_file_name_arginfo,      ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, constMemory,   excel_file_name_arginfo,      ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, header,        excel_header_arginfo,         ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, data,          excel_data_arginfo,           ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, output,        NULL,                         ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, getHandle,     NULL,                         ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, autoFilter,    excel_auto_filter_arginfo,    ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, insertText,    excel_insert_text_arginfo,    ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, insertImage,   excel_insert_image_arginfo,   ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, insertFormula, excel_insert_formula_arginfo, ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, mergeCells,    excel_merge_cells_arginfo,    ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, setColumn,     excel_set_column_arginfo,     ZEND_ACC_PUBLIC)
-        PHP_ME(vtiful_excel, setRow,        excel_set_row_arginfo,        ZEND_ACC_PUBLIC)
+zend_function_entry xls_methods[] = {
+        PHP_ME(vtiful_xls, __construct,   xls_construct_arginfo,      ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+        PHP_ME(vtiful_xls, fileName,      xls_file_name_arginfo,      ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, constMemory,   xls_file_name_arginfo,      ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, header,        xls_header_arginfo,         ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, data,          xls_data_arginfo,           ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, output,        NULL,                       ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, getHandle,     NULL,                       ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, autoFilter,    xls_auto_filter_arginfo,    ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, insertText,    xls_insert_text_arginfo,    ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, insertImage,   xls_insert_image_arginfo,   ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, insertFormula, xls_insert_formula_arginfo, ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, mergeCells,    xls_merge_cells_arginfo,    ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, setColumn,     xls_set_column_arginfo,     ZEND_ACC_PUBLIC)
+        PHP_ME(vtiful_xls, setRow,        xls_set_row_arginfo,        ZEND_ACC_PUBLIC)
         PHP_FE_END
 };
 /* }}} */
@@ -466,16 +465,16 @@ zend_function_entry excel_methods[] = {
 VTIFUL_STARTUP_FUNCTION(excel) {
     zend_class_entry ce;
 
-    INIT_NS_CLASS_ENTRY(ce, "Vtiful\\Kernel", "Excel", excel_methods);
-    ce.create_object = excel_objects_new;
-    vtiful_excel_ce = zend_register_internal_class(&ce);
+    INIT_NS_CLASS_ENTRY(ce, "Vtiful\\Kernel", "Excel", xls_methods);
+    ce.create_object = vtiful_xls_objects_new;
+    vtiful_xls_ce = zend_register_internal_class(&ce);
 
-    memcpy(&vtiful_excel_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    vtiful_excel_handlers.offset   = XtOffsetOf(excel_object, zo);
-    vtiful_excel_handlers.free_obj = vtiful_excel_objects_free;
+    memcpy(&vtiful_xls_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+    vtiful_xls_handlers.offset   = XtOffsetOf(xls_object, zo);
+    vtiful_xls_handlers.free_obj = vtiful_xls_objects_free;
 
-    REGISTER_CLASS_PROPERTY_NULL(vtiful_excel_ce, V_EXCEL_COF, ZEND_ACC_PRIVATE);
-    REGISTER_CLASS_PROPERTY_NULL(vtiful_excel_ce, V_EXCEL_FIL, ZEND_ACC_PRIVATE);
+    REGISTER_CLASS_PROPERTY_NULL(vtiful_xls_ce, V_XLS_COF, ZEND_ACC_PRIVATE);
+    REGISTER_CLASS_PROPERTY_NULL(vtiful_xls_ce, V_XLS_FIL, ZEND_ACC_PRIVATE);
 
     return SUCCESS;
 }

+ 11 - 11
kernel/excel.h

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -10,21 +10,21 @@
   +----------------------------------------------------------------------+
 */
 
-#ifndef VTIFUL_EXCEL_H
-#define VTIFUL_EXCEL_H
+#ifndef VTIFUL_XLS_H
+#define VTIFUL_XLS_H
 
-#define V_EXCEL_HANDLE "handle"
-#define V_EXCEL_FIL "fileName"
-#define V_EXCEL_COF "config"
-#define V_EXCEL_PAT "path"
+#define V_XLS_HANDLE "handle"
+#define V_XLS_FIL    "fileName"
+#define V_XLS_COF    "config"
+#define V_XLS_PAT    "path"
 
 #define GET_CONFIG_PATH(dir_path_res, class_name, object)                                             \
     do {                                                                                              \
-        zval *_config  = zend_read_property(class_name, object, ZEND_STRL(V_EXCEL_COF), 0, NULL);     \
-        (dir_path_res) = zend_hash_str_find(Z_ARRVAL_P(_config), ZEND_STRL(V_EXCEL_PAT));             \
+        zval *_config  = zend_read_property(class_name, object, ZEND_STRL(V_XLS_COF), 0, NULL);     \
+        (dir_path_res) = zend_hash_str_find(Z_ARRVAL_P(_config), ZEND_STRL(V_XLS_PAT));             \
     } while(0)
 
-extern zend_class_entry *vtiful_excel_ce;
+extern zend_class_entry *vtiful_xls_ce;
 
 VTIFUL_STARTUP_FUNCTION(excel);
 

+ 2 - 2
kernel/exception.c

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+

+ 4 - 4
kernel/exception.h

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -10,8 +10,8 @@
   +----------------------------------------------------------------------+
 */
 
-#ifndef VTIFUL_EXCEL_EXCEPTION_H
-#define VTIFUL_EXCEL_EXCEPTION_H
+#ifndef VTIFUL_XLS_EXCEPTION_H
+#define VTIFUL_XLS_EXCEPTION_H
 
 extern zend_class_entry *vtiful_exception_ce;
 

+ 15 - 15
kernel/format.c

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -36,18 +36,18 @@ PHP_METHOD(vtiful_format, bold)
 {
     zval *handle;
     lxw_format *bold_format;
-    excel_resource_t *excel_res;
+    xls_resource_t *xls_res;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
             Z_PARAM_RESOURCE(handle)
     ZEND_PARSE_PARAMETERS_END();
 
-    excel_res   = zval_get_resource(handle);
-    bold_format = workbook_add_format(excel_res->workbook);
+    xls_res   = zval_get_resource(handle);
+    bold_format = workbook_add_format(xls_res->workbook);
 
     format_set_bold(bold_format);
 
-    RETURN_RES(zend_register_resource(bold_format, le_excel_writer));
+    RETURN_RES(zend_register_resource(bold_format, le_xls_writer));
 }
 /* }}} */
 
@@ -57,18 +57,18 @@ PHP_METHOD(vtiful_format, italic)
 {
     zval *handle;
     lxw_format *italic_format;
-    excel_resource_t *excel_res;
+    xls_resource_t *xls_res;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
             Z_PARAM_RESOURCE(handle)
     ZEND_PARSE_PARAMETERS_END();
 
-    excel_res   = zval_get_resource(handle);
-    italic_format = workbook_add_format(excel_res->workbook);
+    xls_res   = zval_get_resource(handle);
+    italic_format = workbook_add_format(xls_res->workbook);
 
     format_set_italic(italic_format);
 
-    RETURN_RES(zend_register_resource(italic_format, le_excel_writer));
+    RETURN_RES(zend_register_resource(italic_format, le_xls_writer));
 }
 /* }}} */
 
@@ -79,24 +79,24 @@ PHP_METHOD(vtiful_format, underline)
     zval *handle;
     zend_long style;
     lxw_format *underline_format;
-    excel_resource_t *excel_res;
+    xls_resource_t *xls_res;
 
     ZEND_PARSE_PARAMETERS_START(2, 2)
             Z_PARAM_RESOURCE(handle)
             Z_PARAM_LONG(style)
     ZEND_PARSE_PARAMETERS_END();
 
-    excel_res = zval_get_resource(handle);
-    underline_format = workbook_add_format(excel_res->workbook);
+    xls_res = zval_get_resource(handle);
+    underline_format = workbook_add_format(xls_res->workbook);
 
     format_set_underline(underline_format, style);
 
-    RETURN_RES(zend_register_resource(underline_format, le_excel_writer));
+    RETURN_RES(zend_register_resource(underline_format, le_xls_writer));
 }
 /* }}} */
 
 
-/** {{{ excel_methods
+/** {{{ xls_methods
 */
 zend_function_entry format_methods[] = {
         PHP_ME(vtiful_format, bold,      format_style_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)

+ 4 - 4
kernel/format.h

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -10,8 +10,8 @@
   +----------------------------------------------------------------------+
 */
 
-#ifndef PHP_EXT_EXCEL_EXPORT_FORMAT_H
-#define PHP_EXT_EXCEL_EXPORT_FORMAT_H
+#ifndef PHP_EXT_XLS_EXPORT_FORMAT_H
+#define PHP_EXT_XLS_EXPORT_FORMAT_H
 
 extern zend_class_entry *vtiful_format_ce;
 

+ 31 - 19
kernel/include.h

@@ -1,5 +1,17 @@
-#ifndef PHP_EXT_EXCEL_EXPORT_INCLUDE_H
-#define PHP_EXT_EXCEL_EXPORT_INCLUDE_H
+/*
+  +----------------------------------------------------------------------+
+  | XlsWriter Extension                                                  |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2017-2018 The Viest                                    |
+  +----------------------------------------------------------------------+
+  | http://www.viest.me                                                  |
+  +----------------------------------------------------------------------+
+  | Author: viest <[email protected]>                                 |
+  +----------------------------------------------------------------------+
+*/
+
+#ifndef PHP_XLS_WRITER_INCLUDE_H
+#define PHP_XLS_WRITER_INCLUDE_H
 
 #include <php.h>
 
@@ -20,15 +32,15 @@
 typedef struct {
     lxw_workbook  *workbook;
     lxw_worksheet *worksheet;
-} excel_resource_t;
+} xls_resource_t;
 
-typedef struct _vtiful_excel_object {
-    excel_resource_t ptr;
+typedef struct _vtiful_xls_object {
+    xls_resource_t ptr;
     zend_object      zo;
-} excel_object;
+} xls_object;
 
-static inline excel_object *php_vtiful_excel_fetch_object(zend_object *obj) {
-    return (excel_object *)((char *)(obj) - XtOffsetOf(excel_object, zo));
+static inline xls_object *php_vtiful_xls_fetch_object(zend_object *obj) {
+    return (xls_object *)((char *)(obj) - XtOffsetOf(xls_object, zo));
 }
 
 #define REGISTER_CLASS_CONST_LONG(class_name, const_name, value) \
@@ -37,12 +49,12 @@ static inline excel_object *php_vtiful_excel_fetch_object(zend_object *obj) {
 #define REGISTER_CLASS_PROPERTY_NULL(class_name, property_name, acc) \
     zend_declare_property_null(class_name, ZEND_STRL(property_name), acc);
 
-#define Z_EXCEL_P(zv) php_vtiful_excel_fetch_object(Z_OBJ_P(zv));
+#define Z_XLS_P(zv) php_vtiful_xls_fetch_object(Z_OBJ_P(zv));
 
 #define ROW(range) \
     lxw_name_to_row(range)
 
-excel_resource_t * zval_get_resource(zval *handle);
+xls_resource_t * zval_get_resource(zval *handle);
 lxw_format       * zval_get_format(zval *handle);
 
 STATIC lxw_error _store_defined_name(lxw_workbook *self, const char *name, const char *app_name, const char *formula, int16_t index, uint8_t hidden);
@@ -54,15 +66,15 @@ STATIC int  _compare_defined_names(lxw_defined_name *a, lxw_defined_name *b);
 STATIC void _populate_range(lxw_workbook *self, lxw_series_range *range);
 STATIC void _populate_range_dimensions(lxw_workbook *self, lxw_series_range *range);
 
-void type_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res, zend_string *format);
-void image_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res);
-void formula_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res);
-void auto_filter(zend_string *range, excel_resource_t *res);
-void merge_cells(zend_string *range, zend_string *value, excel_resource_t *res);
-void set_column(zend_string *range, double width, excel_resource_t *res, lxw_format *format);
-void set_row(zend_string *range, double height, excel_resource_t *res, lxw_format *format);
-lxw_error workbook_file(excel_resource_t *self);
+void type_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res, zend_string *format);
+void image_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res);
+void formula_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res);
+void auto_filter(zend_string *range, xls_resource_t *res);
+void merge_cells(zend_string *range, zend_string *value, xls_resource_t *res);
+void set_column(zend_string *range, double width, xls_resource_t *res, lxw_format *format);
+void set_row(zend_string *range, double height, xls_resource_t *res, lxw_format *format);
+lxw_error workbook_file(xls_resource_t *self);
 
-void excel_file_path(zend_string *file_name, zval *dir_path, zval *file_path);
+void xls_file_path(zend_string *file_name, zval *dir_path, zval *file_path);
 
 #endif

+ 18 - 6
kernel/resource.c

@@ -1,12 +1,24 @@
+/*
+  +----------------------------------------------------------------------+
+  | XlsWriter Extension                                                  |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 2017-2018 The Viest                                    |
+  +----------------------------------------------------------------------+
+  | http://www.viest.me                                                  |
+  +----------------------------------------------------------------------+
+  | Author: viest <[email protected]>                                 |
+  +----------------------------------------------------------------------+
+*/
+
 #include "include.h"
 
 /* {{{ */
-excel_resource_t * zval_get_resource(zval *handle)
+xls_resource_t * zval_get_resource(zval *handle)
 {
-    excel_resource_t *res;
+    xls_resource_t *res;
 
-    if((res = (excel_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_excel_writer)) == NULL) {
-        zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
+    if((res = (xls_resource_t *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_xls_writer)) == NULL) {
+        zend_throw_exception(vtiful_exception_ce, "XLS resources resolution fail", 210);
     }
 
     return res;
@@ -18,8 +30,8 @@ lxw_format * zval_get_format(zval *handle)
 {
     lxw_format *res;
 
-    if((res = (lxw_format *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_excel_writer)) == NULL) {
-        zend_throw_exception(vtiful_exception_ce, "Excel resources resolution fail", 210);
+    if((res = (lxw_format *)zend_fetch_resource(Z_RES_P(handle), VTIFUL_RESOURCE_NAME, le_xls_writer)) == NULL) {
+        zend_throw_exception(vtiful_exception_ce, "XLS resources resolution fail", 210);
     }
 
     return res;

+ 12 - 14
kernel/write.c

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -15,7 +15,7 @@
 /*
  * According to the zval type written to the file
  */
-void type_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res, zend_string *format)
+void type_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res, zend_string *format)
 {
     lxw_format *value_format = NULL;
 
@@ -47,7 +47,7 @@ void type_writer(zval *value, zend_long row, zend_long columns, excel_resource_t
 /*
  * Write the image to the file
  */
-void image_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res)
+void image_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res)
 {
     worksheet_insert_image(res->worksheet, row, columns, ZSTR_VAL(zval_get_string(value)));
 }
@@ -55,7 +55,7 @@ void image_writer(zval *value, zend_long row, zend_long columns, excel_resource_
 /*
  * Write the image to the file
  */
-void formula_writer(zval *value, zend_long row, zend_long columns, excel_resource_t *res)
+void formula_writer(zval *value, zend_long row, zend_long columns, xls_resource_t *res)
 {
     worksheet_write_formula(res->worksheet, row, columns, ZSTR_VAL(zval_get_string(value)), NULL);
 }
@@ -63,7 +63,7 @@ void formula_writer(zval *value, zend_long row, zend_long columns, excel_resourc
 /*
  * Add the autofilter.
  */
-void auto_filter(zend_string *range, excel_resource_t *res)
+void auto_filter(zend_string *range, xls_resource_t *res)
 {
     worksheet_autofilter(res->worksheet, RANGE(ZSTR_VAL(range)));
 }
@@ -71,7 +71,7 @@ void auto_filter(zend_string *range, excel_resource_t *res)
 /*
  * Merge cells.
  */
-void merge_cells(zend_string *range, zend_string *value, excel_resource_t *res)
+void merge_cells(zend_string *range, zend_string *value, xls_resource_t *res)
 {
     worksheet_merge_range(res->worksheet, RANGE(ZSTR_VAL(range)), ZSTR_VAL(value), NULL);
 }
@@ -79,7 +79,7 @@ void merge_cells(zend_string *range, zend_string *value, excel_resource_t *res)
 /*
  * Set column format
  */
-void set_column(zend_string *range, double width, excel_resource_t *res, lxw_format *format)
+void set_column(zend_string *range, double width, xls_resource_t *res, lxw_format *format)
 {
     worksheet_set_column(res->worksheet, COLS(ZSTR_VAL(range)), width, format);
 }
@@ -87,7 +87,7 @@ void set_column(zend_string *range, double width, excel_resource_t *res, lxw_for
 /*
  * Set row format
  */
-void set_row(zend_string *range, double height, excel_resource_t *res, lxw_format *format)
+void set_row(zend_string *range, double height, xls_resource_t *res, lxw_format *format)
 {
     worksheet_set_row(res->worksheet, ROW(ZSTR_VAL(range)), height, format);
 }
@@ -96,7 +96,7 @@ void set_row(zend_string *range, double height, excel_resource_t *res, lxw_forma
  * Call finalization code and close file.
  */
 lxw_error
-workbook_file(excel_resource_t *self)
+workbook_file(xls_resource_t *self)
 {
     lxw_worksheet *worksheet = NULL;
     lxw_packager *packager = NULL;
@@ -175,15 +175,13 @@ workbook_file(excel_resource_t *self)
 
     mem_error:
         lxw_packager_free(packager);
-//        lxw_workbook_free(self->workbook);
-//        self->worksheet->index
 
     return error;
 }
 
-void _php_vtiful_excel_close(zend_resource *rsrc TSRMLS_DC)
+void _php_vtiful_xls_close(zend_resource *rsrc TSRMLS_DC)
 {
-    //Here to PHP for gc
+
 }
 
 /*

+ 4 - 4
php_xls_writer.h

@@ -1,8 +1,8 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
   | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
@@ -34,12 +34,12 @@ extern zend_module_entry xlswriter_module_entry;
 
 #define VTIFUL_RESOURCE_NAME "xlsx"
 
-extern int le_excel_writer;
+extern int le_xls_writer;
 
 #define VTIFUL_STARTUP_MODULE(module) ZEND_MODULE_STARTUP_N(xlsxwriter_##module)(INIT_FUNC_ARGS_PASSTHRU)
 #define VTIFUL_STARTUP_FUNCTION(module) ZEND_MINIT_FUNCTION(xlsxwriter_##module)
 
-void _php_vtiful_excel_close(zend_resource *rsrc TSRMLS_DC);
+void _php_vtiful_xls_close(zend_resource *rsrc TSRMLS_DC);
 
 #if defined(ZTS) && defined(COMPILE_DL_VTIFUL)
 ZEND_TSRMLS_CACHE_EXTERN();

+ 23 - 0
tests/011.phpt

@@ -0,0 +1,23 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php 
+$config = ['path' => './tests'];
+$excel  = new \Vtiful\Kernel\Excel($config);
+
+$fileObject = $excel->fileName('tutorial01.xlsx');
+$fileHandle = $fileObject->getHandle();
+
+$boldStyle = \Vtiful\Kernel\Format::bold($fileHandle);
+
+$filePath = $fileObject->header(['name', 'age'])
+    ->data([['viest', 21]])
+    ->setColumn($boldStyle, 'A:A', 200)
+    ->output();
+
+var_dump($filePath);
+?>
+--EXPECT--
+string(23) "./tests/tutorial01.xlsx"

+ 23 - 0
tests/012.phpt

@@ -0,0 +1,23 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php 
+$config = ['path' => './tests'];
+$excel  = new \Vtiful\Kernel\Excel($config);
+
+$fileObject = $excel->fileName('tutorial01.xlsx');
+$fileHandle = $fileObject->getHandle();
+
+$boldStyle = \Vtiful\Kernel\Format::bold($fileHandle);
+
+$filePath = $fileObject->header(['name', 'age'])
+    ->data([['viest', 21]])
+    ->setRow($boldStyle, 'A1')
+    ->output();
+
+var_dump($filePath);
+?>
+--EXPECT--
+string(23) "./tests/tutorial01.xlsx"

BIN
tests/tutorial01.xlsx


BIN
tests/tutorial02.xlsx


+ 5 - 5
xls_writer.c

@@ -1,10 +1,10 @@
 /*
   +----------------------------------------------------------------------+
-  | Vtiful Extension                                                     |
+  | XlsWriter Extension                                                  |
   +----------------------------------------------------------------------+
-  | Copyright (c) 2017-2017 The Viest                                    |
+  | Copyright (c) 2017-2018 The Viest                                    |
   +----------------------------------------------------------------------+
-  | http://www.vtiful.com                                                |
+  | http://www.viest.me                                                  |
   +----------------------------------------------------------------------+
   | Author: viest <[email protected]>                                 |
   +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
 #include "ext/standard/info.h"
 #include "kernel/include.h"
 
-int le_excel_writer;
+int le_xls_writer;
 
 /* {{{ PHP_MINIT_FUNCTION
  */
@@ -28,7 +28,7 @@ PHP_MINIT_FUNCTION(xlswriter)
 	VTIFUL_STARTUP_MODULE(excel);
 	VTIFUL_STARTUP_MODULE(format);
 
-    le_excel_writer = zend_register_list_destructors_ex(_php_vtiful_excel_close, NULL, VTIFUL_RESOURCE_NAME, module_number);
+	le_xls_writer = zend_register_list_destructors_ex(_php_vtiful_xls_close, NULL, VTIFUL_RESOURCE_NAME, module_number);
 
 	return SUCCESS;
 }