Commit cffc1c34 authored by hujun's avatar hujun

php excel

parent cc873269
/tests export-ignore
README.md export-ignore
*.min.js binary
This is:
```
- [ ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
```
### What is the expected behavior?
### What is the current behavior?
### What are the steps to reproduce?
Please provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of code that exhibits the issue without relying on an external Excel file or a web server:
```php
<?php
require __DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
// add code that show the issue here...
```
### Which versions of PhpSpreadsheet and PHP are affected?
This is:
```
- [ ] a bugfix
- [ ] a new feature
```
Checklist:
- [ ] Changes are covered by unit tests
- [ ] Code style is respected
- [ ] Commit message explains **why** the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
- [ ] CHANGELOG.md contains a short summary of the change
- [ ] Documentation is updated as necessary
### Why this change is needed?
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it
further and sharing your results.
Thank you for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
# Label used to mark issues as support requests
supportLabel: question
# Comment to post on issues marked as support requests. Add a link
# to a support page, or set to `false` to disable
supportComment: >
This looks like a support question. Please ask your support questions on
[StackOverflow](https://stackoverflow.com/questions/tagged/phpspreadsheet),
or [Gitter](https://gitter.im/PHPOffice/PhpSpreadsheet).
Thank you for your contributions.
# Whether to close issues marked as support requests
close: true
# Whether to lock issues marked as support requests
lock: false
/tests/codeCoverage
/analysis
/vendor/
/phpunit.xml
## IDE support
*.buildpath
*.project
/.settings
/.idea
<?php
$finder = PhpCsFixer\Finder::create()
->exclude(['vendor', 'tests/data/Calculation'])
->in('samples')
->in('src')
->in('tests/PhpSpreadsheetTests')
;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
->setRules([
'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const
'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true,
'doctrine_annotation_array_assignment' => true,
'doctrine_annotation_braces' => true,
'doctrine_annotation_indentation' => true,
'doctrine_annotation_spaces' => true,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
'final_internal_class' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => false, // No use for that
'hash_to_slash_comment' => true,
'header_comment' => false, // We don't use common header in all our files
'heredoc_to_nowdoc' => false, // Not sure about this one
'include' => true,
'increment_style' => true,
'indentation_type' => true,
'is_null' => ['use_yoda_style' => false],
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'long'], // Stay compatiblew with PHP 5.6
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'magic_constant_casing' => true,
'mb_str_functions' => false, // No, too dangerous to change that
'method_argument_space' => true,
'method_chaining_indentation' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'native_function_casing' => true,
'native_function_invocation' => false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'non_printable_character' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'normalize_index_brace' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => false, // Might be risky on a huge code base
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
'not_operator_with_successor_space' => false, // idem
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types_order' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_mock' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_strict' => false, // We sometime actually need assertEquals
'php_unit_test_annotation' => true,
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
'pow_to_exponentiation' => false,
'protected_to_private' => true,
'psr0' => true,
'psr4' => true,
'random_api_migration' => false, // This breaks our unit tests
'return_type_declaration' => true,
'self_accessor' => true,
'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
'short_scalar_cast' => true,
'silenced_deprecation_error' => true,
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => false, // No, too dangerous to change that
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'void_return' => false, // Cannot use that with PHP 5.6
'whitespace_after_comma_in_array' => true,
'yoda_style' => false,
]);
<?php
use Sami\RemoteRepository\GitHubRemoteRepository;
use Sami\Sami;
use Sami\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;
$iterator = Finder::create()
->files()
->name('*.php')
->in($dir = __DIR__ . '/src');
$versions = GitVersionCollection::create($dir)
->addFromTags(function ($version) {
return preg_match('~^\d+\.\d+\.\d+$~', $version);
})
->add('master');
return new Sami($iterator, [
'title' => 'PhpSpreadsheet',
'versions' => $versions,
'build_dir' => __DIR__ . '/build/%version%',
'cache_dir' => __DIR__ . '/cache/%version%',
'remote_repository' => new GitHubRemoteRepository('PHPOffice/PhpSpreadsheet', dirname($dir)),
]);
checks:
php: true
coding_style:
php:
spaces:
before_parentheses:
closure_definition: true
around_operators:
concatenation: true
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
tools:
external_code_coverage:
timeout: 3600
build_failure_conditions:
- 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection
- 'patches.label("Unused Use Statements").new.exists' # No new unused imports patches allowed
language: php
dist: trusty
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
matrix:
fast_finish: true
allow_failures:
- php: 5.6
cache:
directories:
- cache
- vendor
- $HOME/.composer/cache
before_script:
# Deactivate xdebug
- if [ -z "$KEEP_XDEBUG" ]; then rm -rfv /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ; fi
- composer install --ignore-platform-reqs
script:
- ./vendor/bin/phpunit
jobs:
include:
- stage: Code style
php: 7.2
script:
- ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
- ./vendor/bin/phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n
- stage: Coverage
php: 7.2
env: KEEP_XDEBUG=1
script:
- travis_wait 40 ./vendor/bin/phpunit --debug --coverage-clover coverage-clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml
- stage: API documentation
php: 7.2
before_script:
- curl -O https://get.sensiolabs.org/sami.phar
script:
- git fetch origin master:master
- git fetch origin --tags
- php sami.phar update .sami.php
- echo '<html><head><meta http-equiv="Refresh" content="0; url=master/"></head><body><p>If you are not automatically redirected, please go to <a href="master/">the latest stable API documentation</a>.</p></body></html>' > build/index.html
deploy:
provider: pages
skip-cleanup: true
local-dir: build
github-token: $GITHUB_TOKEN
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^master$
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
# Want to contribute?
If you would like to contribute, here are some notes and guidelines:
- All new development happens on feature/fix branches, and are then merged to the `master` branch once stable; so the `master` branch is always the most up-to-date, working code
- Tagged releases are made from the `master` branch
- If you are going to be submitting a pull request, please fork from `master`, and submit your pull request back as a fix/feature branch referencing the GitHub issue number
- Code style might be automatically fixed by `composer fix`
- All code changes must be validated by `composer check`
- [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository")
- [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests")
This diff is collapsed.
#!/usr/bin/env php
<?php
use PhpOffice\PhpSpreadsheet\Helper\Migrator;
require_once __DIR__ . '/../src/Bootstrap.php';
$migrator = new Migrator();
$migrator->migrate();
#!/bin/bash
pass=true
files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(php|phtml)$')
if [ "$files" != "" ]; then
# Run php syntax check before commit
while read -r file; do
php -l "$file"
if [ $? -ne 0 ]; then
pass=false
fi
done <<< "$files"
# Run php-cs-fixer validation before commit
echo "$files" | xargs ./vendor/bin/php-cs-fixer fix --diff --config .php_cs.dist
if [ $? -ne 0 ]; then
pass=false
fi
# Automatically add files that may have been fixed by php-cs-fixer
echo "$files" | xargs git add
fi
if $pass; then
exit 0
else
echo ""
echo "PRE-COMMIT HOOK FAILED:"
echo "Code style validation failed. Please fix errors and try committing again."
exit 1
fi
{
"name": "phpoffice/phpspreadsheet",
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"keywords": ["PHP", "OpenXML", "Excel", "xlsx", "xls", "ods", "gnumeric", "spreadsheet"],
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"type": "library",
"license": "LGPL-2.1-or-later",
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"scripts": {
"check": [
"php-cs-fixer fix --ansi --dry-run --diff",
"phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n",
"phpunit --color=always"
],
"fix": [
"php-cs-fixer fix --ansi"
],
"versions": [
"phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 5.6- -n"
]
},
"require": {
"php": "^5.6|^7.0",
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-fileinfo": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-SimpleXML": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"psr/simple-cache": "^1.0",
"markbaker/complex": "^1.4",
"markbaker/matrix": "^1.1"
},
"require-dev": {
"tecnickcom/tcpdf": "^6.2",
"phpunit/phpunit": "^5.7",
"doctrine/instantiator": "^1.0.0",
"dompdf/dompdf": "^0.8.0",
"mpdf/mpdf": "^7.0.0",
"jpgraph/jpgraph": "^4.0",
"friendsofphp/php-cs-fixer": "@stable",
"phpcompatibility/php-compatibility": "^8.0",
"squizlabs/php_codesniffer": "^3.3"
},
"suggest": {
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers"
},
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"autoload-dev": {
"psr-4": {
"PhpOffice\\PhpSpreadsheetTests\\": "tests/PhpSpreadsheetTests"
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Font Name="Tahoma" Size="8.25" />
<Class Name="ClassDiagrams.PHPExcel" Collapsed="true">
<Position X="3.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<FileName>Classes\PHPExcel.cs</FileName>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAA=</HashCode>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Worksheets" />
</ShowAsAssociation>
</Class>
<Class Name="ClassDiagrams.Worksheet" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<FileName>Classes\Worksheet.cs</FileName>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
</TypeIdentifier>
</Class>
<Interface Name="ClassDiagrams.PHPExcel_Reader_IReader" Collapsed="true">
<Position X="2.25" Y="2.5" Width="2" />
<TypeIdentifier>
<FileName>Classes\IReader.cs</FileName>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="reads" />
</ShowAsAssociation>
<AssociationLine Name="reads" Type="ClassDiagrams.PHPExcel">
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
<Position X="0.152" Y="1.279" Height="0.16" Width="0.597" />
</MemberNameLabel>
</AssociationLine>
</Interface>
<Interface Name="ClassDiagrams.PHPExcel_Writer_IWriter" Collapsed="true">
<Position X="4.5" Y="2.5" Width="2" />
<TypeIdentifier>
<FileName>Classes\IWriter.cs</FileName>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="writes" />
</ShowAsAssociation>
<AssociationLine Name="writes" Type="ClassDiagrams.PHPExcel">
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
<Position X="-1.002" Y="1.298" Height="0.16" Width="0.764" />
</MemberNameLabel>
</AssociationLine>
</Interface>
</ClassDiagram>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassDiagrams</RootNamespace>
<AssemblyName>ClassDiagrams</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<None Include="Architecture.cd" />
<None Include="ReaderWriter.cd" />
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\IReader.cs" />
<Compile Include="Classes\IWriter.cs" />
<Compile Include="Classes\PHPExcel_IOFactory.cs" />
<Compile Include="Classes\Worksheet.cs" />
<Compile Include="Classes\PHPExcel.cs" />
<Compile Include="Classes\PHPExcel_Reader_Excel2007.cs" />
<Compile Include="Classes\PHPExcel_Reader_Serialized.cs" />
<Compile Include="Classes\PHPExcel_Writer_Excel2007.cs" />
<Compile Include="Classes\PHPExcel_Writer_Serialized.cs" />
<Compile Include="Classes\PHPExcel_Reader_Excel5.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Exports\Architecture.png" />
<Content Include="Exports\ReaderWriter.png" />
</ItemGroup>
</Project>
\ No newline at end of file
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagrams", "ClassDiagrams.csproj", "{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC8CD7D2-8EFF-48E5-A17A-C1C482744D31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public interface PHPExcel_Reader_IReader
{
PHPExcel reads
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public interface PHPExcel_Writer_IWriter
{
PHPExcel writes
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel
{
/// <remarks></remarks>
public Worksheet Worksheets
{
get
{
throw new System.NotImplementedException();
}
set
{
}
}
}
public class PHPExcel_Writer_PDF : PHPExcel_Writer_IWriter
{
#region PHPExcel_Writer_IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_IOFactory
{
public PHPExcel_Reader_IReader createsReader
{
get
{
throw new System.NotImplementedException();
}
set
{
}
}
public PHPExcel_Writer_IWriter createsWriter
{
get
{
throw new System.NotImplementedException();
}
set
{
}
}
public PHPExcel_Writer_IWriter createWriter()
{
throw new System.NotImplementedException();
}
public PHPExcel_Reader_IReader createReader()
{
throw new System.NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_Reader_Excel2007 : PHPExcel_Reader_IReader
{
#region IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_Reader_Excel5 : PHPExcel_Reader_IReader
{
#region PHPExcel_Writer_IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Reader_Excel2003XML : PHPExcel_Reader_IReader
{
#region PHPExcel_Writer_IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Reader_SYLK : PHPExcel_Reader_IReader
{
#region PHPExcel_Writer_IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_Reader_Serialized : PHPExcel_Reader_IReader
{
#region IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Reader_CSV : PHPExcel_Reader_IReader
{
#region IReader Members
public PHPExcel reads
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_Writer_Excel2007 : PHPExcel_Writer_IWriter
{
#region IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class PHPExcel_Writer_Serialized : PHPExcel_Writer_IWriter
{
#region IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Writer_CSV : PHPExcel_Writer_IWriter
{
#region IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Writer_Excel5 : PHPExcel_Writer_IWriter
{
#region IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
public class PHPExcel_Writer_HTML : PHPExcel_Writer_IWriter
{
#region IWriter Members
public PHPExcel writes
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassDiagrams
{
public class Worksheet
{
}
public class CopyOfWorksheet
{
}
}
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="ClassDiagrams.PHPExcel_Reader_Excel2007" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="0.5" Y="3.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Excel2007.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_Excel2007" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="3.5" Y="3.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Writer_Excel2007.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Reader_Serialized" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="0.5" Y="4.25" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_Serialized" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="3.5" Y="4.25" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Writer_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Reader_CSV" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="0.5" Y="5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_CSV" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="3.5" Y="5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Writer_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_Excel5" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="3.5" Y="5.75" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Writer_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_HTML" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="3.5" Y="6.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Writer_Serialized.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Reader_Excel5" Collapsed="true">
<Position X="0.5" Y="5.75" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Excel5.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Writer_PDF" Collapsed="true">
<Position X="3.5" Y="7.25" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_IOFactory">
<Position X="2" Y="0.5" Width="2.25" />
<AssociationLine Name="createsReader" Type="ClassDiagrams.PHPExcel_Reader_IReader">
<MemberNameLabel ManuallyPlaced="true">
<Position X="0.11" Y="0.06" />
</MemberNameLabel>
</AssociationLine>
<AssociationLine Name="createsWriter" Type="ClassDiagrams.PHPExcel_Writer_IWriter">
<MemberNameLabel ManuallyPlaced="true">
<Position X="-1.088" Y="0.081" />
</MemberNameLabel>
</AssociationLine>
<TypeIdentifier>
<HashCode>AIAAAAAAAAEAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_IOFactory.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="createsReader" />
<Property Name="createsWriter" />
</ShowAsAssociation>
</Class>
<Class Name="ClassDiagrams.PHPExcel_Reader_Excel2003XML" Collapsed="true">
<Position X="0.5" Y="6.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Excel5.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="ClassDiagrams.PHPExcel_Reader_SYLK" Collapsed="true">
<Position X="0.5" Y="7.25" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\PHPExcel_Reader_Excel5.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Interface Name="ClassDiagrams.PHPExcel_Writer_IWriter" Collapsed="true">
<Position X="3.5" Y="2.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAA=</HashCode>
<FileName>Classes\IWriter.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="ClassDiagrams.PHPExcel_Reader_IReader" Collapsed="true">
<Position X="0.5" Y="2.5" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Classes\IReader.cs</FileName>
</TypeIdentifier>
</Interface>
<Font Name="Tahoma" Size="8.25" />
</ClassDiagram>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/* Make the huge table always visible */
table.features-cross-reference {
overflow: visible !important;
}
.rst-content table.features-cross-reference.docutils th,
.rst-content table.features-cross-reference.docutils td {
background-color: white;
}
# Frequently asked questions
## There seems to be a problem with character encoding...
It is necessary to use UTF-8 encoding for all texts in PhpSpreadsheet.
If the script uses different encoding then you can convert those texts
with PHP's `iconv()` or `mb_convert_encoding()` functions.
## Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa
PhpSpreadsheet holds an "in memory" representation of a spreadsheet, so
it is susceptible to PHP's memory limitations. The memory made available
to PHP can be increased by editing the value of the `memory_limit`
directive in your `php.ini` file, or by using
`ini_set('memory_limit', '128M')` within your code.
Some Readers and Writers are faster than others, and they also use
differing amounts of memory.
## Protection on my worksheet is not working?
When you make use of any of the worksheet protection features (e.g. cell
range protection, prohibiting deleting rows, ...), make sure you enable
worksheet security. This can for example be done like this:
``` php
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
```
## Feature X is not working with Reader\_Y / Writer\_Z
Not all features of PhpSpreadsheet are implemented in all of the Reader
/ Writer classes. This is mostly due to underlying libraries not
supporting a specific feature or not having implemented a specific
feature.
For example autofilter is not implemented in PEAR
Spreadsheet\_Excel\_writer, which is the base of our Xls writer.
We are slowly building up a list of features, together with the
different readers and writers that support them, in the [features cross
reference](./references/features-cross-reference.md).
## Formulas don't seem to be calculated in Excel2003 using compatibility pack?
This is normal behaviour of the compatibility pack, `Xlsx` displays this
correctly. Use `\PhpOffice\PhpSpreadsheet\Writer\Xls` if you really need
calculated values, or force recalculation in Excel2003.
## Setting column width is not 100% accurate
Trying to set column width, I experience one problem. When I open the
file in Excel, the actual width is 0.71 less than it should be.
The short answer is that PhpSpreadsheet uses a measure where padding is
included. See [how to set a column's width](./topics/recipes.md#setting-a-columns-width)
for more details.
# Welcome to PhpSpreadsheet's documentation
![Logo](./assets/logo.svg)
PhpSpreadsheet is a library written in pure PHP and providing a set of
classes that allow you to read from and to write to different
spreadsheet file formats, like Excel and LibreOffice Calc.
## File formats supported
|Format |Reading|Writing|
|--------------------------------------------|:-----:|:-----:|
|Open Document Format/OASIS (.ods) | ✓ | ✓ |
|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ |
|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ |
|BIFF 5 (.xls) Excel 95 | ✓ | |
|SpreadsheetML (.xml) Excel 2003 | ✓ | |
|Gnumeric | ✓ | |
|HTML | ✓ | ✓ |
|SYLK | ✓ | |
|CSV | ✓ | ✓ |
|PDF (using either the TCPDF, Dompdf or mPDF libraries, which need to be installed separately)| | ✓ |
# Getting started
## Software requirements
The following software is required to develop using PhpSpreadsheet:
- PHP version 5.6 or newer
- PHP extension php\_zip enabled
- PHP extension php\_xml enabled
- PHP extension php\_gd2 enabled (if not compiled in)
### PHP version support
Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version
## Installation
Use [composer](https://getcomposer.org) to install PhpSpreadsheet into your project:
```sh
composer require phpoffice/phpspreadsheet
```
## Hello World
This would be the simplest way to write a spreadsheet:
```php
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
```
## Learn by example
A good way to get started is to run some of the samples. Serve the samples via
PHP built-in webserver:
```sh
php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples
```
Then point your browser to:
> http://localhost:8000/
The samples may also be run directly from the command line, for example:
```sh
php vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple.php
```
## Learn by documentation
For more in-depth documentation, you may read about an [overview of the
architecture](./topics/architecture.md),
[creating a spreadsheet](./topics/creating-spreadsheet.md),
[worksheets](./topics/worksheets.md),
[accessing cells](./topics/accessing-cells.md) and
[reading and writing to files](./topics/reading-and-writing-to-file.md).
Or browse the [API documentation](https://phpoffice.github.io/PhpSpreadsheet/master).
# Credits
Please refer to the [contributor
list](https://github.com/PHPOffice/PhpSpreadsheet/graphs/contributors)
for up-to-date credits.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment