定制 sulabh/excel-file-package 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sulabh/excel-file-package

最新稳定版本:v1.1.4

Composer 安装命令:

composer require sulabh/excel-file-package

包简介

A package to create Excel files from data

README 文档

README

Excel file package is a composer package used to export data from database to excel sheet with proper heading and formatting of data.

This is more than 85% Faster than existing Solutions

Installation

Use the package manager composer to install Excel File Package.

composer require sulabh/excel-file-package

Usage

require 'vendor/autoload.php';

use Sulabh\ExcelFilePackage\ExcelFile;
use App\Model\User;

// data to be exported, supported format is Laravel's Model.
// You can filter the data as per your need using where conditions;
$data = User::query();

// Number of data you want in a Single Sheet. 
// 1 Excel Sheet can store upto 1,048,576 rows, 
// so this value should not exceed 1,048,575. 
// 1 is for header
$chunk_size = 100000;

// List of headers in each column respectively
$header = ['S.No', 'Name', 'Email', 'Phone Number'];

// No need to use .xlsx, even if entered its filtered by the package
$file_name = "UsersExport";

// Define how the data in export should be displayed
$row_formatter = function($row) {
  return [
    'SERIAL_NO', // This is a wildcard and represents an incremental value, It starts with 1 in every sheet
    $row->first_name." ".$row->last_name,
    $row->email,
    $row->phone_number,
  ];
};

// Optional
$total_count = $data->count();

ExcelFile::createExcelFile($data, $chunk_size, $header, $file_name, $row_formatter, $total_data);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-14