Skip to content

Latest commit

 

History

History
97 lines (65 loc) · 2.48 KB

README.md

File metadata and controls

97 lines (65 loc) · 2.48 KB

EasyExcel

Build Status License Platform Support

简介 Summary

使用 3MB 左右的低内存读取、写入大电子表格,支持格式 CSV、ODS、XLS、XLSX。

Use low memory of around 3MB to read and write large spreadsheets, supporting formats CSV, ODS, XLS, and XLSX.

环境要求 Environment

  • PHP version ^7.1||^8.0
  • PHP extension xml
  • PHP extension libxml
  • PHP extension fileinfo
  • PHP extension simplexml
  • PHP extension xmlreader
  • PHP extension xmlwriter
  • PHP extension iconv (suggest)
  • PHP extension mbstring (suggest)

安装 Install

composer require chenmobuys/easyexcel

使用方法 Usage

<?php

use EasyExcel\Factory;
use EasyExcel\Metadata\Style;

// read excel
$filename = "/path/to/sample.xlsx";
$reader = Factory::load($filename);
foreach ($reader->getRowIterator() as $row) {
    $rowArray = $row->toArray();
}

// write excel
$filename = "/path/to/sample.xlsx";
$writer = Factory::open($filename);
$writer->addRow(["Foo", "Bar"])->close();

// write excel with style
$filename = "/path/to/sample.xlsx";
$writer = Factory::open($filename);
$style = Style::builder()
    ->setFontSize(12)
    ->setFontColor(Style\Color::RED)
    ->build();
$writer->addRow(["Foo", "Bar"], $style)->close();

参考 Refer