Skip to content

Commit

Permalink
Feat: borderOfTheFourSides
Browse files Browse the repository at this point in the history
  • Loading branch information
viest committed Feb 12, 2023
1 parent 5a00d9f commit f6e5410
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/format_border_of_the_four_sides_1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--TEST--
Check for vtiful presence
--SKIPIF--
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
--FILE--
<?php
$config = [
'path' => './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--
<?php
@unlink(__DIR__ . '/format_border_of_the_four_side_1.xlsx');
?>
--EXPECT--
string(45) "./tests/format_border_of_the_four_side_1.xlsx"
46 changes: 46 additions & 0 deletions tests/format_border_of_the_four_sides_2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--TEST--
Check for vtiful presence
--SKIPIF--
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
--FILE--
<?php
$config = [
'path' => './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--
<?php
@unlink(__DIR__ . '/format_border_of_the_four_side_2.xlsx');
?>
--EXPECT--
string(45) "./tests/format_border_of_the_four_side_2.xlsx"

0 comments on commit f6e5410

Please sign in to comment.