🚀 PHP Extension for creating and reader XLSX files.

Overview

Why use xlswriter

Please refer to the image below. PHPExcel has been unable to work properly for memory reasons at 40,000 and 100000 points, but it can be resolved by modifying the ini configuration, but the time may take longer to complete the work;

php-excel

xlswriter is a PHP C Extension that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file. It supports features such as:

Writer
  • 100% compatible Excel XLSX files.
  • Full Excel formatting.
  • Merged cells.
  • Defined names.
  • Autofilters.
  • Charts.
  • Data validation and drop down lists.
  • Worksheet PNG/JPEG images.
  • Memory optimization mode for writing large files.
  • Works on Linux, FreeBSD, OpenBSD, OS X, Windows.
  • Compiles for 32 and 64 bit.
  • FreeBSD License.
  • The only dependency is on zlib.
Reader
  • Full read data
  • Cursor read data
  • Read by data type

Install

Unix
pecl install xlswriter
Windows

download dll

Benchmark

Test environment: Macbook Pro 13 inch, Intel Core i5, 16GB 2133MHz LPDDR3 Memory, 128GB SSD Storage.

Export

Two memory modes export 1 million rows of data (27 columns, data is string)

  • Normal mode: only 29S is needed, and the memory only needs 2083MB;
  • Fixed memory mode: only need 52S, memory only needs <1MB;
Import

1 million rows of data (1 columns, data is inter)

  • Full mode: Just 3S, the memory is only 558MB;
  • Cursor mode: Just 2.8S, memory is only <1MB;

Documents

Includes extensive and detailed instructions that make it easy to get started with xlswriter.

PECL Repository

pecl

IDE Helper

composer require viest/php-ext-xlswriter-ide-helper:dev-master

Exchange group

Financial donation

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

BSD License

FOSSA Status

Stargazers over time

Stargazers over time

Comments
  • centos安装扩展失败

    centos安装扩展失败

    编译最后一步

    sudo make && make install

    In file included from /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:186:
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/crypt.h:35: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/crypt.h:48: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/crypt.h:65: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/crypt.h:94: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c: In function ‘zipOpenNewFileInZip4_64’:
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1245: error: ‘curfile64_info’ has no member named ‘crypt_header_size’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1251: error: ‘curfile64_info’ has no member named ‘pcrc_32_tab’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1254: error: ‘curfile64_info’ has no member named ‘pcrc_32_tab’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1255: error: ‘curfile64_info’ has no member named ‘crypt_header_size’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c: In function ‘zip64FlushWriteBuffer’:
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1375: error: ‘curfile64_info’ has no member named ‘pcrc_32_tab’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1375: error: ‘curfile64_info’ has no member named ‘pcrc_32_tab’
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c: In function ‘zipCloseFileInZipRaw64’:
    /usr/local/src/php-ext-excel-export/library/third_party/minizip/zip.c:1610: error: ‘curfile64_info’ has no member named ‘crypt_header_size’
    make: *** [library/third_party/minizip/zip.lo] Error 1
    

    环境 PHP 7.2.13 (cli) (built: Dec 8 2018 12:27:01) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.7, Copyright (c) 1999-2018, by Zend Technologies

    rinting-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.7 (Final) Release: 6.7 Codename: Final

    opened by needrunning 18
  • How to apply format for range only?

    How to apply format for range only?

    I have a problem when using format on columns. Is there any way to apply format only to a specific range, not the whole column?

               $formatResource = $format->bold()->align(Format::FORMAT_ALIGN_CENTER, 
               Format::FORMAT_ALIGN_VERTICAL_CENTER)->toResource();
               $fileObject->setColumn('A1:F5', 30, $formatResource);
    
    opened by sirhvd 14
  • alpine 编译安装最新版失败

    alpine 编译安装最新版失败

    uname -a Linux 157f56d7c500 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64 Linux

    make错误信息

    lswriter-master/xlswriter.c  -fPIC -DPIC -o .libs/xlswriter.o
    In file included from /usr/local/src/php-ext-xlswriter-master/xlswriter.c:19:
    /usr/local/src/php-ext-xlswriter-master/include/xlswriter.h:29:10: fatal error: xlsxwriter.h: No such file or directory
       29 | #include "xlsxwriter.h"
          |          ^~~~~~~~~~~~~~
    compilation terminated.
    make: *** [Makefile:192: xlswriter.lo] Error 1
    
    
    opened by guiqibusixin 13
  • 设置样式报错

    设置样式报错

    插件版本 version 1.2.4

    代码如下

    $fileHandle = $this->handle->getHandle();
            $alignStyle = \Vtiful\Kernel\Format::align(
                $fileHandle,
                \Vtiful\Kernel\Format::FORMAT_ALIGN_CENTER,
                \Vtiful\Kernel\Format::FORMAT_ALIGN_VERTICAL_CENTER
            );
            foreach ($styles as $key => $width) {
                $this->handle->setColumn($key, (int) $width, $alignStyle);
                $this->handle->setColumn($key, (int) $width, $alignStyle);
            }
    
            $format    = new \Vtiful\Kernel\Format($fileHandle);
            $boldStyle = $format->bold()->toResource();
            $colorStyle = $format->color(\Vtiful\Kernel\Format::COLOR_ORANGE)->toResource();
    
    

    分别报错

      $format    = new \Vtiful\Kernel\Format($fileHandle);
     "Vtiful\\Kernel\\Format::bold() expects exactly 1 parameter, 0 given"
    
    $colorStyle = $format->color(\Vtiful\Kernel\Format::COLOR_ORANGE)->toResource();
    Call to undefined method Vtiful\\Kernel\\Format::color()
    
    opened by needrunning 13
  • 1.3.7编译错误

    1.3.7编译错误

    /usr/local/cellar/xlswriter-1.3.7/kernel/excel.c:43:22: error: no member named 'data_type_default' in 'xls_resource_read_t' intern->read_ptr.data_type_default = READ_TYPE_EMPTY; ~~~~~~~~~~~~~~~~ ^ 1 error generated.

    opened by yzh52521 11
  • xlsx转换csv能否增加不改变格式选项

    xlsx转换csv能否增加不改变格式选项

    image 在使用putCsv方法的时候,遇到了两个、个问题。原excel中的 2017/1/3 11:31 会变成 42738.479861111 还有就是 2018-01-01 10:16:10, 会变成 2018-01-0110:16:10, 中间少了一个空格

    您看看能不能在putCsv方法增加一个 不做任何转换的 参数,或者对这种格式做一下处理

    出问题的excel文件 http://smellycat.top/%E3%80%90%E4%B8%8D%E8%A7%84%E5%88%99%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86%E5%8A%9E%E6%B3%95%E5%AD%98%E5%9C%A8%EF%BC%88%E9%A2%84%E6%9C%9F%E7%BB%93%E6%9E%9C%E7%9A%84%EF%BC%89%E3%80%91_-%E5%9B%9E%E5%BD%92%E6%B5%8B%E8%AF%95.xlsx

    转换后的 csv文件 http://smellycat.top/%E8%BD%AC%E6%8D%A2%E7%9A%84csv.csv

    我测试的代码 $excel = new \Vtiful\Kernel\Excel(['path'=>'']); $fp = fopen('origin.csv', 'a'); $excel->openFile('/home/xiaoming/20191214113424_611.xlsx')->openSheet('回归测试日期标准数据')->putCSV($fp);

    期待您的回复。

    opened by shailuobodemao 10
  • make: Nothing to be done for 'install'

    make: Nothing to be done for 'install'

    你好, 我在执行 make && make install 出现了 make: *** No targets specified and no makefile found. Stop, 然后我发现有 Makefile.global 文件,于是将它的名字改成了 makefile ……,再次运行 make . 后出现了 Build complete. Don't forget to run 'make test'. make: Nothing to be done for 'install',我搜索了相关的东西,但是没能解决这个这问题。 于是暂且认为这只是一个提醒,继续接下来的步骤,然后提示 Class 'Vtiful\Kernel\Excel' not found, 我是想在 laravel 5.7 中使用它的,想必应该是扩展没有安装成功。 希望你可以抽时间回复下我的问题!

    opened by vioulo 10
  • 读取excel设置类型string

    读取excel设置类型string

     $config = ['path' => public_path().'/public/'];
            $excel  = new \Vtiful\Kernel\Excel($config);
            // 读取测试文件
            $data = $excel->openFile($path)
                ->openSheet()
                ->setType([
                    \Vtiful\Kernel\Excel::TYPE_STRING
                ])
                ->getSheetData();
    

    设置了string 类型 读出来的数据 还是自动转成了 float . 怎么强制必须是string 因为身份证号字段会转成float。

    opened by qingmang 8
  • segfault in test suite on 32-bit

    segfault in test suite on 32-bit

    TEST 48/58 [tests/open_xlsx_next_cell_callback_with_data_type.phpt]
    ========DIFF========
    017+ *** stack smashing detected ***: <unknown> terminated
    018+ 
    019+ Termsig=6
    017- cell:2, row:1
    018- int(10)
    019- cell:3, row:1
    020- float(10.9999995)
    021- cell:4, row:1
    022- int(1568904314)
    023- cell:4, row:1
    024- string(12) "XLSX_ROW_END"
    ========DONE========
    FAIL Check for vtiful presence [tests/open_xlsx_next_cell_callback_with_data_type.phpt] 
    
    ========DIFF========
    003+ *** stack smashing detected ***: <unknown> terminated
    004+ 
    005+ Termsig=6
    003- array(3) {
    004-   [0]=>
    005-   int(1)
    006-   [1]=>
    007-   string(4) "Test"
    008-   [2]=>
    009-   int(1568389354)
    010- }
    011- NULL
    ========DONE========
    FAIL Check for vtiful presence [tests/open_xlsx_next_row_with_set_type.phpt] 
    
    
    opened by remicollet 8
  • mac php7.1 安装报错

    mac php7.1 安装报错

    环境:unix 系统
    语言版本:php7.1

    安装方式:sudo pecl install xlswriter (手动安装也失败,采用这种方式,安装过其他的扩展没有问题)

    /private/tmp/pear/install/xlswriter/library/third_party/minizip/zip.c:160:11: error: unknown type name 'z_crc_t' const z_crc_t* pcrc_32_tab; ^ In file included from /private/tmp/pear/install/xlswriter/library/third_party/minizip/zip.c:186: /private/tmp/pear/install/xlswriter/library/third_party/minizip/crypt.h:35:53: error: unknown type name 'z_crc_t' static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) ^ /private/tmp/pear/install/xlswriter/library/third_party/minizip/crypt.h:48:51: error: unknown type name 'z_crc_t' static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) ^ /private/tmp/pear/install/xlswriter/library/third_party/minizip/crypt.h:65:69: error: unknown type name 'z_crc_t' static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) ^ /private/tmp/pear/install/xlswriter/library/third_party/minizip/crypt.h:94:28: error: unknown type name 'z_crc_t' const z_crc_t* pcrc_32_tab, ^ 5 errors generated. make: *** [library/third_party/minizip/zip.lo] Error 1 ERROR: `make' failed

    opened by jasonjiang123 8
  • 编译安装报 fatal error: xlsxwriter.h: No such file or directory            #include

    编译安装报 fatal error: xlsxwriter.h: No such file or directory #include "xlsxwriter.h

    版本 1.3.6 php 7.3

    执行make命令时报以下错误,请问是什么原因导致的?感谢

    /bin/sh /root/php-ext-xlswriter-1.3.6/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DNOCRYPT -DNOUNCRYPT -I. -I/root/php-ext-xlswriter-1.3.6 -DPHP_ATOM_INC -I/root/php-ext-xlswriter-1.3.6/include -I/root/php-ext-xlswriter-1.3.6/main -I/root/php-ext-xlswriter-1.3.6 -I/www/server/php/73/include/php -I/www/server/php/73/include/php/main -I/www/server/php/73/include/php/TSRM -I/www/server/php/73/include/php/Zend -I/www/server/php/73/include/php/ext -I/www/server/php/73/include/php/ext/date/lib -I/root/php-ext-xlswriter-1.3.6/library/libxlsxwriter/include -I/root/php-ext-xlswriter-1.3.6/. -I/root/php-ext-xlswriter-1.3.6/include  -DHAVE_CONFIG_H  -g -O2   -c /root/php-ext-xlswriter-1.3.6/kernel/exception.c -o kernel/exception.lo                                                                                            
    cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DNOCRYPT -DNOUNCRYPT -I. -I/root/php-ext-xlswriter-1.3.6 -DPHP_ATOM_INC -I/root/php-ext-xlswriter-1.3.6/include -I/root/php-ext-xlswriter-1.3.6/main -I/root/php-ext-xlswriter-1.3.6 -I/www/server/php/73/include/php -I/www/server/php/73/include/php/main -I/www/server/php/73/include/php/TSRM -I/www/server/php/73/include/php/Zend -I/www/server/php/73/include/php/ext -I/www/server/php/73/include/php/ext/date/lib -I/root/php-ext-xlswriter-1.3.6/library/libxlsxwriter/include -I/root/php-ext-xlswriter-1.3.6/. -I/root/php-ext-xlswriter-1.3.6/include -DHAVE_CONFIG_H -g -O2 -c /root/php-ext-xlswriter-1.3.6/kernel/exception.c  -fPIC -DPIC -o kernel/.libs/exception.o                
     In file included from /root/php-ext-xlswriter-1.3.6/kernel/exception.c:13:0:                                            
    /root/php-ext-xlswriter-1.3.6/include/xlswriter.h:28:24: fatal error: xlsxwriter.h: No such file or directory            #include "xlsxwriter.h"                                                                                                                        ^                                                                                               compilation terminated.                                                                                                 make: *** [kernel/exception.lo] Error 1                                                                                                                       ^  
    
    opened by jqhph 7
  • php8.2中导出失败

    php8.2中导出失败

    相同的数据在php7.3的时候可以成功导出,php8.2导出失败

    // 报出的异常
    Worksheet row or column index out of range.
    
    php -v
    PHP 8.2.0 (cli) (built: Dec 10 2022 10:52:42) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.2.0, Copyright (c) Zend Technologies
        with Zend OPcache v8.2.0, Copyright (c), by Zend Technologies
    
    php --ri xlswriter
    
    xlswriter
    
    xlswriter support => enabled
    Version => 1.5.2
    bundled libxlsxwriter version => 1.1.3
    bundled libxlsxio version => 0.2.27
    
    opened by JieAnthony 1
  • fix: 内存模式下,设置单个单元格内容格式,内存模式会失效,导致内存不断堆叠溢出

    fix: 内存模式下,设置单个单元格内容格式,内存模式会失效,导致内存不断堆叠溢出

    $config     = ['path' => '/'];
    $excel = new \Vtiful\Kernel\Excel($config); 
    $fileObject = $excel->constMemory('test.xlsx', '内存占用', false);
    for ($index = 0; $index < 10000; $index++) {
        for ($column = 0; $column < 300; $column++) {
            $mem = self::getMemoryUsage('MemRealUsage');
            $mem = $mem / (1024 * 1024);
            $fileObject->insertText($index+1, $column, floatval($mem), 'Max$#,##0.00;Max$-#,##0.00');
            var_dump($mem);
        }
    }
    $filePath = $fileObject->output();
    $fileObject->close();
    
    opened by mingdiantianxia 0
  • Get calculated value from cell?

    Get calculated value from cell?

    Hi, thanks for this awesome extension. Can you advise, how i can get a few calculated value from Excel file? I have very big calculation on excel, so i can't move it to php.

    opened by ka5itoshka 0
Releases(v1.5.2)
Owner
viest
enjoy life.
viest
Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

OpenSpout OpenSpout is a community driven fork of box/spout, a PHP library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scal

null 239 Jan 6, 2023
Parse and retrieve data from old format Excel XLS files. MS Excel 97 workbooks PHP reader.

SimpleXLS class 0.9.15 Parse and retrieve data from old Excel .XLS files. MS Excel 97-2003 workbooks PHP reader. PHP BIFF reader. No additional extens

Sergey Shuchkin 160 Jan 6, 2023
A pure PHP library for reading and writing spreadsheet files

PhpSpreadsheet PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file f

PHPOffice 11.8k Jan 8, 2023
A pure PHP library for reading and writing project management files

PHPProject PHPProject is a library written in pure PHP that provides a set of classes to write to different project management file formats, i.e. Micr

PHPOffice 192 Dec 17, 2022
Merge Excel Files to single excel file per columns

Merge Excel Files to single excel file per columns

Max Base 3 Apr 26, 2021
CSV files from Eloquent model in seconds - a Laravel package.

LaraCSV A Laravel package to easily generate CSV files from Eloquent model. Basic usage $users = User::get(); // All users $csvExporter = new \Laracsv

Muhammad Usman 604 Dec 16, 2022
PhpSpreadsheet - a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc

PhpSpreadsheet PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file f

PHPOffice 11.8k Dec 31, 2022
A pure PHP library for reading and writing word processing documents

Master: Develop: PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. Th

PHPOffice 6.5k Jan 7, 2023
A pure PHP library for reading and writing presentations documents

Branch Master : Branch Develop : PHPPresentation is a library written in pure PHP that provides a set of classes to write to different presentation fi

PHPOffice 1.2k Jan 2, 2023
🚀 Supercharged Excel exports and imports in Laravel

Supercharged Excel exports and imports A simple, but elegant Laravel wrapper around PhpSpreadsheet exports and imports. Quickstart · Documentation · V

Maatwebsite 11.2k Jan 4, 2023
Simple yet powerful Excel manipulation library for PHP 5.4+

| | \ / \_/ __ /^\ __ ' `. \_/ ,' ` \/ \/ _,--./| |\.--._ _,' _.-\_/-._ `._ | / \ | |

Wisembly 68 Sep 20, 2022
an excel export/import tool for laravel based on php-xlswriter

Laravel-xlswriter 一款基于xlswriter的laravel扩展包 php-xlswriter是一款高性能的excel读写扩展,laravel-xlswriter基于该扩展做了封装,旨在提供一个便于使用的xlswriter的laravel工具包。 目前laravel-xlswrit

lysice 54 Dec 3, 2022
CSV data manipulation made easy in PHP

CSV Csv is a simple library to ease CSV parsing, writing and filtering in PHP. The goal of the library is to be powerful while remaining lightweight,

The League of Extraordinary Packages 3k Jan 1, 2023
Simplexcel.php - Easily read / parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc spreadsheet tabular file formats

Simple Excel Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats For further deatails see the GitHuib P

Faisal Salman 550 Dec 27, 2022
ExcelAnt - Simple yet powerful Excel manipulation library for PHP 5.4+

ExcelAnt is an Excel manipulation library for PHP 5.4. It currently works on top of PHPExcel. If you want to add / use another library, feel free to fork and contribute !

Wisembly 68 Sep 20, 2022
A PHP spreadsheet reader (Excel XLS and XLSX, OpenOffice ODS, and variously separated text files) with a singular goal of getting the data out, efficiently

spreadsheet-reader is a PHP spreadsheet reader that differs from others in that the main goal for it was efficient data extraction that could handle l

Nuovo 666 Dec 24, 2022
Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

Spout Spout is a PHP library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way. Contrary to other file readers or wr

Box 4.2k Jan 6, 2023
Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

OpenSpout OpenSpout is a community driven fork of box/spout, a PHP library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scal

null 239 Jan 6, 2023
Magento 2 Module for parsing xlsx, xlsm and csv files from Excel

Magento 2 Spreadsheet Parser Facts Parse XLSX, XLSM and CSV Files from Excel Requirements PHP >= 7.0.* Magento >= 2.1.* Compatibility Magento >= 2.1 U

Stämpfli AG 9 Sep 24, 2020
Parse and retrieve data from old format Excel XLS files. MS Excel 97 workbooks PHP reader.

SimpleXLS class 0.9.15 Parse and retrieve data from old Excel .XLS files. MS Excel 97-2003 workbooks PHP reader. PHP BIFF reader. No additional extens

Sergey Shuchkin 160 Jan 6, 2023