All Projects → jqhph → easy-excel

jqhph / easy-excel

Licence: MIT license
🚀 快速读写Excel文件,简单高效

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to easy-excel

Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+8905.93%)
Mutual labels:  excel, xlsx, spreadsheet, ods
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+1878.81%)
Mutual labels:  excel, xlsx, spreadsheet, ods
xlsx-reader
xlsx-reader is a PHP library for fast and efficient reading of XLSX spreadsheet files. Its focus is on reading the data contained within XLSX files, disregarding all document styling beyond that which is strictly necessary for data type recognition. It is built to be usable for very big XLSX files in the magnitude of multiple GBs.
Stars: ✭ 40 (-66.1%)
Mutual labels:  excel, xlsx, spreadsheet
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+24034.75%)
Mutual labels:  excel, xlsx, spreadsheet
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+754.24%)
Mutual labels:  excel, xlsx, spreadsheet
Docjure
Read and write Office documents from Clojure
Stars: ✭ 510 (+332.2%)
Mutual labels:  excel, xlsx, spreadsheet
Reogrid
Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.
Stars: ✭ 532 (+350.85%)
Mutual labels:  excel, xlsx, spreadsheet
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+8181.36%)
Mutual labels:  excel, xlsx, spreadsheet
excel validator
Python script to validate data in Excel files
Stars: ✭ 14 (-88.14%)
Mutual labels:  excel, xlsx, spreadsheet
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+8616.95%)
Mutual labels:  excel, xlsx, spreadsheet
spreadcheetah
SpreadCheetah is a high-performance .NET library for generating spreadsheet (Microsoft Excel XLSX) files.
Stars: ✭ 107 (-9.32%)
Mutual labels:  excel, xlsx, spreadsheet
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+190.68%)
Mutual labels:  excel, xlsx, spreadsheet
Unioffice
Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents
Stars: ✭ 3,111 (+2536.44%)
Mutual labels:  excel, xlsx, spreadsheet
Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+395.76%)
Mutual labels:  excel, xlsx, spreadsheet
ExcelFormulaBeautifier
Excel Formula Beautifer,make Excel formulas more easy to read,Excel公式格式化/美化,将Excel公式转为易读的排版
Stars: ✭ 27 (-77.12%)
Mutual labels:  excel, xlsx, spreadsheet
Xlnt
📊 Cross-platform user-friendly xlsx library for C++11+
Stars: ✭ 876 (+642.37%)
Mutual labels:  excel, xlsx, spreadsheet
fxl.js
ƛ fxl.js is a data-oriented JavaScript spreadsheet library. It provides a way to build spreadsheets using modular, lego-like blocks.
Stars: ✭ 27 (-77.12%)
Mutual labels:  excel, xlsx, spreadsheet
XToolset
Typed import, and export XLSX spreadsheet to JS / TS. Template-based create, render, and export data into excel files.
Stars: ✭ 110 (-6.78%)
Mutual labels:  excel, xlsx, spreadsheet
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-48.31%)
Mutual labels:  excel, xlsx, spreadsheet
Xlsx
Fast and reliable way to work with Microsoft Excel™ [xlsx] files in Golang
Stars: ✭ 132 (+11.86%)
Mutual labels:  excel, xlsx, spreadsheet

EASY EXCEL

StyleCI

Easy Excel是一个基于 box/spout 封装的Excel读写工具,可以帮助开发者更快速更轻松地读写Excel文件, 并且无论读取多大的文件只需占用极少的内存。

由于box/spout只支持读写xlsxcsvods等类型文件,所以本项目目前也仅支持读写这三种类型的文件。

文档

文档

环境

  • PHP >= 7.1
  • PHP extension php_zip
  • PHP extension php_xmlreader
  • box/spout >= 3.0
  • league/flysystem >= 1.0

安装

composer require dcat/easy-excel

快速开始

导出

下载

use Dcat\EasyExcel\Excel;

$array = [
    ['id' => 1, 'name' => 'Brakus', 'email' => '[email protected]', 'created_at' => '...'], 
    ...
];

$headings = ['id' => 'ID', 'name' => '名称', 'email' => '邮箱'];

// xlsx
Excel::export($array)->headings($headings)->download('users.xlsx');

// csv
Excel::export($array)->headings($headings)->download('users.csv');

// ods
Excel::export($array)->headings($headings)->download('users.ods');

保存

use Dcat\EasyExcel\Excel;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

$array = [...];

// 保存到当前服务器
Excel::export($array)->store('/tmp/users.xlsx');


// 使用 filesystem
$adapter = new Local(__DIR__);

$filesystem = new Filesystem($adapter);

Excel::export($array)->disk($filesystem)->store('users.xlsx');

获取文件内容

use Dcat\EasyExcel\Excel;

$array = [...];

$xlsxContents = Excel::xlsx($array)->raw();

$csvContents = Excel::csv($array)->raw();

$odsContents = Excel::ods($array)->raw();

更多导出功能请参考文档

导入

读取所有表格数据

use Dcat\EasyExcel\Excel;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

$headings = ['id', 'name', 'email'];

// 导入xlsx
$allSheets = Excel::import('/tmp/users.xlsx')->headings($headings)->toArray();


// 使用filesystem
$adapter = new Local(__DIR__);

$filesystem = new Filesystem($adapter);

$allSheets = Excel::import('users.xlsx')->disk($filesystem)->headings($headings)->toArray();


print_r($allSheets); // ['Sheet1' => [['id' => 1, 'name' => 'Brakus', 'email' => '[email protected]', 'created_at' => '...']]]

遍历表格

use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Contracts\Sheet as SheetInterface;
use Dcat\EasyExcel\Support\SheetCollection;

// 导入xlsx
Excel::import('/tmp/users.xlsx')->each(function (SheetInterface $sheet) {
    // 获取表格名称,如果是csv文件,则此方法返回空字符串
    $sheetName = $sheet->getName();

    // 表格序号,从 0 开始
    $sheetIndex = $sheet->getIndex();
    
    // 是否是最后一次保存前打开的表格
    $isActive = $sheet->isActive();
    
    // 分块处理表格数据
    $sheet->chunk(100, function (SheetCollection $collection) {
        $chunkArray = $collection->toArray();
        
        print_r($chunkArray); // [['id' => 1, 'name' => 'Brakus', 'email' => '[email protected]', 'created_at' => '...']]
    });
    
});

获取指定表格内容

use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Support\SheetCollection;

// 获取第一个表格内容
$firstSheet = Excel::import('/tmp/users.xlsx')->first()->toArray();


// 获取最后一次保存前打开的表格内容
$activeSheet = Excel::import('/tmp/users.xlsx')->active()->toArray();


// 获取指定名称或序号的表格内容
$sheet = Excel::import('/tmp/users.xlsx')->sheet('Sheet1')->toArray();
$sheet = Excel::import('/tmp/users.xlsx')->sheet(0)->toArray();


// 分块处理表格内容
Excel::import('/tmp/users.xlsx')
    ->first()
    ->chunk(1000, function (SheetCollection $collection) {
        $collection = $collection->keyBy('id');
    });

更多导入功能请参考文档

License

The MIT License (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].