feat: add videodb media index with Docker stack

- Add videodb PHP/MySQL media collection manager (Blu-ray, DVD, CD)
- Dockerfile: PHP 8.1 + Apache with GD/mysqli/exif extensions
- docker-compose.yml: app on port 6761 + MySQL 8.0 with health checks
- docker-entrypoint.sh: auto-generates config.inc.php from env vars,
  waits for MySQL, initializes DB schema idempotently
- init-db.php: CLI schema installer using app's own prefix_query() logic
- Persistent volumes for DB, cache, and cover images

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 09:49:52 +02:00
commit f55c91276e
1230 changed files with 252321 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- master
jobs:
tests:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
name: CI on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.composer-flags }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist --no-progress ${{ matrix.composer-flags }}
- name: Run tests
run: |
vendor/bin/phpunit
- name: Lint code
run: |
find Spreadsheet/ -type f -name \*.php | xargs -n1 php -l

View File

@@ -0,0 +1,38 @@
name: Coding Standards
on:
pull_request:
push:
branches:
- main
- master
jobs:
coding-standards:
name: Coding Standards
runs-on: ubuntu-latest
env:
PHP_CS_FIXER_VERSION: v2.17.3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: php-cs-fixer:${{ env.PHP_CS_FIXER_VERSION }}
- name: Restore PHP-CS-Fixer cache
uses: actions/cache@v2
with:
path: .php_cs.cache
key: "php-cs-fixer"
restore-keys: "php-cs-fixer"
- name: Run PHP-CS-Fixer, version ${{ env.PHP_CS_FIXER_VERSION }}
run: |
php-cs-fixer fix --diff --diff-format=udiff --dry-run --verbose

View File

@@ -0,0 +1,7 @@
# composer related
composer.lock
composer.phar
vendor
# build logs
build

View File

@@ -0,0 +1,11 @@
<?php
return PhpCsFixer\Config::create()
->setRules([
'native_function_invocation' => null,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
;

View File

@@ -0,0 +1,25 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
cache:
directories:
- $HOME/.composer/cache
- $HOME/.cache/cache
- build/cache
install:
- composer install --prefer-dist
- mkdir -p build/cache
script:
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- vendor/bin/php-cs-fixer --cache-file=build/cache/.php_cs.cache --diff --dry-run --stop-on-violation --verbose fix
after_success:
- travis_retry php vendor/bin/php-coveralls

View File

@@ -0,0 +1,166 @@
[![Build Status](https://travis-ci.org/pear/Spreadsheet_Excel_Writer.svg?branch=master)](https://travis-ci.org/pear/Spreadsheet_Excel_Writer)
[![Latest Stable Version](https://poser.pugx.org/pear/spreadsheet_excel_writer/v/stable)](https://packagist.org/packages/pear/spreadsheet_excel_writer)
[![Coverage Status](https://coveralls.io/repos/github/pear/Spreadsheet_Excel_Writer/badge.svg?branch=master)](https://coveralls.io/github/pear/Spreadsheet_Excel_Writer?branch=master)
# Spreadsheet_Excel_Writer
This package is [Spreadsheet_Excel_Writer](http://pear.php.net/package/Spreadsheet_Excel_Writer) and has been migrated from [svn.php.net](https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer).
Please report all new issues [via the PEAR bug tracker](http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Spreadsheet_Excel_Writer&order_by=ts1&direction=DESC&status=Open).
If this package is marked as unmaintained and you have fixes, please submit your pull requests and start discussion on the pear-qa mailing list.
# Installation
## Pear
To test, run
$ phpunit
To build, simply
$ pear package
To install from scratch
$ pear install package.xml
To upgrade
$ pear upgrade -f package.xml
## Composer
This package comes with support for Composer.
To install from Composer
$ composer require pear/spreadsheet_excel_writer
To install the latest development version
$ composer require pear/spreadsheet_excel_writer:dev-master
# Features
- writing Excel (.XLS) spreadsheets
- support: strings (with formatting for text and cells), formulas, images (BMP)
# Limitations
Library support only 2 types of format for writing XLS, also known as Binary Interchange File Format ([BIFF](https://www.openoffice.org/sc/excelfileformat.pdf)):
- BIFF5 (Excel 5.0 - Excel 95)
- BIFF8 (Excel 98 - Excel 2003)
**Some important limitations:**
| Limit | BIFF5 | BIFF8 |
| --- | --- | --- |
| Maximum number of rows | 16384 | 65535 |
| Maximum number of columns | 255 | 255 |
| Maximum data size of a record | 2080 bytes | 8224 bytes |
| Unicode support | CodePage based character encoding | UTF-16LE |
Explanation of formats and specifications you can find [here](https://www.loc.gov/preservation/digital/formats/fdd/fdd000510.shtml) (section "Useful references")
Correct output only guaranteed with `mbstring.func_overload = 0` otherwise, you should use workround `mb_internal_encoding('latin1');`
# Usage
## Basic usage
```php
use Spreadsheet_Excel_Writer;
$filePath = __DIR__ . '/output/out.xls';
$xls = new Spreadsheet_Excel_Writer($filePath);
// 8 = BIFF8
$xls->setVersion(8);
$sheet = $xls->addWorksheet('info');
// only available with BIFF8
$sheet->setInputEncoding('UTF-8');
$headers = [
'id',
'name',
'email',
'code',
'address'
];
$row = $col = 0;
foreach ($headers as $header) {
$sheet->write($row, $col, $header);
$col++;
}
for ($id = 1; $id < 100; $id++) {
$data = [
'id' => $id,
'name' => 'Name Surname',
'email' => 'mail@gmail.com',
'password' => 'cfcd208495d565ef66e7dff9f98764da',
'address' => '00000 North Tantau Avenue. Cupertino, CA 12345. (000) 1234567'
];
$sheet->writeRow($id, 0, $data);
}
$xls->close();
```
## Format usage
```php
$xls = new Spreadsheet_Excel_Writer();
$titleFormat = $xls->addFormat();
$titleFormat->setFontFamily('Helvetica');
$titleFormat->setBold();
$titleFormat->setSize(10);
$titleFormat->setColor('orange');
$titleFormat->setBorder(1);
$titleFormat->setBottom(2);
$titleFormat->setBottomColor(44);
$titleFormat->setAlign('center');
$sheet = $xls->addWorksheet('info');
$sheet->write(0, 0, 'Text 123', $titleFormat);
```
## Header usage (Sending HTTP header for download dialog)
```php
$xls = new Spreadsheet_Excel_Writer();
$xls->send('excel_'.date("Y-m-d__H:i:s").'.xls');
```
# Performance
**Platform:**
Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
PHP 7.4
**Test case:**
Write xls (BIFF8 format, UTF-8), by 5 cells (1x number, 4x string without format/styles, average line length = 120 char) in each row
**Estimated performance:**
| Number of rows | Time (seconds) | Peak memory usage (MB) |
| --- | --- | --- |
| 10000 | 0.2 | 4 |
| 20000 | 0.4 | 4 |
| 30000 | 0.6 | 6 |
| 40000 | 0.8 | 6 |
| 50000 | 1.0 | 8 |
| 65534 | 1.2 | 8 |
# Alternative solutions
- [PHPOffice/PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)
File formats supported: https://phpspreadsheet.readthedocs.io/en/latest/
- [box/spout](https://github.com/box/spout)
File formats supported: https://opensource.box.com/spout/

View File

@@ -0,0 +1,105 @@
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!class_exists('Spreadsheet_Excel_Writer_Workbook')) {
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
}
/**
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
{
/**
* The constructor. It just creates a Workbook
*
* @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/
public function __construct($filename = '')
{
$this->_filename = $filename;
parent::__construct($filename);
}
/**
* Send HTTP headers for the Excel file.
*
* @param string $filename The filename to use for HTTP headers
* @access public
*/
public function send($filename)
{
$filename = addslashes($filename);
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
/**
* Utility function for writing formulas
* Converts a cell's coordinates to the A1 format.
*
* @access public
* @static
* @param integer $row Row for the cell to convert (0-indexed).
* @param integer $col Column for the cell to convert (0-indexed).
* @return string The cell identifier in A1 format
*/
function rowcolToCell($row, $col)
{
if ($col > 255) { //maximum column value exceeded
return new PEAR_Error("Maximum column value exceeded: $col");
}
$int = (int)($col / 26);
$frac = $col % 26;
$chr1 = '';
if ($int > 0) {
$chr1 = chr(ord('A') + $int - 1);
}
$chr2 = chr(ord('A') + $frac);
$row++;
return $chr1 . $chr2 . $row;
}
}

View File

@@ -0,0 +1,268 @@
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@php.net>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!class_exists('PEAR')) {
require_once 'PEAR.php';
}
/**
* Class for writing Excel BIFF records.
*
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
*
* BIFF (BInary File Format) is the file format in which Excel documents are
* saved on disk. A BIFF file is a complete description of an Excel document.
* BIFF files consist of sequences of variable-length records. There are many
* different types of BIFF records. For example, one record type describes a
* formula entered into a cell; one describes the size and location of a
* window into a document; another describes a picture format.
*
* @author Xavier Noguer <xnoguer@php.net>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
{
/**
* The BIFF/Excel version (5).
* @var integer
*/
public $_BIFF_version = 0x0500;
/**
* The byte order of this architecture. 0 => little endian, 1 => big endian
* @var integer
*/
public $_byte_order;
/**
* The string containing the data of the BIFF stream
* @var string
*/
public $_data;
/**
* The size of the data in bytes. Should be the same as strlen($this->_data)
* @var integer
*/
public $_datasize;
/**
* The maximun length for a BIFF record. See _addContinue()
* @var integer
* @see _addContinue()
*/
public $_limit;
/**
* The temporary dir for storing the OLE file
* @var string
*/
public $_tmp_dir;
/**
* The temporary file for storing the OLE file
* @var string
*/
public $_tmp_file;
/**
* Constructor
*
* @access public
*/
public function __construct()
{
$this->_byte_order = '';
$this->_data = '';
$this->_datasize = 0;
$this->_limit = 2080;
$this->_tmp_dir = '';
// Set the byte order
$this->_setByteOrder();
}
/**
* Determine the byte order and store it as class data to avoid
* recalculating it for each call to new().
*
* @access private
*/
protected function _setByteOrder()
{
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)){
$byte_order = 1; // Big Endian
} else {
// Give up. I'll fix this in a later version.
return $this->raiseError("Required floating point format ".
"not supported on this platform.");
}
$this->_byte_order = $byte_order;
}
/**
* General storage public function
*
* @param string $data binary data to prepend
* @access private
*/
protected function _prepend($data)
{
if (strlen($data) > $this->_limit) {
$data = $this->_addContinue($data);
}
$this->_data = $data.$this->_data;
$this->_datasize += strlen($data);
}
/**
* General storage public function
*
* @param string $data binary data to append
* @access private
*/
protected function _append($data)
{
if (strlen($data) > $this->_limit) {
$data = $this->_addContinue($data);
}
$this->_data .= $data;
$this->_datasize += strlen($data);
}
/**
* Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file.
*
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
* 0x0010 Worksheet.
* @access private
*/
protected function _storeBof($type)
{
$record = 0x0809; // Record identifier
// According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use magic numbers.
if ($this->_BIFF_version == 0x0500) {
$length = 0x0008;
$unknown = '';
$build = 0x096C;
$year = 0x07C9;
} elseif ($this->_BIFF_version == 0x0600) {
$length = 0x0010;
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
$build = 0x0DBB;
$year = 0x07CC;
}
$version = $this->_BIFF_version;
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header . $data . $unknown);
}
/**
* Writes Excel EOF record to indicate the end of a BIFF stream.
*
* @access private
*/
protected function _storeEof()
{
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}
/**
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
* must be split up into CONTINUE blocks.
*
* This public function takes a long BIFF record and inserts CONTINUE records as
* necessary.
*
* @param string $data The original binary data to be written
* @return string A very convenient string of continue blocks
* @access private
*/
protected function _addContinue($data)
{
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
$header = pack("vv", $record, $limit); // Headers for continue records
// Retrieve chunks of 2080/8224 bytes +4 for the header.
$data_length = strlen($data);
for ($i = $limit; $i < ($data_length - $limit); $i += $limit) {
$tmp .= $header;
$tmp .= substr($data, $i, $limit);
}
// Retrieve the last chunk of data
$header = pack("vv", $record, strlen($data) - $i);
$tmp .= $header;
$tmp .= substr($data, $i, strlen($data) - $i);
return $tmp;
}
/**
* Sets the temp dir used for storing the OLE file
*
* @access public
* @param string $dir The dir to be used as temp dir
* @return true if given dir is valid, false otherwise
*/
public function setTempDir($dir)
{
if (is_dir($dir)) {
$this->_tmp_dir = $dir;
return true;
}
return false;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,228 @@
<?php
/*
* Module written by Herman Kuiper <herman@ozuzo.net>
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//require_once('PEAR.php');
// Possible operator types
/*
FIXME: change prefixes
*/
define("OP_BETWEEN", 0x00);
define("OP_NOTBETWEEN", 0x01);
define("OP_EQUAL", 0x02);
define("OP_NOTEQUAL", 0x03);
define("OP_GT", 0x04);
define("OP_LT", 0x05);
define("OP_GTE", 0x06);
define("OP_LTE", 0x07);
/**
* Baseclass for generating Excel DV records (validations)
*
* @author Herman Kuiper
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
class Spreadsheet_Excel_Writer_Validator
{
public $_type;
public $_style;
public $_fixedList;
public $_blank;
public $_incell;
public $_showprompt;
public $_showerror;
public $_title_prompt;
public $_descr_prompt;
public $_title_error;
public $_descr_error;
public $_operator;
public $_formula1;
public $_formula2;
/**
* The parser from the workbook. Used to parse validation formulas also
* @var Spreadsheet_Excel_Writer_Parser
*/
public $_parser;
public function __construct($parser)
{
$this->_parser = $parser;
$this->_type = 0x01; // FIXME: add method for setting datatype
$this->_style = 0x00;
$this->_fixedList = false;
$this->_blank = false;
$this->_incell = false;
$this->_showprompt = false;
$this->_showerror = true;
$this->_title_prompt = "\x00";
$this->_descr_prompt = "\x00";
$this->_title_error = "\x00";
$this->_descr_error = "\x00";
$this->_operator = 0x00; // default is equal
$this->_formula1 = '';
$this->_formula2 = '';
}
public function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
{
$this->_showprompt = $showPrompt;
$this->_title_prompt = $promptTitle;
$this->_descr_prompt = $promptDescription;
}
public function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
{
$this->_showerror = $showError;
$this->_title_error = $errorTitle;
$this->_descr_error = $errorDescription;
}
public function allowBlank()
{
$this->_blank = true;
}
public function onInvalidStop()
{
$this->_style = 0x00;
}
public function onInvalidWarn()
{
$this->_style = 0x01;
}
public function onInvalidInfo()
{
$this->_style = 0x02;
}
public function setFormula1($formula)
{
// Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula);
if (PEAR::isError($error)) {
return $this->_formula1;
}
$this->_formula1 = $this->_parser->toReversePolish();
if (PEAR::isError($this->_formula1)) {
return $this->_formula1;
}
return true;
}
public function setFormula2($formula)
{
// Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula);
if (PEAR::isError($error)) {
return $this->_formula2;
}
$this->_formula2 = $this->_parser->toReversePolish();
if (PEAR::isError($this->_formula2)) {
return $this->_formula2;
}
return true;
}
protected function _getOptions()
{
$options = $this->_type;
$options |= $this->_style << 3;
if ($this->_fixedList) {
$options |= 0x80;
}
if ($this->_blank) {
$options |= 0x100;
}
if (!$this->_incell) {
$options |= 0x200;
}
if ($this->_showprompt) {
$options |= 0x40000;
}
if ($this->_showerror) {
$options |= 0x80000;
}
$options |= $this->_operator << 20;
return $options;
}
protected function _getData()
{
$title_prompt_len = strlen($this->_title_prompt);
$descr_prompt_len = strlen($this->_descr_prompt);
$title_error_len = strlen($this->_title_error);
$descr_error_len = strlen($this->_descr_error);
$formula1_size = strlen($this->_formula1);
$formula2_size = strlen($this->_formula2);
$data = pack("V", $this->_getOptions());
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
return $data;
}
}
/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
{
public function Spreadsheet_Excel_Writer_Validation_list()
{
parent::Spreadsheet_Excel_Writer_Validation();
$this->_type = 0x03;
}
public function setList($source, $incell = true)
{
$this->_incell = $incell;
$this->_fixedList = true;
$source = implode("\x00", $source);
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
}
public function setRow($row, $col1, $col2, $incell = true)
{
$this->_incell = $incell;
//$this->_formula1 = ...;
}
public function setCol($col, $row1, $row2, $incell = true)
{
$this->_incell = $incell;
//$this->_formula1 = ...;
}
}*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
{
"name": "pear/spreadsheet_excel_writer",
"type": "library",
"description": "Allows writing of Excel spreadsheets without the need for COM objects. Supports formulas, images (BMP) and all kinds of formatting for text and cells.",
"license": "LGPL-2.1-or-later",
"authors": [
{
"name": "Carsten Schmitz",
"email": "cschmitz@limesurvey.org",
"role": "Lead"
},
{
"name": "Xavier Noguer",
"email": "xnoguer@php.net",
"role": "Lead"
},
{
"name": "Franck Lefevre",
"email": "progi1984@gmail.com",
"role": "Developer"
},
{
"name": "Mika Tuupola",
"email": "tuupola@appelsiini.net",
"role": "Developer"
},
{
"name": "Alexey Kopytko",
"email": "alexey@kopytko.com",
"role": "Lead"
}
],
"require": {
"php": ">=5.6",
"pear/ole": ">=1.0.0RC4",
"pear/pear-core-minimal": "^1.10"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2",
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": ">=5 <10",
"sanmai/phpunit-legacy-adapter": "^6 || ^8"
},
"autoload": {
"psr-0": {
"Spreadsheet": ""
}
},
"autoload-dev": {
"psr-0": {
"Test": "test"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"include-path": [
"./"
],
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Spreadsheet_Excel_Writer",
"source": "https://github.com/pear/Spreadsheet_Excel_Writer"
}
}

View File

@@ -0,0 +1,357 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Spreadsheet_Excel_Writer</name>
<channel>pear.php.net</channel>
<summary>Package for generating Excel spreadsheets</summary>
<description>Spreadsheet_Excel_Writer was born as a porting of the Spreadsheet::WriteExcel Perl module to PHP.
It allows writing of Excel spreadsheets without the need for COM objects.
It supports formulas, images (BMP) and all kinds of formatting for text and cells.
It currently supports the BIFF5 format (Excel 5.0), so functionality appeared in the latest Excel versions is not yet available.</description>
<lead>
<name>Carsten Schmitz</name>
<user>cschmitz</user>
<email>cschmitz@limesurvey.org</email>
<active>yes</active>
</lead>
<lead>
<name>Xavier Noguer</name>
<user>xnoguer</user>
<email>xnoguer@php.net</email>
<active>no</active>
</lead>
<lead>
<name>Alexey Kopytko</name>
<user>sanmai</user>
<email>alexey@kopytko.com</email>
<active>yes</active>
</lead>
<developer>
<name>Franck Lefevre</name>
<user>progi1984</user>
<email>progi1984@gmail.com</email>
<active>yes</active>
</developer>
<developer>
<name>Mika Tuupola</name>
<user>tuupola</user>
<email>tuupola@appelsiini.net</email>
<active>no</active>
</developer>
<date>2017-05-24</date>
<time>11:31:45</time>
<version>
<release>0.9.4</release>
<api>0.9.4</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
QA release. Comes with support for newer PHP versions. Fixed irritating "pass by reference" errors.
</notes>
<contents>
<dir name="/">
<dir name="Spreadsheet">
<dir name="Excel">
<dir name="Writer">
<file name="BIFFwriter.php" role="php" />
<file name="Format.php" role="php" />
<file name="Parser.php" role="php" />
<file name="Validator.php" role="php" />
<file name="Workbook.php" role="php" />
<file name="Worksheet.php" role="php" />
</dir>
<file name="Writer.php" role="php" />
</dir>
</dir>
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.3.3</min>
</php>
<pearinstaller>
<min>1.4.0b1</min>
</pearinstaller>
<package>
<name>OLE</name>
<channel>pear.php.net</channel>
<min>1.0.0RC2</min>
</package>
</required>
</dependencies>
<phprelease />
<changelog>
<release>
<version>
<release>0.9.3</release>
<api>0.9.3</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2012-01-26</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
QA release
Bug #18590 Impossible to work from IIS7
Bug #18024 deprecated line 180, 186 with php 5.3.2
Bug #16025 MERGEDCELLS record split by CONTINUE record
Bug #17766 Patch: Avoid deprecated split
Bug #17572 Temporary files are not removed
Bug #16938 open_basedir check is wrong in Spreadsheet_Excel_Writer_Worksheet::_initialize
Bug #14585 open_basedir workaround doesn&apos;t work
Bug #12362 named worksheets &amp; utf-8
Bug #14515 writeUrl only uses writeString, never writeNumber
Bug #14281 Using a row &gt; 16,384 reports error
Request #13486 Set the worksheet direction to right-to-left (RTL)
Bug #12720 Notice thrown when using setColumn (undefined colFirst and colLast)
Bug #12053 With SetVersion(8) setting bottom border color to 0 gives cross borders (!)
</notes>
</release>
<release>
<version>
<release>0.2</release>
<api>0.2</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2003-03-17</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
-added several formatting methods: setTextRotation(), setStrikeOut(),
setOutLine(), setShadow(), setScript().
-fixed bug in Workbook::sheets() (Bjoern Schotte).
-fixed range for references in formulas (Edward).
-added support for external references in formulas.
-added support for comparisons in formulas.
-added support for strings in formulas.
</notes>
</release>
<release>
<version>
<release>0.3</release>
<api>0.3</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-05-02</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
-added support for row ranges (JT Hughes)
-added method method Format::setUnLocked() (Ajit Dixit)
-added Worksheet::writeRow() and Worksheet::writeCol()
Bug fixes:
-fixed problem with unparenthesized expresions in formulas (Brent Laminack)
-fixed problems with non ISO-8859-1 characters (KUBO Atsuhiro)
-fixed swapping of columns in formulas (JT Hughes)
-fixed assorted bugs in tokenizing formulas (JT Hughes)
-fixed Worksheet::activate() (JT Hughes)
</notes>
</release>
<release>
<version>
<release>0.4</release>
<api>0.4</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-08-21</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
-using OLE package (&gt;= 0.3) to generate files bigger than 7MB
-changed setFgColor() and setBgColor()&apos;s behavior to something more intuitive.
Bug fixes:
-fixed bug #25133, lowercase cell references (jkwiat03 at hotmail dot com)
-fixed Bug #23730, worksheet names containing spaces in formulas (Robin Ericsson)
-fixed Bug #24147, formulas ended in &apos;0&apos; (paul at classical dot com)
-fixed swapping of arguments in variable arguments functions (JT Hughes)
</notes>
</release>
<release>
<version>
<release>0.5</release>
<api>0.5</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-10-01</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
-added rowcolToCell() utility method for easy writing of formula&apos;s cell references (JT Hughes).
-added Worksheet::setOutline() method (Herman Kuiper)
-added Format::setFontFamily() method (Donnie Miller)
Bug fixes:
-fixed bug #21, cyrillic characters in sheet references (arhip at goldentele dot com)
</notes>
</release>
<release>
<version>
<release>0.6</release>
<api>0.6</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-11-15</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
- allow semicolon as argument separator (Axel Pratzner)
- added experimental Excel97 generation. You can test it with setVersion():
Beware! this method will be deprecated in a future release (when
Excel97 becomes the default). It is only available for testing
purposes. Use it at your own risk.
- strings longer than 255 bytes are now available using the experimental
Excel97 generation. But not all Excel97 features are available yet!
Bug fixes:
- Fixed bug #225, error in writeUrl() (jamesn at tocquigny dot com)
- Fixed bug #59, retval undefined for writeRow() (Bertrand)
</notes>
</release>
<release>
<version>
<release>0.7</release>
<api>0.7</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2004-02-27</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
- allow setting temp dir other than default using setTempDir() (using OLE 5.0 for this).
- added setMerge() for merging (only for experimental Excel97 generation)
- added setCountry() method.
- added setLocked() method.
Bug fixes:
- Fixed bug #415, typo in BIFF8 code (papercrane at reversefold dot com)
</notes>
</release>
<release>
<version>
<release>0.8</release>
<api>0.8</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2004-06-22</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
- added hideScreenGridlines() (Paul Osman)
Bug fixes:
- Fixed SST table (long strings) (Bernd Jaenichen)
- Fixed bug #1218, SST table (boucher dot stephane at free dot fr)
- Fixed bug #781, insertBitmap ignores row height
- Fixed bug #578, setVPageBreaks doesn&apos;t handle multiple value arrays (natel at tocquigny dot com)
</notes>
</release>
<release>
<version>
<release>0.9.0</release>
<api>0.9.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2005-11-21</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
New features:
- adding new methods Format::setVAlign() and Format::setHAlign()
- adding support for uncapitalized functions in formulas (ej: &quot;=sum(B27:B31)&quot;)
- adding support for different charsets with method Worksheet::setInputEncoding()
- adding support for sheetnames longer than 31 chars when using setVersion(8).
Bug fixes:
- Fixed Bug #1796, wrong regular expression in _writeUrlInternal
- Fixed Bug #2363, wrong export filename with spaces
- Fixed Bug #2425, Error using writeFormula with Now() and TODAY()
- Fixed Bug #2876, German Umlauts destroy sheet references
- Fixed Bug #1706, Formulas refer to other Worksheets with &quot;spezial&quot; names don&apos;t work
- Fixed Bug #2748, setMargins(), setHeader() and setFooter() work in excel but not in openoffice.
- Fixed Bug #5698, preg_replace in _writeUrlInternal
- Fixed Bug #2823, Inpropper results from writeUrl() method
</notes>
</release>
<release>
<version>
<release>0.9.1</release>
<api>0.9.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2006-09-26</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
</notes>
</release>
<release>
<version>
<release>0.9.2</release>
<api>0.9.2</api>
</version>
<stability>
<release>beta</release>
<api>stable</api>
</stability>
<date>2009-11-28</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
</notes>
</release>
<release>
<version>
<release>0.9.3</release>
<api>0.9.3</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2012-01-26</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
QA release
Bug #18590 Impossible to work from IIS7
Bug #18024 deprecated line 180, 186 with php 5.3.2
Bug #16025 MERGEDCELLS record split by CONTINUE record
Bug #17766 Patch: Avoid deprecated split
Bug #17572 Temporary files are not removed
Bug #16938 open_basedir check is wrong in Spreadsheet_Excel_Writer_Worksheet::_initialize
Bug #14585 open_basedir workaround doesn&apos;t work
Bug #12362 named worksheets &amp; utf-8
Bug #14515 writeUrl only uses writeString, never writeNumber
Bug #14281 Using a row &gt; 16,384 reports error
Request #13486 Set the worksheet direction to right-to-left (RTL)
Bug #12720 Notice thrown when using setColumn (undefined colFirst and colLast)
Bug #12053 With SetVersion(8) setting bottom border color to 0 gives cross borders (!)
</notes>
</release>
</changelog>
</package>

View File

@@ -0,0 +1,28 @@
<phpunit bootstrap="vendor/autoload.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false">
<testsuites>
<testsuite name="Test Suite">
<directory>test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">Spreadsheet/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-text" target="php://stdout"/>
</logging>
</phpunit>

View File

@@ -0,0 +1,81 @@
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2016-01-17
*/
class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_WriterTestCase
{
public static function doSetUpBeforeClass()
{
// Preload constants from OLE
@class_exists(OLE::class);
}
public function testSetVersion()
{
$workbook = $this->getNewWorkbook();
$before = get_object_vars($workbook);
$workbook->setVersion(1);
$this->assertEquals($before, get_object_vars($workbook), "Version 1 should not change internal state");
$workbook->setVersion(8);
$this->assertNotEquals($before, get_object_vars($workbook), "Version 8 should change internal state");
return $workbook;
}
/**
* @depends testSetVersion
*/
public function testWriteSingleCell(Spreadsheet_Excel_Writer $workbook)
{
$sheet = $workbook->addWorksheet("Example");
$sheet->write(0, 0, "Example");
$this->assertSameAsInFixture('example.xls', $workbook);
}
public function testWriteWithFormat()
{
$workbook = $this->getNewWorkbook();
$workbook->setVersion(8);
$format = $workbook->addFormat();
$format->setFontFamily('Helvetica');
$format->setSize(16);
$format->setVAlign('vcenter');
$format->setBorder(1);
$sheet = $workbook->addWorksheet('Example report');
$sheet->setInputEncoding('utf-8');
$sheet->setColumn(0, 10, 35);
$sheet->writeString(0, 0, "Test string", $format);
$sheet->setRow(0, 40);
$sheet->writeString(1, 0, "こんにちわ");
$this->assertSameAsInFixture('with_format.xls', $workbook);
}
public function testWithDefaultVersion()
{
$workbook = $this->getNewWorkbook();
$sheet = $workbook->addWorksheet("Example");
for ($i = 0; $i < 10; $i++) {
for ($j = 0; $j < 10; $j++) {
$sheet->write($i, $j, "Row $i $j");
}
}
$this->assertSameAsInFixture('example2.xls', $workbook);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2016-01-17
*/
class Test_Spreadsheet_Excel_WriterTestCase extends \LegacyPHPUnit\TestCase
{
const FIXTURES_PATH = 'test/fixture/';
/**
* @param string $filename
* @return Spreadsheet_Excel_Writer
*/
protected function getNewWorkbook($filename = '')
{
// we're writing to the standard output by defaulr
return new Spreadsheet_Excel_Writer($filename);
}
protected function assertSameAsInFixture($filename, Spreadsheet_Excel_Writer $workbook)
{
$this->assertEmpty($workbook->_filename, "Testing with fixtures works only for standard output");
// we have to fix timestamp for fixtures to work
$workbook->_timestamp = 1000000000; // somewhere in 2001
ob_start();
$workbook->close();
$data = ob_get_clean();
$fullPath = self::FIXTURES_PATH.$filename;
if ($this->shouldUpdateFixtures()) {
file_put_contents($fullPath, $data);
}
if (!is_file($fullPath)) {
$this->fail("Fixture $filename not found");
}
// TODO: should we save data for future analysis?
//file_put_contents("{$fullPath}.work", $data);
$this->assertEquals(file_get_contents($fullPath), $data, "Output differs for $filename");
}
/**
* We should update golden files
*/
private function shouldUpdateFixtures()
{
return isset($_SERVER['GOLDEN']);
}
}