定制 ceytek-labs/php-spreadsheet-lite 二次开发

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

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

ceytek-labs/php-spreadsheet-lite

最新稳定版本:v1.0.2

Composer 安装命令:

composer require ceytek-labs/php-spreadsheet-lite

包简介

A lightweight library for creating and reading spreadsheets in CSV or XLSX formats using PhpSpreadsheet.

README 文档

README

FtpDownloader - Simple FTP File Downloader

Total Downloads Latest Version Size License

PhpSpreadsheetLite - Lightweight Spreadsheet Utility

PhpSpreadsheetLite is a lightweight library designed to simplify creating and reading spreadsheets in CSV or XLSX formats using PhpSpreadsheet. It provides an intuitive API for quick and efficient spreadsheet operations.

Requirements

  • PHP 8.1 or higher
  • PhpSpreadsheet library (automatically installed via Composer)

Installation

Install the package via Composer. This will also install phpoffice/phpspreadsheet automatically:

composer require ceytek-labs/php-spreadsheet-lite

Usage

Here’s an example of how to use PhpSpreadsheetLite:

Creating and Saving a Spreadsheet

use CeytekLabs\PhpSpreadsheetLite\PhpSpreadsheetLite;
use CeytekLabs\PhpSpreadsheetLite\SpreadsheetFormat;

try {
    PhpSpreadsheetLite::make()
        ->setHeaders(['ID', 'Name', 'Email']) // Set the headers
        ->setContent([
            [1, 'John Doe', 'john.doe@example.com'],
            [2, 'Jane Smith', 'jane.smith@example.com'],
        ]) // Add your data
        ->setDirectory('/path/to/save') // Specify directory
        ->setFilename('example') // Specify file name
        ->setFileFormat(SpreadsheetFormat::XLSX) // Supported formats: XLSX, CSV
        ->createSpreadsheet();

    echo "Spreadsheet created successfully.";
} catch (\Exception $exception) {
    echo "Error: " . $exception->getMessage();
}

Reading a Spreadsheet

use CeytekLabs\PhpSpreadsheetLite\PhpSpreadsheetLite;
use CeytekLabs\PhpSpreadsheetLite\SpreadsheetFormat;

try {
    $data = PhpSpreadsheetLite::make()
        ->setDirectory('/path/to/spreadsheet') // Specify directory
        ->setFilename('example') // Specify file name
        ->setFileFormat(SpreadsheetFormat::XLSX) // Match the file format
        ->readSpreadsheet();

    print_r($data);
} catch (\Exception $exception) {
    echo "Error: " . $exception->getMessage();
}

Enum for File Formats

The SpreadsheetFormat enum helps you specify supported file formats consistently:

enum SpreadsheetFormat: string
{
    case XLSX = 'xlsx';
    case CSV = 'csv';
}

Contributing

Feel free to submit a pull request or report an issue. Any contributions and feedback are highly appreciated!

License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

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