1212
1313#include "xlswriter.h"
1414#include "ext/date/php_date.h"
15- #include "ext/standard/php_filestat.h"
1615
1716zend_class_entry * vtiful_xls_ce ;
1817
@@ -153,6 +152,15 @@ ZEND_BEGIN_ARG_INFO_EX(xls_insert_formula_arginfo, 0, 0, 3)
153152 ZEND_ARG_INFO (0 , format_handle )
154153ZEND_END_ARG_INFO ()
155154
155+ ZEND_BEGIN_ARG_INFO_EX (xls_insert_comment_arginfo , 0 , 0 , 3 )
156+ ZEND_ARG_INFO (0 , row )
157+ ZEND_ARG_INFO (0 , column )
158+ ZEND_ARG_INFO (0 , comment )
159+ ZEND_END_ARG_INFO ()
160+
161+ ZEND_BEGIN_ARG_INFO_EX (xls_show_comment_arginfo , 0 , 0 , 0 )
162+ ZEND_END_ARG_INFO ()
163+
156164ZEND_BEGIN_ARG_INFO_EX (xls_auto_filter_arginfo , 0 , 0 , 1 )
157165 ZEND_ARG_INFO (0 , range )
158166ZEND_END_ARG_INFO ()
@@ -278,7 +286,7 @@ PHP_METHOD(vtiful_xls, __construct)
278286PHP_METHOD (vtiful_xls , fileName )
279287{
280288 char * sheet_name = NULL ;
281- zval file_path , dir_exists , * dir_path = NULL ;
289+ zval file_path , * dir_path = NULL ;
282290 zend_string * zs_file_name = NULL , * zs_sheet_name = NULL ;
283291
284292 ZEND_PARSE_PARAMETERS_START (1 , 2 )
@@ -287,16 +295,13 @@ PHP_METHOD(vtiful_xls, fileName)
287295 Z_PARAM_STR (zs_sheet_name )
288296 ZEND_PARSE_PARAMETERS_END ();
289297
290- ZVAL_NULL (& dir_exists );
291298 ZVAL_COPY (return_value , getThis ());
292299
293300 GET_CONFIG_PATH (dir_path , vtiful_xls_ce , return_value );
294301
295- php_stat (ZSTR_VAL (Z_STR_P (dir_path )), strlen (ZSTR_VAL (Z_STR_P (dir_path ))), FS_IS_DIR , & dir_exists );
296-
297- if (Z_TYPE (dir_exists ) == IS_FALSE ) {
298- zval_ptr_dtor (& dir_exists );
302+ if (directory_exists (ZSTR_VAL (Z_STR_P (dir_path ))) == XLSWRITER_FALSE ) {
299303 zend_throw_exception (vtiful_exception_ce , "Configure 'path' directory does not exist" , 121 );
304+ return ;
300305 }
301306
302307 xls_object * obj = Z_XLS_P (getThis ());
@@ -315,8 +320,6 @@ PHP_METHOD(vtiful_xls, fileName)
315320
316321 zval_ptr_dtor (& file_path );
317322 }
318-
319- zval_ptr_dtor (& dir_exists );
320323}
321324/* }}} */
322325
@@ -711,7 +714,7 @@ PHP_METHOD(vtiful_xls, insertImage)
711714}
712715/* }}} */
713716
714- /** {{{ \Vtiful\Kernel\Excel::insertImage (int $row, int $column, string $imagePath )
717+ /** {{{ \Vtiful\Kernel\Excel::insertFormula (int $row, int $column, string $formula )
715718 */
716719PHP_METHOD (vtiful_xls , insertFormula )
717720{
@@ -745,6 +748,43 @@ PHP_METHOD(vtiful_xls, insertFormula)
745748}
746749/* }}} */
747750
751+ /** {{{ \Vtiful\Kernel\Excel::insertComment(int $row, int $column, string $comment)
752+ */
753+ PHP_METHOD (vtiful_xls , insertComment )
754+ {
755+ zend_string * comment = NULL ;
756+ zend_long row = 0 , column = 0 ;
757+
758+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
759+ Z_PARAM_LONG (row )
760+ Z_PARAM_LONG (column )
761+ Z_PARAM_STR (comment )
762+ ZEND_PARSE_PARAMETERS_END ();
763+
764+ ZVAL_COPY (return_value , getThis ()) ;
765+
766+ xls_object * obj = Z_XLS_P (getThis ());
767+
768+ WORKBOOK_NOT_INITIALIZED (obj );
769+
770+ comment_writer (comment , row , column , & obj -> write_ptr );
771+ }
772+ /* }}} */
773+
774+ /** {{{ \Vtiful\Kernel\Excel::showComment()
775+ */
776+ PHP_METHOD (vtiful_xls , showComment )
777+ {
778+ ZVAL_COPY (return_value , getThis ());
779+
780+ xls_object * obj = Z_XLS_P (getThis ());
781+
782+ WORKBOOK_NOT_INITIALIZED (obj );
783+
784+ comment_show (& obj -> write_ptr );
785+ }
786+ /* }}} */
787+
748788/** {{{ \Vtiful\Kernel\Excel::autoFilter(int $rowStart, int $rowEnd, int $columnStart, int $columnEnd)
749789 */
750790PHP_METHOD (vtiful_xls , autoFilter )
@@ -1288,6 +1328,8 @@ zend_function_entry xls_methods[] = {
12881328 PHP_ME (vtiful_xls , insertUrl , xls_insert_url_arginfo , ZEND_ACC_PUBLIC )
12891329 PHP_ME (vtiful_xls , insertImage , xls_insert_image_arginfo , ZEND_ACC_PUBLIC )
12901330 PHP_ME (vtiful_xls , insertFormula , xls_insert_formula_arginfo , ZEND_ACC_PUBLIC )
1331+ PHP_ME (vtiful_xls , insertComment , xls_insert_comment_arginfo , ZEND_ACC_PUBLIC )
1332+ PHP_ME (vtiful_xls , showComment , xls_show_comment_arginfo , ZEND_ACC_PUBLIC )
12911333 PHP_ME (vtiful_xls , mergeCells , xls_merge_cells_arginfo , ZEND_ACC_PUBLIC )
12921334 PHP_ME (vtiful_xls , setColumn , xls_set_column_arginfo , ZEND_ACC_PUBLIC )
12931335 PHP_ME (vtiful_xls , setRow , xls_set_row_arginfo , ZEND_ACC_PUBLIC )
0 commit comments