PHP-Xlswriter
  • Why use xlswriter
  • English
    • Install
      • Env requirements
      • PECL (recommend)
      • Mac
      • Alpine
      • Ubuntu
      • Windows
    • Quick start
      • Create file
      • Read file
    • Read file
      • Worksheet list
      • Read file (full amount)
      • Read file (cursor)
      • Ignore blank cells
      • Ignore blank lines
      • Global row read type
      • Cell callback mode read
      • Read file by data type
      • Data type constant
    • Chart
      • Chart type constant
      • Data input
      • Doughnut chart
      • Area chart
      • Histogram chart
      • Bar chart
    • Cell
      • Insert text
      • Insert link
      • Insert formula
      • Insert date
      • Insert local image
      • Automatic filtering
      • Freeze Panes
      • Merge Cells
      • Row cell style
      • Column cell style
    • Memory model
      • Export - Fixed memory mode
    • Worksheet
      • Create worksheet
      • Switch worksheet
      • Gridlines
      • Zoom
      • Hide the current worksheet
      • Set the current worksheet as the first worksheet
    • Style
      • Combination style
      • Gloabl default style
    • Download
    • Style list
      • Italic
      • Align
      • Text deletion (text middle line)
      • Underline
      • Text wrap
      • Text color
      • Text size
      • Bold
      • Cell border
      • Border style constant
      • Background color
      • Color constant
      • Font
      • Number format
    • CSV
      • XLSX to CSV - Normal mode
      • XLSX to CSV - Callback function mode
    • Printed
      • Set print orientation-landscape
      • Set print orientation-portrait
    • Assistant functions
      • Column index transform
      • Get version
      • Get author
  • Project recommendation
  • 中文简体
    • 安装
      • 环境要求
      • PECL(推荐)
      • Mac
      • Ubuntu
      • Alpine
      • Windows
      • Docker多阶构建
    • 快速上手
      • 导出文件
      • 读取文件
      • 手动销毁资源
    • 读取文件
      • 工作表列表
      • 全量读取
      • 游标读取
      • 跳过指定行
      • 忽略空白单元格
      • 忽略空白行
      • 忽略跳过动作常量
      • 设置全局读取类型
      • 单元格回调模式读取
      • 数据类型读取
      • 数据类型常量
    • 图表
      • 图表类型常量
      • 填充数据
      • 圆环图
      • 面积图
      • 直方图
      • 条形图
    • 数据验证
      • 下拉列表
      • 范围约束
      • 大于约束
    • 单元格
      • 插入文字
      • 插入链接
      • 插入公式
      • 插入日期
      • 插入本地图片
      • 自动过滤
      • 冻结单元格
      • 合并单元格
      • 行单元格样式
      • 列单元格样式
    • 内存模式
      • 导出 - 固定内存模式
    • 工作表
      • 创建工作表
      • 切换工作表
      • 检查工作表是否存在
      • 网格线
      • 缩放
      • 隐藏当前工作表
      • 设置当前工作表为第一个工作表
    • 样式
      • 组合样式
      • 全局默认样式
    • 锁定保护
      • 密码保护
      • 解除保护
    • 打印
      • 纸张大小
      • 纸张方向
      • 纸张边距
      • 缩放比例
      • 设置打印方向 - 横向
      • 设置打印方向 - 纵向
    • 下载
    • 样式列表
      • 斜体
      • 对齐
      • 文本删除(文本中间划线)
      • 下划线
      • 文本换行
      • 文本颜色
      • 文本字号
      • 多样式文本
      • 粗体
      • 单元格边框
      • 边框样式常量
      • 背景颜色
      • 颜色常量
      • 字体
      • 数字格式化
    • CSV
      • XLSX转为CSV - 常规模式
      • XLSX转为CSV - 回调模式
    • 辅助函数
      • 列标字符转化
      • 设置当前写入行号
      • 获取当前写入行号
      • 获取扩展版本
      • 查看作者信息
    • 异常列表
      • 异常码列表
    • 常见问题
      • xls文件通过excel转成xlsx格式后无法读取
  • 项目推荐
Powered by GitBook
On this page
  • 优势
  • 函数原型
  • 回调函数原型
  • 单行结束标识
  • 示例
  • 示例输出

Was this helpful?

  1. 中文简体
  2. 读取文件

单元格回调模式读取

  • 读取文件已支持 windows 系统,版本号大于等于 1.3.4.1;

  • 扩展版本大于等于 1.2.7;

  • PECL 安装时将会提示是否开启读取功能,请键入 yes;

优势

最大内存 == 最大单元格数据体积

该模式可满足 xlsx 大文件读取

函数原型

nextCellCallback(callable $callback, string $sheetName = NULL): void

回调函数原型

function(int $row, int $cell, string|double|int $data)

单行结束标识

每行末尾,将会附加一次回调,并传递 XLSX_ROW_END 为当前行结束标识。

示例

$config   = ['path' => './tests'];
$excel    = new \Vtiful\Kernel\Excel($config);
$filePath = $excel->fileName('tutorial.xlsx')
    ->header(['Item', 'Cost'])
    ->data([
        ['Item_1', 'Cost_1'],
    ])
    ->output();

$excel->openFile('tutorial.xlsx')->nextCellCallback(function ($row, $cell, $data) {
    echo 'cell:' . $cell . ', row:' . $row . ', value:' . $data . PHP_EOL;
});

示例输出

cell:0, row:0, value:Item
cell:1, row:0, value:Cost
cell:1, row:0, value:XLSX_ROW_END  // 结束标识
cell:0, row:1, value:Item_1
cell:1, row:1, value:Cost_1
cell:1, row:1, value:XLSX_ROW_END // 结束标识
Previous设置全局读取类型Next数据类型读取

Last updated 5 years ago

Was this helpful?