logo
0
0
WeChat Login

PhpSpreadsheet v2.1 — Quick Start

This repository includes a Composer project set to use phpoffice/phpspreadsheet:^2.1. It provides the core library under vendor/ and a minimal setup to start generating Excel files in PHP.

Requirements

  • PHP 8.0+ recommended

Download

Use this repository directly without Composer:

  • Clone:
    git clone https://github.com/ramyibrahim-eg/phpspreadsheet-v2.1.git
    cd phpspreadsheet-v2.1
    
  • Or download the ZIP from GitHub and extract it.

Setup

  • The vendor/ directory is included. Simply include the autoloader in your script:
    require __DIR__ . '/vendor/autoload.php';
    

Minimal Usage Example

Create a file like export.php and run it with PHP:

<?php
require __DIR__ . '/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World!');
$sheet->setCellValue('B1', date('Y-m-d'));

$writer = new Xlsx($spreadsheet);
$writer->save(__DIR__ . '/hello_world.xlsx');

echo "File saved: hello_world.xlsx\n";

Run:

php export.php

Loading an Existing File (Optional)

use PhpOffice\PhpSpreadsheet\IOFactory;
$spreadsheet = IOFactory::load('hello_world.xlsx');
$sheet = $spreadsheet->getActiveSheet();
$val = $sheet->getCell('A1')->getValue();

Notes

  • This repository may include vendor/ for convenience. For production projects, consider excluding vendor/ and relying on Composer to install dependencies.
  • Consult the official documentation for advanced usage: https://phpspreadsheet.readthedocs.io/

About

No description, topics, or website provided.