@@ -163,6 +163,10 @@ ZEND_BEGIN_ARG_INFO_EX(xls_open_sheet_arginfo, 0, 0, 1)
163163 ZEND_ARG_INFO (0 , zs_sheet_name )
164164ZEND_END_ARG_INFO ()
165165
166+ ZEND_BEGIN_ARG_INFO_EX (xls_set_type_arginfo , 0 , 0 , 1 )
167+ ZEND_ARG_INFO (0 , zv_type_t )
168+ ZEND_END_ARG_INFO ()
169+
166170ZEND_BEGIN_ARG_INFO_EX (xls_next_cell_callback_arginfo , 0 , 0 , 2 )
167171 ZEND_ARG_INFO (0 , fci )
168172 ZEND_ARG_INFO (0 , sheet_name )
@@ -754,6 +758,22 @@ PHP_METHOD(vtiful_xls, openSheet)
754758}
755759/* }}} */
756760
761+ /** {{{ \Vtiful\Kernel\xls::setType(array $rowType)
762+ */
763+ PHP_METHOD (vtiful_xls , setType )
764+ {
765+ zval * zv_type_t = NULL ;
766+
767+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
768+ Z_PARAM_ARRAY (zv_type_t )
769+ ZEND_PARSE_PARAMETERS_END ();
770+
771+ ZVAL_COPY (return_value , getThis ());
772+
773+ add_property_zval_ex (getThis (), ZEND_STRL (V_XLS_TYPE ), zv_type_t );
774+ }
775+ /* }}} */
776+
757777/** {{{ \Vtiful\Kernel\xls::getSheetData()
758778 */
759779PHP_METHOD (vtiful_xls , getSheetData )
@@ -764,7 +784,15 @@ PHP_METHOD(vtiful_xls, getSheetData)
764784 RETURN_FALSE ;
765785 }
766786
767- load_sheet_all_data (obj -> read_ptr .sheet_t , return_value );
787+ zval * zv_type = zend_read_property (vtiful_xls_ce , getThis (), ZEND_STRL (V_XLS_TYPE ), 0 , NULL );
788+
789+ if (zv_type != NULL && Z_TYPE_P (zv_type ) == IS_ARRAY ) {
790+ load_sheet_all_data (obj -> read_ptr .sheet_t , zv_type , return_value );
791+
792+ return ;
793+ }
794+
795+ load_sheet_all_data (obj -> read_ptr .sheet_t , NULL , return_value );
768796}
769797/* }}} */
770798
@@ -785,6 +813,10 @@ PHP_METHOD(vtiful_xls, nextRow)
785813 RETURN_FALSE ;
786814 }
787815
816+ if (zv_type == NULL ) {
817+ zv_type = zend_read_property (vtiful_xls_ce , getThis (), ZEND_STRL (V_XLS_TYPE ), 0 , NULL );
818+ }
819+
788820 load_sheet_current_row_data (obj -> read_ptr .sheet_t , return_value , zv_type , READ_ROW );
789821}
790822/* }}} */
@@ -846,6 +878,7 @@ zend_function_entry xls_methods[] = {
846878#ifdef ENABLE_READER
847879 PHP_ME (vtiful_xls , openFile , xls_open_file_arginfo , ZEND_ACC_PUBLIC )
848880 PHP_ME (vtiful_xls , openSheet , xls_open_sheet_arginfo , ZEND_ACC_PUBLIC )
881+ PHP_ME (vtiful_xls , setType , xls_set_type_arginfo , ZEND_ACC_PUBLIC )
849882 PHP_ME (vtiful_xls , getSheetData , NULL , ZEND_ACC_PUBLIC )
850883 PHP_ME (vtiful_xls , nextRow , NULL , ZEND_ACC_PUBLIC )
851884 PHP_ME (vtiful_xls , nextCellCallback , xls_next_cell_callback_arginfo , ZEND_ACC_PUBLIC )
@@ -868,8 +901,9 @@ VTIFUL_STARTUP_FUNCTION(excel) {
868901 vtiful_xls_handlers .offset = XtOffsetOf (xls_object , zo );
869902 vtiful_xls_handlers .free_obj = vtiful_xls_objects_free ;
870903
871- REGISTER_CLASS_PROPERTY_NULL (vtiful_xls_ce , V_XLS_COF , ZEND_ACC_PRIVATE );
872- REGISTER_CLASS_PROPERTY_NULL (vtiful_xls_ce , V_XLS_FIL , ZEND_ACC_PRIVATE );
904+ REGISTER_CLASS_PROPERTY_NULL (vtiful_xls_ce , V_XLS_COF , ZEND_ACC_PRIVATE );
905+ REGISTER_CLASS_PROPERTY_NULL (vtiful_xls_ce , V_XLS_FIL , ZEND_ACC_PRIVATE );
906+ REGISTER_CLASS_PROPERTY_NULL (vtiful_xls_ce , V_XLS_TYPE , ZEND_ACC_PRIVATE );
873907
874908#ifdef ENABLE_READER
875909 REGISTER_CLASS_CONST_LONG (vtiful_xls_ce , V_XLS_CONST_READ_SKIP_NONE , XLSXIOREAD_SKIP_NONE );
0 commit comments