phpspreadsheet 中文文档 粗翻版

 

http://get.ftqq.com/9211.get

 

官方使用文档  https://phpspreadsheet.readthedocs.io/en/stable/topics/accessing-cells/

api文档 https://phpoffice.github.io/PhpSpreadsheet/master/PhpOffice.html

翻译的是使用文档,机翻+校验,因为现在单个文档内容放的东西有限分成几篇文章

只翻译标题的主要部分

文档部分主要的菜单↓↓

Accessing cells                                     访问单元格                                             
  Setting a cell value by coordinate              通过坐标设置单元格值
  Excel DataTypes Excel                           数据类型
  Setting a range of cells from an array          设置数组中的单元格范围
  Retrieving a cell value by coordinate           通过坐标检索单元格值
  Setting a cell value by column and row          按列和行设置单元格值
  Retrieving a cell value by column and row       按列和行检索单元格值
  Retrieving a range of cell values to an array   检索单元格值范围到数组
  Looping through cells                           遍历单元格
  Using value binders to facilitate data entry    使用值绑定器简化数据输入
Architecture                                        结构
  Architecture                                    结构
  Schematical                                     示意图
  AutoLoader                                      自动加载器
  Spreadsheet in memory                           表格在内存中使用
  Readers and writers                             读取器和写入器
  Fluent interfaces                               优美的接口
AutoFilter Reference                                自动筛选引用
  Introduction                                    简介
  Setting an AutoFilter area on a worksheet       在工作表上设置自动筛选区域
  Autofilter Expressions                          自动筛选表达式
  Executing an AutoFilter                         执行自动筛选
  AutoFilter Sorting                              自动筛选排序
Calculation Engine                                  计算引擎
  Using the PhpSpreadsheet calculation engine     使用phpspreadsheet计算引擎
  Calculation Cache                               计算缓存
  Known limitations                               已知限制
  Handling Date and Time Values                   处理日期和时间值
  Function Reference                              函数引用
Creating a spreadsheet                              创建电子表格
  The Spreadsheet class                           Spreadsheet类
  Clearing a Workbook from memory                 从内存中清除工作簿
File Formats                                        文件格式
  Xls
  Xml
  Xlsx
  Ods
  Slk
  Gnumeric
  Csv
  Html
Memory saving                                       节约内存
    Beware of TTL                                   注意TTL使用
    Common use cases                                常见用例
Migration from PHPExcel                             从PHPExcel迁移
  Automated tool                                  自动化工具
  Manual changes                                  需要手动更改
Reading and writing to file                         读写文件
  \PhpOffice\PhpSpreadsheet\IOFactory             IOFactory类
  Excel 2007 (SpreadsheetML) file format          Excel 2007 文件格式
  Excel 5 (BIFF) file format                      Excel 5 文件格式
  Excel 2003 XML file format                      Excel 2003 文件格式
  Symbolic LinK (SYLK)                            符号链接(Sylk)
  Open/Libre Office (.ods)
  CSV (Comma Separated Values)
  HTML
  PDF
  Generating Excel files from templates (read, modify, write)     从模板生成Excel文件(读取,修改,写入)
  Generating Excel files from HTML content                        从HTML内容生成Excel文件
Reading Files                                       读取文件
  Security                                         安全问题
  Loading a Spreadsheet File                       加载电子表格文件
  Creating a Reader and Loading a Spreadsheet File    创建阅读器并加载电子表格文件
  Spreadsheet Reader Options                      电子表格阅读器选项
  Error Handling                                  错误处理
  Helper Methods                                  辅助方法
Recipes                                             技巧和诀窍demo
  Setting a spreadsheet's metadata                设置电子表格的元数据
  Setting a spreadsheet's active sheet            设置电子表格的活动工作表
  Write a date or time into a cell                将日期或时间写入单元格
  Write a formula into a cell                     将公式写入单元格
  Locale Settings for Formulae                    公式的区域设置
  Write a newline character "\n" in a cell (ALT+"Enter")          在单元格中写入换行符“ \ n”
  Explicitly set a cell's datatype                明确设置单元格的数据类型
  Change a cell into a clickable URL              将单元格更改为可点击的网址
  Setting Printer Options for Excel files         设置Excel文件的打印机选项
  Styles                                          样式设置
  Conditional formatting a cell                   有条件地格式化单元格
  Add a comment to a cell                         在单元格中添加评论
  Apply autofilter to a range of cells            将自动过滤器应用于指定范围的单元格
  Setting security on a spreadsheet               在电子表格上设置安全性
  Setting data validation on a cell               在单元上设置数据验证
  Setting a column's width                        设置列的宽度
  Show/hide a column                              显示/隐藏列
  Group/outline a column                          分组/概述一列
  Setting a row's height                          设置行的高度
  Show/hide a row                                 显示/隐藏行
  Group/outline a row                             分组/概述行
  Merge/unmerge cells                             合并/取消合并单元格
  Inserting rows/columns                          插入行/列
  Add a drawing to a worksheet                    将工程图添加到工作表
  Reading Images from a worksheet                 从工作表中读取图像
  Add rich text to a cell                         向单元格添加富文本
  Define a named range                            定义一个命名范围
  Redirect output to a client's web browser       将输出重定向到客户端的Web浏览器
  Setting the default column width                设置默认列宽
  Setting the default row height                  设置默认行高
  Add a GD drawing to a worksheet                 将GD工程图添加到工作表
  Setting worksheet zoom level                    设置工作表缩放级别
  Sheet tab color                                 工作表标签颜色
  Creating worksheets in a workbook               在工作簿中创建工作表
  Hidden worksheets (Sheet states)                隐藏的工作表(Sheet状态)
  Right-to-left worksheet                         从右到左的工作表
Configuration Settings                              配置设定
    Cell collection caching                         单元格集合缓存
    Language/Locale                                 语言/地区
Worksheets                                          工作表
  Adding a new Worksheet                          添加一个新的工作表
  Copying Worksheets                              复制工作表
  Removing a Worksheet                            删除工作表

一点个人经验:

//第一行冻结
            $sheet->freezePaneByColumnAndRow(1, 1);
            $sheet->freezePaneByColumnAndRow(1, 2);
//吧列转换成A B C AA等列的形式
Coordinate::stringFromColumnIndex('9')

专用的类来操纵坐标

曾经存在于PHPExcel_Cell其中的坐标处理方法被提取到一个专用的新类中\PhpOffice\PhpSpreadsheet\Cell\Coordinate。方法是:

  • absoluteCoordinate()
  • absoluteReference()
  • buildRange()
  • columnIndexFromString()
  • coordinateFromString()
  • extractAllCellReferencesInRange()
  • getRangeBoundaries()
  • mergeRangesInCollection()
  • rangeBoundaries()
  • rangeDimension()
  • splitRange()
  • stringFromColumnIndex()
//给某一个单元格添加注释
$sheet->getComment(Coordinate::stringFromColumnIndex('9') . $Row)->getText()->createTextRun('注释');
在一系列单元格上设置自动过滤器。

$spreadsheet->getActiveSheet()->setAutoFilter('A1:E20');
如果要将整个工作表设置为自动筛选区域

$spreadsheet->getActiveSheet()->setAutoFilter(
    $spreadsheet->getActiveSheet()
        ->calculateWorksheetDimension()
);
要将过滤器表达式应用于autoFilter范围,首先需要确定要将此过滤器应用于哪一列。

$autoFilter = $spreadsheet->getActiveSheet()->getAutoFilter();
$columnFilter = $autoFilter->getColumn('C');

\vendor\phpoffice\phpspreadsheet\samples\index.php   这里面有很多的demo

//给表格设置样式
$styleArray = self::getStyleArray($Row);
$sheet->getStyle('B2:G8')->applyFromArray($styleArray);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值