PHPackages                             dongdavid/excel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dongdavid/excel

ActiveLibrary

dongdavid/excel
===============

Excel导入导出工具类.

v1.0.1(5y ago)06MITPHP

Since Mar 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/DongDavid/excel)[ Packagist](https://packagist.org/packages/dongdavid/excel)[ RSS](/packages/dongdavid-excel/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

 excel
=======

[](#-excel-)

 .

\## 这个功能有问题，不能用 Installing
----------

[](#installing)

```
$ composer require dongdavid/excel -vvv
```

Usage
-----

[](#usage)

### 导入数据

[](#导入数据)

```
\Dongdavid\Excel\QuickStart::getExcelRow($filename); // 获取当前sheet的行数
\Dongdavid\Excel\QuickStart::importByLimit($filename,$startRow,$endRow);
```

```
// 读完后会自动释放内存
// 10万条数据 一次1000条 读一次要4秒， 14MB内存 全部读完要7分钟， 总消耗内存在40MB左右
// 10万条数据 一次3000条 读一次5秒 14MB
$filename = "./output/quick100000.xlsx";
$debug = [];
$debug[] = [microtime(true),round(memory_get_usage()/1024/1024,2)];
$data = [];
for ($i = 0;$i < 100;$i++){
    $t = microtime(true);
    $tmp = \Dongdavid\Excel\QuickStart::importByLimit($filename,$i*10,($i+1)*1000);
    //$data = array_merge($data,$tmp);
    $t1 = microtime(true);
    echo $t1-$t .'s'.PHP_EOL;
    echo '数量'.$tmp['total'].PHP_EOL;
    echo memory_get_usage()/1024/1024 .'MB'.PHP_EOL;
}
```

### 导出数据

[](#导出数据)

更多的用法可以参考[xlsxwriter](https://packagist.org/packages/mk-j/php_xlsxwriter)

```
// 10万行 18秒 80MB内存
// 1万行 2秒 14MB内存
$data = [
   ['我是表头1','我是表头2','我是表头3','我是表头4','我是表头5','我是表头6','我是表头7','我是表头8','我是表头9']
];
$line = [
    ['你好啊','我不好',23.434523,'TP239d2ojd0e3','40.0%','第六咧','哈哈哈','啊啊啊啊','0003232'],
    ['你好啊23','我不好',-23223,'TACOIS$$@#ojd0e3','40.0%','第六咧','哈哈哈','啊啊啊啊',10000000000032]
];
for ($i = 0;$i < 10000;$i++){
    $data[] = $line[0];
    $data[] = $line[1];
    $data[] = $line[0];
    $data[] = $line[1];
    $data[] = $line[0];
    $data[] = $line[1];
    $data[] = $line[1];
    $data[] = $line[0];
    $data[] = $line[0];
    $data[] = $line[1];
}
// 导出到文件
\Dongdavid\Excel\QuickStart::export('./output/quick.xlsx',$data);
// 导出到浏览器 会自己设置响应头
\Dongdavid\Excel\QuickStart::exportDown('quick.xlsx',$data);
```

```
// 复杂调用
$rows = [
    [],
    [],
];
$col = 10; //列数
$sheetName = 'Sheet1'; //非必填 默认为Sheet1
$excel = new \Dongdavid\Excel\Excel();
$excel->init(false);
//$excel->setTitle(['表头1','表头2','表头3','表头4']);
$excel->setTitle(['表头1'=>'string','表头2'=>'0.00%','表头3'=>'string','表头4'=>'0.0']); // 设置不同列的格式
foreach($rows as $row){
    $excel->writeRow($row,$sheetName);
}
$excel->toFile("./output/result.xlsx");
```

每一行都设置不同的格式

```
$row = [

];
$excel = new \Dongdavid\Excel\Excel();
$excel->init(false);
//$excel->writeRow($row);
//$excel->setFormate(['1'=>'string','23438932'=>'string','32'=>'0.00%']);
$excel->writeRow($row);
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/dongdavid/excel/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/dongdavid/excel/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1888d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18623095?v=4)[DongDavid](/maintainers/dongdavid)[@DongDavid](https://github.com/DongDavid)

---

Top Contributors

[![DongDavid](https://avatars.githubusercontent.com/u/18623095?v=4)](https://github.com/DongDavid "DongDavid (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dongdavid-excel/health.svg)

```
[![Health](https://phpackages.com/badges/dongdavid-excel/health.svg)](https://phpackages.com/packages/dongdavid-excel)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[in2code/powermail

Powermail is a well-known, editor-friendly, powerful and easy to use mailform extension for TYPO3 with a lots of features

982.5M38](/packages/in2code-powermail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
