Skip to content

Commit 5b837e5

Browse files
authored
Merge pull request #467 from viest/dev
Feat: borderOfTheFourSides and update config.m4
2 parents 8fcc501 + f6e5410 commit 5b837e5

File tree

6 files changed

+170
-41
lines changed

6 files changed

+170
-41
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
<div align=center>
2-
<img height="214" src="resource/logo_now.png"/>
2+
<img alt="php-ext-xlswriter" height="214" src="resource/logo_now.png"/>
33
</div>
44

55
<div align=center>
6-
<a href="https://github.com/viest/php-ext-xlswriter/releases"><img src="https://img.shields.io/github/release/viest/php-ext-excel-export.svg"/></a>
6+
<a href="https://github.com/viest/php-ext-xlswriter/releases"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/release/viest/php-ext-excel-export.svg"/></a>
77
</div>
88

99
<div align=center>
10-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/platform-macos%20%7C%20linux%20%7C%20windows-brightgreen.svg"/></a>
10+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/platform-macos%20%7C%20linux%20%7C%20windows-brightgreen.svg"/></a>
1111
</div>
1212

1313
<div align=center>
14-
<a href="https://github.com/viest/php-ext-xlswriter/actions/workflows/main.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/workflow/status/viest/php-ext-xlswriter/php-ext-xlswriter/master"></a>
15-
<a href="https://ci.appveyor.com/project/viest/php-ext-excel-export/branch/master"><img src="https://ci.appveyor.com/api/projects/status/w4cfjo9e4gsrs6rn/branch/master?svg=true"/></a>
16-
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter?ref=badge_shield"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter.svg?type=shield"/></a>
14+
<a href="https://github.com/viest/php-ext-xlswriter/actions"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/actions/workflow/status/viest/php-ext-xlswriter/main.yml?branch=master&logo=github"></a>
15+
<a href="https://travis-ci.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://travis-ci.com/viest/php-ext-xlswriter.svg?branch=master"/></a>
16+
<a href="https://ci.appveyor.com/project/viest/php-ext-excel-export/branch/master"><img alt="php-ext-xlswriter" src="https://ci.appveyor.com/api/projects/status/w4cfjo9e4gsrs6rn/branch/master?svg=true"/></a>
17+
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter?ref=badge_shield"><img alt="php-ext-xlswriter" src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter.svg?type=shield"/></a>
1718
</div>
1819

1920
<div align=center>
20-
<a href="https://opencollective.com/php-ext-xlswriter"><img src="https://opencollective.com/php-ext-xlswriter/all/badge.svg?label=financial+contributors"/></a>
21-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/PHP-%3E%3D%207.0-brightgreen.svg"/></a>
22-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/github/contributors/viest/php-ext-excel-export.svg"/></a>
23-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/license-BSD-green.svg"/></a>
24-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/github/issues/viest/php-ext-excel-export.svg"/></a>
25-
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fviest%2Fphp-ext-xlswriter&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
21+
<a href="https://opencollective.com/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://opencollective.com/php-ext-xlswriter/all/badge.svg?label=financial+contributors"/></a>
22+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/PHP-%3E%3D%207.0-brightgreen.svg"/></a>
23+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/contributors/viest/php-ext-excel-export.svg"/></a>
24+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/license-BSD-green.svg"/></a>
25+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/issues/viest/php-ext-excel-export.svg"/></a>
26+
<a href="https://hits.seeyoufarm.com"><img alt="php-ext-xlswriter" src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fviest%2Fphp-ext-xlswriter&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
2627
</div>
2728

2829
## Why use xlswriter
@@ -101,11 +102,11 @@ composer require viest/php-ext-xlswriter-ide-helper:dev-master
101102

102103
## Exchange group
103104

104-
<img width="160" src="resource/qq.jpg"/>
105+
<img alt="php-ext-xlswriter" width="160" src="resource/qq.jpg"/>
105106

106107
## Financial donation
107108

108-
<img height="220" src="resource/pay.jpg"/>
109+
<img alt="php-ext-xlswriter" height="220" src="resource/pay.jpg"/>
109110

110111
## Contributors
111112

README_zh.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
<div align=center>
2-
<img height="214" src="resource/logo_now.png"/>
2+
<img alt="php-ext-xlswriter" height="214" src="resource/logo_now.png"/>
33
</div>
44

55
<div align=center>
6-
<a href="https://github.com/viest/php-ext-xlswriter/releases"><img src="https://img.shields.io/github/release/viest/php-ext-excel-export.svg"/></a>
6+
<a href="https://github.com/viest/php-ext-xlswriter/releases"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/release/viest/php-ext-excel-export.svg"/></a>
77
</div>
88

99
<div align=center>
10-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/platform-macos%20%7C%20linux%20%7C%20windows-brightgreen.svg"/></a>
10+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/platform-macos%20%7C%20linux%20%7C%20windows-brightgreen.svg"/></a>
1111
</div>
1212

1313
<div align=center>
14-
<a href="https://github.com/viest/php-ext-xlswriter/actions/workflows/main.yml?query=branch%3Amaster"><img src="https://img.shields.io/github/workflow/status/viest/php-ext-xlswriter/php-ext-xlswriter/master"></a>
15-
<a href="https://ci.appveyor.com/project/viest/php-ext-excel-export/branch/master"><img src="https://ci.appveyor.com/api/projects/status/w4cfjo9e4gsrs6rn/branch/master?svg=true"/></a>
16-
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter?ref=badge_shield"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter.svg?type=shield"/></a>
14+
<a href="https://github.com/viest/php-ext-xlswriter/actions"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/actions/workflow/status/viest/php-ext-xlswriter/main.yml?branch=master&logo=github"></a>
15+
<a href="https://travis-ci.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://travis-ci.com/viest/php-ext-xlswriter.svg?branch=master"/></a>
16+
<a href="https://ci.appveyor.com/project/viest/php-ext-excel-export/branch/master"><img alt="php-ext-xlswriter" src="https://ci.appveyor.com/api/projects/status/w4cfjo9e4gsrs6rn/branch/master?svg=true"/></a>
17+
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter?ref=badge_shield"><img alt="php-ext-xlswriter" src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fviest%2Fphp-ext-xlswriter.svg?type=shield"/></a>
1718
</div>
1819

1920
<div align=center>
20-
<a href="https://opencollective.com/php-ext-xlswriter"><img src="https://opencollective.com/php-ext-xlswriter/all/badge.svg?label=financial+contributors"/></a>
21-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/PHP-%3E%3D%207.0-brightgreen.svg"/></a>
22-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/github/contributors/viest/php-ext-excel-export.svg"/></a>
23-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/badge/license-BSD-green.svg"/></a>
24-
<a href="https://github.com/viest/php-ext-xlswriter"><img src="https://img.shields.io/github/issues/viest/php-ext-excel-export.svg"/></a>
25-
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fviest%2Fphp-ext-xlswriter&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
21+
<a href="https://opencollective.com/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://opencollective.com/php-ext-xlswriter/all/badge.svg?label=financial+contributors"/></a>
22+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/PHP-%3E%3D%207.0-brightgreen.svg"/></a>
23+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/contributors/viest/php-ext-excel-export.svg"/></a>
24+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/badge/license-BSD-green.svg"/></a>
25+
<a href="https://github.com/viest/php-ext-xlswriter"><img alt="php-ext-xlswriter" src="https://img.shields.io/github/issues/viest/php-ext-excel-export.svg"/></a>
26+
<a href="https://hits.seeyoufarm.com"><img alt="php-ext-xlswriter" src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fviest%2Fphp-ext-xlswriter&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
2627
</div>
2728

2829
## 为什么使用xlswriter

config.m4

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if test "$PHP_XLSWRITER" != "no"; then
113113
else
114114
AC_MSG_RESULT([use the bundled library])
115115
xls_writer_sources="$xls_writer_sources $libxlsxwriter_sources"
116-
PHP_ADD_INCLUDE([$srcdir/library/libxlsxwriter/include])
116+
PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libxlsxwriter/include])
117117

118118
dnl see library/CMakeLists.txt
119119
LIBOPT="-DNOCRYPT -DNOUNCRYPT"
@@ -150,13 +150,13 @@ if test "$PHP_XLSWRITER" != "no"; then
150150
AC_MSG_RESULT([use the bundled library])
151151

152152
xls_writer_sources="$xls_writer_sources $libexpat"
153-
PHP_ADD_INCLUDE([$srcdir/library/libexpat/expat/lib])
154-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib])
153+
PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libexpat/expat/lib])
154+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libexpat/expat/lib])
155155
LIBOPT="$LIBOPT -DXML_POOR_ENTROPY"
156156

157157
xls_writer_sources="$xls_writer_sources $libxlsxio"
158-
PHP_ADD_INCLUDE([$srcdir/library/libxlsxio/include])
159-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib])
158+
PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/library/libxlsxio/include])
159+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxio/lib])
160160
LIBOPT="$LIBOPT -DUSE_MINIZIP"
161161

162162
fi
@@ -177,15 +177,15 @@ if test "$PHP_XLSWRITER" != "no"; then
177177

178178
PHP_NEW_EXTENSION(xlswriter, $xls_writer_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $LIBOPT)
179179

180-
PHP_ADD_INCLUDE([$srcdir])
181-
PHP_ADD_INCLUDE([$srcdir/include])
180+
PHP_ADD_INCLUDE([PHP_EXT_SRCDIR])
181+
PHP_ADD_INCLUDE([PHP_EXT_SRCDIR/include])
182182

183-
PHP_ADD_BUILD_DIR([$abs_builddir/kernel])
184-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/src])
185-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/minizip])
186-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/tmpfileplus])
187-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxwriter/third_party/md5])
183+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/kernel])
184+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/src])
185+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/minizip])
186+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/tmpfileplus])
187+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxwriter/third_party/md5])
188188

189-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib])
190-
PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib])
189+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libexpat/expat/lib])
190+
PHP_ADD_BUILD_DIR([PHP_EXT_BUILDDIR/library/libxlsxio/lib])
191191
fi

kernel/format.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ ZEND_BEGIN_ARG_INFO_EX(format_border_arginfo, 0, 0, 1)
103103
ZEND_ARG_INFO(0, style)
104104
ZEND_END_ARG_INFO()
105105

106+
ZEND_BEGIN_ARG_INFO_EX(format_border_of_the_four_sides_arginfo, 0, 0, 4)
107+
ZEND_ARG_INFO(0, top)
108+
ZEND_ARG_INFO(0, right)
109+
ZEND_ARG_INFO(0, bottom)
110+
ZEND_ARG_INFO(0, left)
111+
ZEND_END_ARG_INFO()
112+
106113
ZEND_BEGIN_ARG_INFO_EX(format_border_color_arginfo, 0, 0, 1)
107114
ZEND_ARG_INFO(0, color)
108115
ZEND_END_ARG_INFO()
@@ -367,7 +374,7 @@ PHP_METHOD(vtiful_format, wrap)
367374
}
368375
/* }}} */
369376

370-
/** {{{ \Vtiful\Kernel\Format::toResource()
377+
/** {{{ \Vtiful\Kernel\Format::border()
371378
*/
372379
PHP_METHOD(vtiful_format, border)
373380
{
@@ -387,6 +394,33 @@ PHP_METHOD(vtiful_format, border)
387394
}
388395
/* }}} */
389396

397+
/** {{{ \Vtiful\Kernel\Format::borderOfTheFourSides(int $top, int $right, int $bottom, int $left)
398+
*/
399+
PHP_METHOD(vtiful_format, borderOfTheFourSides)
400+
{
401+
zend_long top = LXW_BORDER_NONE, right = LXW_BORDER_NONE, bottom = LXW_BORDER_NONE, left = LXW_BORDER_NONE;
402+
403+
ZEND_PARSE_PARAMETERS_START(0, 4)
404+
Z_PARAM_OPTIONAL
405+
Z_PARAM_LONG_OR_NULL(top, _dummy)
406+
Z_PARAM_LONG_OR_NULL(right, _dummy)
407+
Z_PARAM_LONG_OR_NULL(bottom, _dummy)
408+
Z_PARAM_LONG_OR_NULL(left, _dummy)
409+
ZEND_PARSE_PARAMETERS_END();
410+
411+
ZVAL_COPY(return_value, getThis());
412+
413+
format_object *obj = Z_FORMAT_P(getThis());
414+
415+
if (obj->ptr.format) {
416+
format_set_top(obj->ptr.format, top);
417+
format_set_right(obj->ptr.format, right);
418+
format_set_bottom(obj->ptr.format, bottom);
419+
format_set_left(obj->ptr.format, left);
420+
}
421+
}
422+
/* }}} */
423+
390424
/** {{{ \Vtiful\Kernel\Format::borderColor(int $color)
391425
*/
392426
PHP_METHOD(vtiful_format, borderColor)
@@ -463,6 +497,7 @@ zend_function_entry format_methods[] = {
463497
PHP_ME(vtiful_format, bold, format_bold_arginfo, ZEND_ACC_PUBLIC)
464498
PHP_ME(vtiful_format, italic, format_italic_arginfo, ZEND_ACC_PUBLIC)
465499
PHP_ME(vtiful_format, border, format_border_arginfo, ZEND_ACC_PUBLIC)
500+
PHP_ME(vtiful_format, borderOfTheFourSides, format_border_of_the_four_sides_arginfo, ZEND_ACC_PUBLIC)
466501
PHP_ME(vtiful_format, borderColor, format_border_color_arginfo, ZEND_ACC_PUBLIC)
467502
PHP_ME(vtiful_format, borderColorOfTheFourSides, format_border_color_of_the_four_sides_arginfo, ZEND_ACC_PUBLIC)
468503
PHP_ME(vtiful_format, align, format_align_arginfo, ZEND_ACC_PUBLIC)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'path' => './tests'
9+
];
10+
11+
$fileObject = new \Vtiful\Kernel\Excel($config);
12+
13+
$fileObject = $fileObject->fileName('format_border_of_the_four_side_1.xlsx');
14+
$fileHandle = $fileObject->getHandle();
15+
16+
$data = [
17+
['viest1', 21, 100, "A"],
18+
['viest2', 20, 80, "B"],
19+
['viest3', 22, 70, "C"],
20+
];
21+
22+
$format = new \Vtiful\Kernel\Format($fileHandle);
23+
24+
$borderStyle = $format
25+
->border(\Vtiful\Kernel\Format::BORDER_THIN)
26+
->borderOfTheFourSides(
27+
\Vtiful\Kernel\Format::BORDER_THIN, // top
28+
\Vtiful\Kernel\Format::BORDER_MEDIUM, // right
29+
\Vtiful\Kernel\Format::BORDER_DASHED, // bottom
30+
\Vtiful\Kernel\Format::BORDER_DOTTED // left
31+
)
32+
->toResource();
33+
34+
$filePath = $fileObject->header(['name', 'age', 'score', 'level'])
35+
->data($data)
36+
->setRow('A1', 20, $borderStyle)
37+
->output();
38+
39+
var_dump($filePath);
40+
?>
41+
--CLEAN--
42+
<?php
43+
@unlink(__DIR__ . '/format_border_of_the_four_side_1.xlsx');
44+
?>
45+
--EXPECT--
46+
string(45) "./tests/format_border_of_the_four_side_1.xlsx"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'path' => './tests'
9+
];
10+
11+
$fileObject = new \Vtiful\Kernel\Excel($config);
12+
13+
$fileObject = $fileObject->fileName('format_border_of_the_four_side_2.xlsx');
14+
$fileHandle = $fileObject->getHandle();
15+
16+
$data = [
17+
['viest1', 21, 100, "A"],
18+
['viest2', 20, 80, "B"],
19+
['viest3', 22, 70, "C"],
20+
];
21+
22+
$format = new \Vtiful\Kernel\Format($fileHandle);
23+
24+
$borderStyle = $format
25+
->border(\Vtiful\Kernel\Format::BORDER_THIN)
26+
->borderOfTheFourSides(
27+
NULL, // top
28+
\Vtiful\Kernel\Format::BORDER_THICK, // right
29+
\Vtiful\Kernel\Format::BORDER_DOUBLE, // bottom
30+
NULL // left
31+
)
32+
->toResource();
33+
34+
$filePath = $fileObject->header(['name', 'age', 'score', 'level'])
35+
->data($data)
36+
->setRow('A1', 20, $borderStyle)
37+
->output();
38+
39+
var_dump($filePath);
40+
?>
41+
--CLEAN--
42+
<?php
43+
@unlink(__DIR__ . '/format_border_of_the_four_side_2.xlsx');
44+
?>
45+
--EXPECT--
46+
string(45) "./tests/format_border_of_the_four_side_2.xlsx"

0 commit comments

Comments
 (0)