From 2f3190feb99f2a0cecc3294742aef4b054487b32 Mon Sep 17 00:00:00 2001 From: viest Date: Sun, 12 Feb 2023 15:03:51 +0800 Subject: [PATCH 1/4] Update: config.m4 --- config.m4 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/config.m4 b/config.m4 index 0cc9d89..5d815bd 100644 --- a/config.m4 +++ b/config.m4 @@ -113,7 +113,7 @@ if test "$PHP_XLSWRITER" != "no"; then else AC_MSG_RESULT([use the bundled library]) xls_writer_sources="$xls_writer_sources $libxlsxwriter_sources" - PHP_ADD_INCLUDE([$srcdir/library/libxlsxwriter/include]) + PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libxlsxwriter/include]) dnl see library/CMakeLists.txt LIBOPT="-DNOCRYPT -DNOUNCRYPT" @@ -150,13 +150,13 @@ if test "$PHP_XLSWRITER" != "no"; then AC_MSG_RESULT([use the bundled library]) xls_writer_sources="$xls_writer_sources $libexpat" - PHP_ADD_INCLUDE([$srcdir/library/libexpat/expat/lib]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib]) + PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libexpat/expat/lib]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libexpat/expat/lib]) LIBOPT="$LIBOPT -DXML_POOR_ENTROPY" xls_writer_sources="$xls_writer_sources $libxlsxio" - PHP_ADD_INCLUDE([$srcdir/library/libxlsxio/include]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib]) + PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libxlsxio/include]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxio/lib]) LIBOPT="$LIBOPT -DUSE_MINIZIP" fi @@ -177,15 +177,15 @@ if test "$PHP_XLSWRITER" != "no"; then PHP_NEW_EXTENSION(xlswriter, $xls_writer_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $LIBOPT) - PHP_ADD_INCLUDE([$srcdir]) - PHP_ADD_INCLUDE([$srcdir/include]) + PHP_ADD_INCLUDE([PHP_EXT_SRCDIR]) + PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/include]) - PHP_ADD_BUILD_DIR([$abs_builddir/kernel]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/src]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/minizip]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/tmpfileplus]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/md5]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/kernel]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/src]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/minizip]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/tmpfileplus]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/md5]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib]) - PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libexpat/expat/lib]) + PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxio/lib]) fi From c2f6577782aa18042f8ec83f815e5b40e89b688d Mon Sep 17 00:00:00 2001 From: viest Date: Sun, 12 Feb 2023 15:20:46 +0800 Subject: [PATCH 2/4] Update: readme --- README.md | 29 +++++++++++++++-------------- README_zh.md | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index b296b43..56e5973 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,29 @@
- +php-ext-xlswriter
- +php-ext-xlswriter
- +php-ext-xlswriter
- - - +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter
- - - - - - +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter
## Why use xlswriter @@ -101,11 +102,11 @@ composer require viest/php-ext-xlswriter-ide-helper:dev-master ## Exchange group - +php-ext-xlswriter ## Financial donation - +php-ext-xlswriter ## Contributors diff --git a/README_zh.md b/README_zh.md index 88f48c3..9080334 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,28 +1,29 @@
- +php-ext-xlswriter
- +php-ext-xlswriter
- +php-ext-xlswriter
- - - +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter
- - - - - - +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter +php-ext-xlswriter
## 为什么使用xlswriter From 32771757cbf18b904b952b183d9c3f7fbface25f Mon Sep 17 00:00:00 2001 From: viest Date: Sun, 12 Feb 2023 15:40:48 +0800 Subject: [PATCH 3/4] Feat: borderOfTheFourSides --- kernel/format.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/kernel/format.c b/kernel/format.c index 0fd111e..8c1787a 100644 --- a/kernel/format.c +++ b/kernel/format.c @@ -103,6 +103,13 @@ ZEND_BEGIN_ARG_INFO_EX(format_border_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(format_border_of_the_four_sides_arginfo, 0, 0, 4) + ZEND_ARG_INFO(0, top) + ZEND_ARG_INFO(0, right) + ZEND_ARG_INFO(0, bottom) + ZEND_ARG_INFO(0, left) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(format_border_color_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() @@ -367,7 +374,7 @@ PHP_METHOD(vtiful_format, wrap) } /* }}} */ -/** {{{ \Vtiful\Kernel\Format::toResource() +/** {{{ \Vtiful\Kernel\Format::border() */ PHP_METHOD(vtiful_format, border) { @@ -387,6 +394,33 @@ PHP_METHOD(vtiful_format, border) } /* }}} */ +/** {{{ \Vtiful\Kernel\Format::borderOfTheFourSides(int $top, int $right, int $bottom, int $left) + */ +PHP_METHOD(vtiful_format, borderOfTheFourSides) +{ + zend_long top = LXW_BORDER_NONE, right = LXW_BORDER_NONE, bottom = LXW_BORDER_NONE, left = LXW_BORDER_NONE; + + ZEND_PARSE_PARAMETERS_START(0, 4) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(top, _dummy) + Z_PARAM_LONG_OR_NULL(right, _dummy) + Z_PARAM_LONG_OR_NULL(bottom, _dummy) + Z_PARAM_LONG_OR_NULL(left, _dummy) + ZEND_PARSE_PARAMETERS_END(); + + ZVAL_COPY(return_value, getThis()); + + format_object *obj = Z_FORMAT_P(getThis()); + + if (obj->ptr.format) { + format_set_top(obj->ptr.format, top); + format_set_right(obj->ptr.format, right); + format_set_bottom(obj->ptr.format, bottom); + format_set_left(obj->ptr.format, left); + } +} +/* }}} */ + /** {{{ \Vtiful\Kernel\Format::borderColor(int $color) */ PHP_METHOD(vtiful_format, borderColor) @@ -463,6 +497,7 @@ zend_function_entry format_methods[] = { PHP_ME(vtiful_format, bold, format_bold_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, italic, format_italic_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, border, format_border_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(vtiful_format, borderOfTheFourSides, format_border_of_the_four_sides_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, borderColor, format_border_color_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, borderColorOfTheFourSides, format_border_color_of_the_four_sides_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, align, format_align_arginfo, ZEND_ACC_PUBLIC) From f6e5410497dfb1ff16f19796aedc8eb2ee8ef07a Mon Sep 17 00:00:00 2001 From: viest Date: Sun, 12 Feb 2023 15:59:35 +0800 Subject: [PATCH 4/4] Feat: borderOfTheFourSides --- tests/format_border_of_the_four_sides_1.phpt | 46 ++++++++++++++++++++ tests/format_border_of_the_four_sides_2.phpt | 46 ++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tests/format_border_of_the_four_sides_1.phpt create mode 100644 tests/format_border_of_the_four_sides_2.phpt diff --git a/tests/format_border_of_the_four_sides_1.phpt b/tests/format_border_of_the_four_sides_1.phpt new file mode 100644 index 0000000..1969e73 --- /dev/null +++ b/tests/format_border_of_the_four_sides_1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Check for vtiful presence +--SKIPIF-- + +--FILE-- + './tests' +]; + +$fileObject = new \Vtiful\Kernel\Excel($config); + +$fileObject = $fileObject->fileName('format_border_of_the_four_side_1.xlsx'); +$fileHandle = $fileObject->getHandle(); + +$data = [ + ['viest1', 21, 100, "A"], + ['viest2', 20, 80, "B"], + ['viest3', 22, 70, "C"], +]; + +$format = new \Vtiful\Kernel\Format($fileHandle); + +$borderStyle = $format + ->border(\Vtiful\Kernel\Format::BORDER_THIN) + ->borderOfTheFourSides( + \Vtiful\Kernel\Format::BORDER_THIN, // top + \Vtiful\Kernel\Format::BORDER_MEDIUM, // right + \Vtiful\Kernel\Format::BORDER_DASHED, // bottom + \Vtiful\Kernel\Format::BORDER_DOTTED // left + ) + ->toResource(); + +$filePath = $fileObject->header(['name', 'age', 'score', 'level']) + ->data($data) + ->setRow('A1', 20, $borderStyle) + ->output(); + +var_dump($filePath); +?> +--CLEAN-- + +--EXPECT-- +string(45) "./tests/format_border_of_the_four_side_1.xlsx" diff --git a/tests/format_border_of_the_four_sides_2.phpt b/tests/format_border_of_the_four_sides_2.phpt new file mode 100644 index 0000000..880fee8 --- /dev/null +++ b/tests/format_border_of_the_four_sides_2.phpt @@ -0,0 +1,46 @@ +--TEST-- +Check for vtiful presence +--SKIPIF-- + +--FILE-- + './tests' +]; + +$fileObject = new \Vtiful\Kernel\Excel($config); + +$fileObject = $fileObject->fileName('format_border_of_the_four_side_2.xlsx'); +$fileHandle = $fileObject->getHandle(); + +$data = [ + ['viest1', 21, 100, "A"], + ['viest2', 20, 80, "B"], + ['viest3', 22, 70, "C"], +]; + +$format = new \Vtiful\Kernel\Format($fileHandle); + +$borderStyle = $format + ->border(\Vtiful\Kernel\Format::BORDER_THIN) + ->borderOfTheFourSides( + NULL, // top + \Vtiful\Kernel\Format::BORDER_THICK, // right + \Vtiful\Kernel\Format::BORDER_DOUBLE, // bottom + NULL // left + ) + ->toResource(); + +$filePath = $fileObject->header(['name', 'age', 'score', 'level']) + ->data($data) + ->setRow('A1', 20, $borderStyle) + ->output(); + +var_dump($filePath); +?> +--CLEAN-- + +--EXPECT-- +string(45) "./tests/format_border_of_the_four_side_2.xlsx"