Skip to content

Commit 6f63ef7

Browse files
committed
init
1 parent 6ebbf0d commit 6f63ef7

File tree

38 files changed

+552
-2
lines changed

38 files changed

+552
-2
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
# demo-php-office
2-
demo-php-office
1+
2+
# Demo PHPOffice Usage
3+
4+
* [demo-php-office](https://github.com/samwhelp/demo-php-office)
5+
6+
7+
## Clone
8+
9+
``` sh
10+
$ git clone https://github.com/samwhelp/demo-php-office.git
11+
```

demo-install-composer/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
## Example
3+
4+
* [Install composer](ex-install-composer)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
* [https://getcomposer.org/download/](https://getcomposer.org/download/)
4+
* [https://getcomposer.org/composer.phar](https://getcomposer.org/composer.phar)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f "$HOME/bin/composer" ]; then
4+
echo "File exists:" "$HOME/bin/composer"
5+
echo "Please remove it first! Just run:"
6+
echo '$ rm ~/bin/composer'
7+
exit 1;
8+
fi
9+
10+
11+
mkdir -p "$HOME/bin"
12+
13+
wget -c 'https://getcomposer.org/composer.phar' -O "$HOME/bin/composer"
14+
15+
chmod u+x "$HOME/bin/composer"
16+
17+
"$HOME/bin/composer" self-update
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
rm "$HOME/bin/composer"
4+
#rm -f "$HOME/bin/composer"

demo-install-php-cli/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
## Example
4+
5+
* [Install php-cli](ex-install-php-cli)
6+
* [Install package for PhpSpreadsheet](ex-install-php-ext-for-php-spreadsheet)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
## Package
4+
5+
* [php-cli](https://packages.ubuntu.com/bionic/php-cli)
6+
7+
8+
## Install php-cli
9+
10+
``` sh
11+
$ sudo apt-get install php-cli
12+
```
13+
14+
15+
## Uninstall php-cli
16+
17+
``` sh
18+
$ sudo apt-get purge php-cli
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get install php-cli
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get purge php-cli
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# Install package for PhpSpreadsheet
3+
4+
5+
## Reference
6+
7+
* [https://phpspreadsheet.readthedocs.io/en/latest/#software-requirements](https://phpspreadsheet.readthedocs.io/en/latest/#software-requirements)
8+
* [PhpSpreadsheet/composer.json](https://github.com/PHPOffice/PhpSpreadsheet/blob/master/composer.json#L43)
9+
10+
11+
## Package
12+
13+
* [php-cli](https://packages.ubuntu.com/bionic/php-cli)
14+
* [php-zip](https://packages.ubuntu.com/bionic/php-zip)
15+
* [php-xml](https://packages.ubuntu.com/bionic/php-xml)
16+
* [php-gd](https://packages.ubuntu.com/bionic/php-gd)
17+
* [php-mbstring](https://packages.ubuntu.com/bionic/php-mbstring)
18+
19+
## Install package
20+
21+
``` sh
22+
$ sudo apt-get install php-cli php-zip php-xml php-gd php-mbstring
23+
```
24+
25+
26+
## Uninstall package
27+
28+
``` sh
29+
$ sudo apt-get purge php-cli php-zip php-xml php-gd php-mbstring
30+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get install php-cli php-zip php-xml php-gd php-mbstring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sudo apt-get purge php-cli php-zip php-xml php-gd php-mbstring

demo-php-spreadsheet/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
# Demo PhpSpreadsheet
3+
4+
## 緣起
5+
6+
這裡的範例是為了回覆下面的討論
7+
8+
* [https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2486647224723918/](https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2486647224723918/)
9+
* https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2480940128627961/
10+
11+
請先閱讀「[Tutorial](Tutorial.md)」。
12+
13+
## Howto
14+
15+
* [Install php-cli](../demo-install-php-cli)
16+
* [Install composer](../demo-install-composer)
17+
18+
19+
## Example
20+
21+
* [Hello World](hello-world)
22+
* [Case Discussion](case-discussion)
23+
24+
25+
## GitHub
26+
27+
* [https://github.com/PHPOffice/PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)
28+
29+
30+
## Doc
31+
32+
* [https://phpspreadsheet.readthedocs.io](https://phpspreadsheet.readthedocs.io)
33+
34+
35+
## Api
36+
37+
* [https://phpoffice.github.io/PhpSpreadsheet/master/](https://phpoffice.github.io/PhpSpreadsheet/master/)

demo-php-spreadsheet/Tutorial.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
# Tutorial
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor
2+
composer.lock
3+
var
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
THE_MAKEFILE_FILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
2+
THE_BASE_DIR_PATH := $(abspath $(dir $(THE_MAKEFILE_FILE_PATH)))
3+
THE_BIN_DIR_PATH := $(THE_BASE_DIR_PATH)/bin
4+
THE_MAK_DIR_PATH := $(THE_BASE_DIR_PATH)/mak
5+
6+
PATH := $(THE_BIN_DIR_PATH):$(PATH)
7+
8+
default: help
9+
.PHONY: default
10+
11+
include $(THE_MAK_DIR_PATH)/*.mk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
## 安裝「phpoffice/phpspreadsheet」
4+
5+
執行
6+
7+
``` sh
8+
$ composer install
9+
```
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
require_once(dirname(__DIR__) . '/vendor/autoload.php');
4+
5+
6+
define('THE_BASE_DIR_PATH', dirname(__DIR__));
7+
define('THE_VAR_DIR_PATH', THE_BASE_DIR_PATH . '/var');
8+
define('THE_ASSET_DIR_PATH', THE_BASE_DIR_PATH . '/asset');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once(__DIR__ . '/Boot.php');
5+
6+
(new \Demo\Dump\Ex0010)
7+
->run()
8+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once(__DIR__ . '/Boot.php');
5+
6+
(new \Demo\Hello)
7+
->run()
8+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once(__DIR__ . '/Boot.php');
5+
6+
(new \Demo\Merge\Ex0010)
7+
->run()
8+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "demo/php-spreadsheet",
3+
"description": "Demo PhpSpreadsheet",
4+
"type": "project",
5+
"license": "MIT",
6+
"require": {
7+
"phpoffice/phpspreadsheet": "^1.6"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Demo\\": "src/Demo"
12+
}
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
composer-install:
3+
composer install
4+
.PHONY: composer-install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
dump-ex0010:
3+
@dump-ex0010.php
4+
.PHONY: dump-ex0010
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
hello:
3+
@hello.php
4+
.PHONY: hello
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
help:
4+
@echo Usage:
5+
6+
@echo make
7+
@echo make help
8+
9+
@echo make hello
10+
11+
@echo make dump-ex0010
12+
13+
@echo make merge-ex0010
14+
15+
.PHONY: help
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
merge-ex0010:
3+
@merge-ex0010.php
4+
.PHONY: merge-ex0010
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
prepare-php-cli:
3+
sudo apt-get install php-cli php-zip php-xml php-gd php-mbstring
4+
.PHONY: prepare-php-cli
5+
6+
7+
prepare-composer:
8+
@echo Todo: prepare-composer
9+
.PHONY: prepare-composer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Demo\Dump;
4+
5+
use PhpOffice\PhpSpreadsheet\IOFactory;
6+
7+
class Ex0010 {
8+
9+
public function run ()
10+
{
11+
//var_dump(__METHOD__);
12+
13+
14+
$this->dump_1();
15+
$this->dump_2();
16+
$this->dump_3();
17+
18+
}
19+
20+
protected function dump_file ($file_path)
21+
{
22+
echo 'Dump file: ' . $file_path;
23+
echo PHP_EOL;
24+
echo PHP_EOL;
25+
26+
$spreadsheet = IOFactory::load($file_path);
27+
28+
$data = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
29+
30+
var_dump($data);
31+
32+
echo PHP_EOL;
33+
}
34+
35+
/*
36+
protected function dump_1 ()
37+
{
38+
$file_path = THE_ASSET_DIR_PATH . '/merge/1.ods';
39+
40+
echo 'Dump file: ' . $file_path;
41+
echo PHP_EOL;
42+
echo PHP_EOL;
43+
44+
$spreadsheet = IOFactory::load($file_path);
45+
46+
$data = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
47+
48+
var_dump($data);
49+
50+
echo PHP_EOL;
51+
}
52+
*/
53+
54+
protected function dump_1 ()
55+
{
56+
$this->dump_file(THE_ASSET_DIR_PATH . '/merge/1.ods');
57+
}
58+
59+
protected function dump_2 ()
60+
{
61+
$this->dump_file(THE_ASSET_DIR_PATH . '/merge/2.ods');
62+
}
63+
64+
protected function dump_3 ()
65+
{
66+
$this->dump_file(THE_ASSET_DIR_PATH . '/merge/3.ods');
67+
}
68+
69+
70+
} // End class Hello

0 commit comments

Comments
 (0)