소스 검색

Merge pull request #110 from viest/dev

DOC Update
viest 6 년 전
부모
커밋
2f5faa6abe
2개의 변경된 파일171개의 추가작업 그리고 30개의 파일을 삭제
  1. 6 0
      README.md
  2. 165 30
      README_zh.md

+ 6 - 0
README.md

@@ -2,6 +2,12 @@
 
 [![Build Status](https://travis-ci.org/viest/php-ext-excel-export.svg?branch=master)](https://travis-ci.org/viest/php-ext-excel-export)
 [![Build status](https://ci.appveyor.com/api/projects/status/w4cfjo9e4gsrs6rn/branch/master?svg=true)](https://ci.appveyor.com/project/viest/php-ext-excel-export/branch/master)
+[![](https://img.shields.io/github/release/viest/php-ext-excel-export.svg)]()
+[![](https://img.shields.io/badge/PHP-%3E%3D%207.0-brightgreen.svg)]()
+[![](https://img.shields.io/github/contributors/viest/php-ext-excel-export.svg)]()
+[![](https://img.shields.io/badge/platform-macos%20%7C%20linux%20%7C%20windows-brightgreen.svg)]()
+[![](https://img.shields.io/badge/license-BSD-green.svg)]()
+[![](https://img.shields.io/github/issues/viest/php-ext-excel-export.svg)]()
 
 #### Why use xlswriter
 

+ 165 - 30
README_zh.md

@@ -1,28 +1,39 @@
-## Excel-Export
+## xlswriter [ Excel-Export ]
 
 Authon: viest [[email protected]](mailto:[email protected])
 
--------
+## 安装
+
+- [编译安装](#编译安装)
+- [PECL](#PECL)
+    
+## 使用
+    
+1. [创建一个简单的xlsx文件](#创建一个简单的xlsx文件)
+2. [单元格插入文字](#单元格插入文字)
+3. [单元格插入链接](#单元格插入链接)
+4. [单元格插入公式](#单元格插入公式)
+5. [单元格插入本地图片](#单元格插入本地图片)
+6. [数据过滤](#数据过滤)
+7. [合并单元格](#合并单元格)
+8. [设置列单元格样式](#设置列单元格格式)
+9. [设置行单元格样式](#设置行单元格格式)
+10. [固定内存导出](#固定内存导出)
+11. [创建工作表](#创建工作表)
+12. [组合样式](#组合样式)
+13. [样式列表](#样式列表)
+
+## PECL
 
-- **安装**
-    - **[编译安装 Excel-Export](#编译安装)**
-- **使用**
-    - **[创建一个简单的xlsx文件](#创建一个简单的xlsx文件)**
-    - **[1、向单元格插入文字](#向单元格插入文字)**
-    - **[2、单元格插入公式](#单元格插入公式)**
-    - **[3、单元格插入本地图片](#单元格插入本地图片)**
-    - **[4、数据过滤](#数据过滤)**
-    - **[5、合并单元格](#合并单元格)**
-    - **[6、设置列单元格格式](#设置列单元格格式)**
-    - **[7、设置行单元格格式](#设置行单元格格式)**
-    - **[8、固定内存导出](#固定内存导出)**
-    - **[9、向文件追加表格](#追加表格)**
+```bash
+pecl install xlswriter
 
---------
+# 添加 extension = xlswriter.so 到 ini 配置
+```
 
-### 编译安装
+## 编译安装
 
-#### Unix
+### Unix
 
 ##### Ubuntu
 
@@ -31,7 +42,7 @@ Authon: viest [[email protected]](mailto:[email protected])
 
 sudo apt-get install -y zlib1g-dev
 
-# Excel-Export
+# 扩展
 
 git clone https://github.com/viest/php-ext-excel-export.git
 
@@ -53,7 +64,7 @@ make && make install
 
 brew install zlib
 
-# Excel-Export
+# 扩展
 
 git clone https://github.com/viest/php-ext-excel-export.git
 
@@ -122,7 +133,7 @@ $filePath = $excel->fileName('tutorial01.xlsx', 'sheet1')
     ->output();
 ```
 
-### 单元格插入文字
+### 单元格插入文字
 
 #### 语法
 
@@ -162,9 +173,53 @@ for ($index = 0; $index < 10; $index++) {
 $textFile->output();
 ```
 
+### 单元格插入链接
+
+#### 函数原型
+
+```php
+insertUrl(int $row, int $column, string $url[, resource $format])
+```
+
+##### int $row
+
+> 单元格所在行
+
+##### int $column
+
+> 单元格所在列
+
+##### string $url
+
+> 链接地址
+
+##### resource $format
+
+> 链接样式
+
+##### 实例
+
+```php
+$excel = new \Vtiful\Kernel\Excel($config);
+
+$urlFile = $excel->fileName("free.xlsx")
+    ->header(['url']);
+
+$fileHandle = $fileObject->getHandle();
+
+$format    = new \Vtiful\Kernel\Format($fileHandle);
+$urlStyle = $format->bold()
+    ->underline(Format::UNDERLINE_SINGLE)
+    ->toResource();
+
+$urlFile->insertUrl(1, 0, 'https://github.com', $urlStyle);
+
+$textFile->output();
+```
+
 ### 单元格插入公式
 
-#### 语法
+#### 函数原型
 
 ```php
 insertFormula(int $row, int $column, string $formula)
@@ -203,7 +258,7 @@ $freeFile->output();
 
 ### 单元格插入本地图片
 
-#### 语法
+#### 函数原型
 
 ```php
 insertImage(int $row, int $column, string $localImagePath[, double $widthScale, double $heightScale])
@@ -245,7 +300,7 @@ $freeFile->output();
 
 ### 数据过滤
 
-#### 语法
+#### 函数原型
 
 ```php
 autoFilter(string $scope);
@@ -267,7 +322,7 @@ $excel->fileName('test.xlsx')
 
 ### 合并单元格
 
-#### 语法
+#### 函数原型
 
 ```php
 mergeCells(string $scope, string $data);
@@ -291,7 +346,7 @@ $excel->fileName("test.xlsx")
 
 ### 设置列单元格格式
 
-#### 语法
+#### 函数原型
 
 ```php
 setColumn(string $range, double $width [, resource $format]);
@@ -329,7 +384,7 @@ $fileObject->header(['name', 'age'])
 
 ### 设置行单元格格式
 
-#### 语法
+#### 函数原型
 
 ```php
 setRow(string $range, double $height [, resource $format]);
@@ -371,7 +426,7 @@ $fileObject->header(['name', 'age'])
 
 最大内存使用量 = 最大一行的数据占用量
 
-#### 语法
+#### 函数原型
 
 ```php
 constMemory(string $fileName);
@@ -395,9 +450,9 @@ $fileObject->header(['name', 'age'])
     ->output();
 ```
 
-### 追加表格
+### 创建工作表
 
-#### 语法
+#### 函数原型
 
 ```php
 addSheet([string $sheetName]);
@@ -427,3 +482,83 @@ $fileObject->addSheet()
 $filePath = $fileObject->output();
 ```
 
+### 组合样式
+
+将多个样式合并为一个新样式应用在单元格上
+
+```php
+// 将粗体与斜体合并为一个样式
+$format          = new \Vtiful\Kernel\Format($fileHandle);
+$boldItalicStyle = $format->bold()->italic()->toResource();
+```
+
+### 样式列表
+
+##### 粗体
+
+```php
+$format    = new \Vtiful\Kernel\Format($fileHandle);
+$boldStyle = $format->bold()->toResource();
+```
+##### 斜体
+
+```php
+$format      = new \Vtiful\Kernel\Format($fileHandle);
+$italicStyle = $format->italic()->toResource();
+```
+##### 下划线
+
+###### 函数原型
+
+```php
+underline(resource $resourchHandle, Format::const $style): \Vtiful\Kernel\Format
+```
+
+###### 实例
+
+```php
+$format         = new \Vtiful\Kernel\Format($fileHandle);
+$underlineStyle = $format->underline(Format::UNDERLINE_SINGLE)->toResource();
+```
+###### Style 
+
+```php
+Format::UNDERLINE_SINGLE;            // 单下划线
+Format::UNDERLINE_DOUBLE;            // 双下划线
+Format::UNDERLINE_SINGLE_ACCOUNTING; // 会计用单下划线
+Format::UNDERLINE_DOUBLE_ACCOUNTING; // 会计用双下划线
+```
+
+##### 对齐
+
+###### 函数原型
+
+```php
+align(resource $resourchHandle, Format::const ...$style): \Vtiful\Kernel\Format
+```
+
+###### 实例
+
+```php
+$format     = new \Vtiful\Kernel\Format($fileHandle);
+$alignStyle = $format
+    ->align(Format::FORMAT_ALIGN_CENTER, Format::FORMAT_ALIGN_VERTICAL_CENTER)
+    ->toResource();
+```
+###### Style 
+
+```php
+Format::FORMAT_ALIGN_LEFT;                 // 水平左对齐
+Format::FORMAT_ALIGN_CENTER;               // 水平剧中对齐
+Format::FORMAT_ALIGN_RIGHT;                // 水平右对齐
+Format::FORMAT_ALIGN_FILL;                 // 水平填充对齐
+Format::FORMAT_ALIGN_JUSTIFY;              // 水平两端对齐
+Format::FORMAT_ALIGN_CENTER_ACROSS;        // 横向中心对齐
+Format::FORMAT_ALIGN_DISTRIBUTED;          // 分散对齐
+Format::FORMAT_ALIGN_VERTICAL_TOP;         // 顶部垂直对齐
+Format::FORMAT_ALIGN_VERTICAL_BOTTOM;      // 底部垂直对齐
+Format::FORMAT_ALIGN_VERTICAL_CENTER;      // 垂直剧中对齐
+Format::FORMAT_ALIGN_VERTICAL_JUSTIFY;     // 垂直两端对齐
+Format::FORMAT_ALIGN_VERTICAL_DISTRIBUTED; // 垂直分散对齐
+```
+