Skip to content

Commit fd79d72

Browse files
authored
Merge pull request #135 from viest/dev
update doc
2 parents 7549218 + baddb4e commit fd79d72

File tree

2 files changed

+111
-4
lines changed

2 files changed

+111
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ xlswriter is a PHP C Extension that can be used to write text, numbers, formulas
2929
* Works on Linux, FreeBSD, OpenBSD, OS X, Windows.
3030
* Compiles for 32 and 64 bit.
3131
* FreeBSD License.
32+
* The only dependency is on zlib.
3233

3334
[文档](https://github.com/viest/php-ext-excel-export/blob/master/README_zh.md) | [Documents](https://github.com/viest/php-ext-excel-export/wiki)
3435

README_zh.md

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ xlswriter is a PHP C Extension that can be used to write text, numbers, formulas
2929
* Works on Linux, FreeBSD, OpenBSD, OS X, Windows.
3030
* Compiles for 32 and 64 bit.
3131
* FreeBSD License.
32+
* The only dependency is on zlib.
3233

3334
## 安装
3435

@@ -278,7 +279,7 @@ $filePath = $fileObject->header(['Number', 'Batch 1', 'Batch 2'])
278279
#### 函数原型
279280

280281
```php
281-
insertText(int $row, int $column, string|int|double $data[, string $format])
282+
insertText(int $row, int $column, string|int|double $data[, string $format, resource $style])
282283
```
283284

284285
##### int $row
@@ -297,6 +298,10 @@ insertText(int $row, int $column, string|int|double $data[, string $format])
297298

298299
> 内容格式
299300
301+
##### resource $style
302+
303+
> 单元格样式
304+
300305
##### 实例
301306

302307
```php
@@ -565,7 +570,7 @@ $fileObject->header(['name', 'age'])
565570
#### 函数原型
566571

567572
```php
568-
color(int $color)
573+
fontColor(int $color)
569574
```
570575

571576
##### int $color
@@ -582,8 +587,8 @@ $fileObject = $fileObject->fileName('tutorial.xlsx');
582587
$fileHandle = $fileObject->getHandle();
583588

584589
$format = new \Vtiful\Kernel\Format($fileHandle);
585-
$colorStyle = $format->color(0xFF0000)->toResource();
586-
//或 $colorStyle = $format->color(\Vtiful\Kernel\Format::COLOR_ORANGE)->toResource();
590+
$colorStyle = $format->fontColor(0xFF0000)->toResource();
591+
//或 $colorStyle = $format->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)->toResource();
587592

588593
$filePath = $fileObject->header(['name', 'age'])
589594
->data([
@@ -596,6 +601,44 @@ $filePath = $fileObject->header(['name', 'age'])
596601
var_dump($filePath);
597602
```
598603

604+
### 设置文字大小
605+
606+
#### 函数原型
607+
608+
```php
609+
fontSize(double $size);
610+
```
611+
612+
##### double $size
613+
614+
> 单元格字体大小
615+
616+
##### 实例
617+
618+
```php
619+
$config = [
620+
'path' => './tests'
621+
];
622+
623+
$fileObject = new \Vtiful\Kernel\Excel($config);
624+
$fileObject = $fileObject->fileName('tutorial.xlsx');
625+
$fileHandle = $fileObject->getHandle();
626+
627+
$format = new \Vtiful\Kernel\Format($fileHandle);
628+
$style = $format->fontSize(30)->toResource();
629+
630+
$filePath = $fileObject->header(['name', 'age'])
631+
->data([
632+
['viest', 21],
633+
['wjx', 21]
634+
])
635+
->setRow('A1', 50, $style)
636+
->setRow('A2:A3', 50, $style)
637+
->output();
638+
639+
var_dump($filePath);
640+
```
641+
599642
### 固定内存导出
600643

601644
#### 内存
@@ -658,6 +701,43 @@ $fileObject->addSheet()
658701
$filePath = $fileObject->output();
659702
```
660703

704+
### 切换工作表
705+
706+
#### 函数原型
707+
708+
```php
709+
checkoutSheet(string $sheetName);
710+
```
711+
712+
#### 实例
713+
714+
```php
715+
$config = [
716+
'path' => './tests'
717+
];
718+
719+
$excel = new \Vtiful\Kernel\Excel($config);
720+
$fileObject = $excel->fileName("tutorial01.xlsx");
721+
722+
$fileObject->header(['name', 'age'])
723+
->data([
724+
['viest', 21],
725+
['viest', 22],
726+
['viest', 23],
727+
]);
728+
729+
// 添加工作表,并插入数据
730+
$fileObject->addSheet('twoSheet')
731+
->header(['name', 'age'])
732+
->data([['vikin', 22]]);
733+
734+
// 切换回默认工作表,并追加数据
735+
$fileObject->checkoutSheet('Sheet1')
736+
->data([['sheet1']]);
737+
738+
$filePath = $fileObject->output();
739+
```
740+
661741
### 组合样式
662742

663743
将多个样式合并为一个新样式应用在单元格上
@@ -670,6 +750,32 @@ $boldItalicStyle = $format->bold()->italic()->toResource();
670750

671751
### 样式列表
672752

753+
##### 背景颜色
754+
755+
```php
756+
$format = new \Vtiful\Kernel\Format($fileHandle);
757+
$backgroundStyle = $format->background(
758+
\Vtiful\Kernel\Format::PATTERN_LIGHT_UP,
759+
\Vtiful\Kernel\Format::COLOR_RED
760+
)->toResource();
761+
```
762+
763+
##### 文本换行
764+
765+
单元格内文本需包含`\n`
766+
767+
```php
768+
$format = new \Vtiful\Kernel\Format($fileHandle);
769+
$wrapStyle = $format->wrap()->toResource();
770+
```
771+
772+
##### 文本删除 (文字中间划线)
773+
774+
```php
775+
$format = new \Vtiful\Kernel\Format($fileHandle);
776+
$style = $format->strikeout()->toResource();
777+
```
778+
673779
##### 粗体
674780

675781
```php

0 commit comments

Comments
 (0)