@@ -71,6 +71,10 @@ ZEND_BEGIN_ARG_INFO_EX(xls_file_add_sheet, 0, 0, 1)
7171 ZEND_ARG_INFO (0 , sheet_name )
7272ZEND_END_ARG_INFO ()
7373
74+ ZEND_BEGIN_ARG_INFO_EX (xls_file_checkout_sheet , 0 , 0 , 1 )
75+ ZEND_ARG_INFO (0 , sheet_name )
76+ ZEND_END_ARG_INFO ()
77+
7478ZEND_BEGIN_ARG_INFO_EX (xls_header_arginfo , 0 , 0 , 1 )
7579 ZEND_ARG_INFO (0 , header )
7680ZEND_END_ARG_INFO ()
@@ -229,6 +233,40 @@ PHP_METHOD(vtiful_xls, addSheet)
229233}
230234/* }}} */
231235
236+ /** {{{ \Vtiful\Kernel\xls::checkoutSheet(string $sheetName)
237+ */
238+ PHP_METHOD (vtiful_xls , checkoutSheet )
239+ {
240+ int line = 0 ;
241+ lxw_worksheet * sheet_t = NULL ;
242+ zend_string * zs_sheet_name = NULL ;
243+
244+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
245+ Z_PARAM_STR (zs_sheet_name )
246+ ZEND_PARSE_PARAMETERS_END ();
247+
248+ ZVAL_COPY (return_value , getThis ());
249+
250+ xls_object * obj = Z_XLS_P (getThis ());
251+
252+ if (obj -> ptr .workbook == NULL ) {
253+ zend_throw_exception (vtiful_exception_ce , "Please create a file first, use the filename method" , 130 );
254+ return ;
255+ }
256+
257+ if ((sheet_t = workbook_get_worksheet_by_name (obj -> ptr .workbook , ZSTR_VAL (zs_sheet_name ))) == NULL ) {
258+ zend_throw_exception (vtiful_exception_ce , "Sheet not fund" , 140 );
259+ return ;
260+ }
261+
262+ line = sheet_t -> table -> cached_row_num ;
263+
264+ SHEET_LINE_SET (obj , line );
265+
266+ obj -> ptr .worksheet = sheet_t ;
267+ }
268+ /* }}} */
269+
232270/** {{{ \Vtiful\Kernel\xls::constMemory(string $fileName [, string $sheetName])
233271 */
234272PHP_METHOD (vtiful_xls , constMemory )
@@ -575,6 +613,7 @@ zend_function_entry xls_methods[] = {
575613 PHP_ME (vtiful_xls , __construct , xls_construct_arginfo , ZEND_ACC_PUBLIC )
576614 PHP_ME (vtiful_xls , fileName , xls_file_name_arginfo , ZEND_ACC_PUBLIC )
577615 PHP_ME (vtiful_xls , addSheet , xls_file_add_sheet , ZEND_ACC_PUBLIC )
616+ PHP_ME (vtiful_xls , checkoutSheet , xls_file_checkout_sheet , ZEND_ACC_PUBLIC )
578617 PHP_ME (vtiful_xls , constMemory , xls_const_memory_arginfo , ZEND_ACC_PUBLIC )
579618 PHP_ME (vtiful_xls , header , xls_header_arginfo , ZEND_ACC_PUBLIC )
580619 PHP_ME (vtiful_xls , data , xls_data_arginfo , ZEND_ACC_PUBLIC )
0 commit comments