Upgrade to latest PHP_CodeSniffer

This commit is contained in:
Adrien Crivelli 2018-08-06 11:02:16 +09:00
parent c04b92198e
commit b0004cdabf
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
25 changed files with 484 additions and 511 deletions

View File

@ -29,7 +29,7 @@ jobs:
php: 7.1 php: 7.1
script: script:
- ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run - ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n - ./vendor/bin/phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n
- stage: Coverage - stage: Coverage
php: 7.1 php: 7.1

View File

@ -25,7 +25,7 @@
"scripts": { "scripts": {
"check": [ "check": [
"php-cs-fixer fix --ansi --dry-run --diff", "php-cs-fixer fix --ansi --dry-run --diff",
"phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n", "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n",
"phpunit --color=always" "phpunit --color=always"
], ],
"fix": [ "fix": [
@ -51,12 +51,12 @@
}, },
"require-dev": { "require-dev": {
"tecnickcom/tcpdf": "^6.2", "tecnickcom/tcpdf": "^6.2",
"squizlabs/php_codesniffer": "^2.7",
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"dompdf/dompdf": "^0.8.0", "dompdf/dompdf": "^0.8.0",
"mpdf/mpdf": "^7.0.0", "mpdf/mpdf": "^7.0.0",
"jpgraph/jpgraph": "^4.0", "jpgraph/jpgraph": "^4.0",
"friendsofphp/php-cs-fixer": "@stable" "friendsofphp/php-cs-fixer": "@stable",
"squizlabs/php_codesniffer": "^3.3"
}, },
"suggest": { "suggest": {
"mpdf/mpdf": "Option for rendering PDF with PDF Writer", "mpdf/mpdf": "Option for rendering PDF with PDF Writer",

51
composer.lock generated
View File

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "1aba55e3ac36d8d5015f9b3193f93c23", "content-hash": "66067b3ab7afd673a28cf0b31eb9ae20",
"packages": [ "packages": [
{ {
"name": "markbaker/complex", "name": "markbaker/complex",
@ -2201,64 +2201,37 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "2.8.1", "version": "3.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" "reference": "628a481780561150481a9ec74709092b9759b3ec"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/628a481780561150481a9ec74709092b9759b3ec",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "reference": "628a481780561150481a9ec74709092b9759b3ec",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-simplexml": "*", "ext-simplexml": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"php": ">=5.1.2" "php": ">=5.4.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0" "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
}, },
"bin": [ "bin": [
"scripts/phpcs", "bin/phpcs",
"scripts/phpcbf" "bin/phpcbf"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.x-dev" "dev-master": "3.x-dev"
} }
}, },
"autoload": {
"classmap": [
"CodeSniffer.php",
"CodeSniffer/CLI.php",
"CodeSniffer/Exception.php",
"CodeSniffer/File.php",
"CodeSniffer/Fixer.php",
"CodeSniffer/Report.php",
"CodeSniffer/Reporting.php",
"CodeSniffer/Sniff.php",
"CodeSniffer/Tokens.php",
"CodeSniffer/Reports/",
"CodeSniffer/Tokenizers/",
"CodeSniffer/DocGenerators/",
"CodeSniffer/Standards/AbstractPatternSniff.php",
"CodeSniffer/Standards/AbstractScopeSniff.php",
"CodeSniffer/Standards/AbstractVariableSniff.php",
"CodeSniffer/Standards/IncorrectPatternException.php",
"CodeSniffer/Standards/Generic/Sniffs/",
"CodeSniffer/Standards/MySource/Sniffs/",
"CodeSniffer/Standards/PEAR/Sniffs/",
"CodeSniffer/Standards/PSR1/Sniffs/",
"CodeSniffer/Standards/PSR2/Sniffs/",
"CodeSniffer/Standards/Squiz/Sniffs/",
"CodeSniffer/Standards/Zend/Sniffs/"
]
},
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
@ -2275,7 +2248,7 @@
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2017-03-01T22:17:45+00:00" "time": "2018-07-26T23:47:18+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",

View File

@ -125,7 +125,7 @@ $autoFilter->getColumn('C')
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
// Filter the Date column on a filter value of the first day of every period of the current year // Filter the Date column on a filter value of the first day of every period of the current year
// We us a dateGroup ruletype for this, although it is still a standard filter // We us a dateGroup ruletype for this, although it is still a standard filter
foreach ($periods as $period) { foreach ($periods as $period) {
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));

View File

@ -108,7 +108,7 @@ $spreadsheet->getActiveSheet()->setAutoFilter($spreadsheet->getActiveSheet()->ca
$autoFilter = $spreadsheet->getActiveSheet()->getAutoFilter(); $autoFilter = $spreadsheet->getActiveSheet()->getAutoFilter();
$helper->log('Set active filters'); $helper->log('Set active filters');
// Filter the Country column on a filter value of Germany // Filter the Country column on a filter value of Germany
// As it's just a simple value filter, we can use FILTERTYPE_FILTER // As it's just a simple value filter, we can use FILTERTYPE_FILTER
$autoFilter->getColumn('C') $autoFilter->getColumn('C')
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER) ->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
->createRule() ->createRule()

View File

@ -125,7 +125,7 @@ $autoFilter->getColumn('C')
) )
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); ->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
// Filter the Date column on a filter value of the first day of every period of the current year // Filter the Date column on a filter value of the first day of every period of the current year
// We us a dateGroup ruletype for this, although it is still a standard filter // We us a dateGroup ruletype for this, although it is still a standard filter
foreach ($periods as $period) { foreach ($periods as $period) {
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear)); $endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));

View File

@ -84,7 +84,7 @@ $conditionalStyles[] = $conditional2;
$conditionalStyles[] = $conditional3; $conditionalStyles[] = $conditional3;
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles); $spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
// duplicate the conditional styles across a range of cells // duplicate the conditional styles across a range of cells
$helper->log('Duplicate the conditional formatting across a range of cells'); $helper->log('Duplicate the conditional formatting across a range of cells');
$spreadsheet->getActiveSheet()->duplicateConditionalStyle( $spreadsheet->getActiveSheet()->duplicateConditionalStyle(
$spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles(), $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles(),

View File

@ -59,7 +59,7 @@ $conditionalStyles[] = $conditional1;
$conditionalStyles[] = $conditional3; $conditionalStyles[] = $conditional3;
$spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles); $spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
// duplicate the conditional styles across a range of cells // duplicate the conditional styles across a range of cells
$helper->log('Duplicate the conditional formatting across a range of cells'); $helper->log('Duplicate the conditional formatting across a range of cells');
$spreadsheet->getActiveSheet()->duplicateConditionalStyle( $spreadsheet->getActiveSheet()->duplicateConditionalStyle(
$spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(), $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles(),

View File

@ -5,7 +5,7 @@ use PhpOffice\PhpSpreadsheet\Settings;
require __DIR__ . '/../Header.php'; require __DIR__ . '/../Header.php';
// Change these values to select the Rendering library that you wish to use // Change these values to select the Rendering library that you wish to use
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class); Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
$inputFileType = 'Xlsx'; $inputFileType = 'Xlsx';

View File

@ -7,7 +7,7 @@ require __DIR__ . '/../Header.php';
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class); IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class);
// Change these values to select the Rendering library that you wish to use // Change these values to select the Rendering library that you wish to use
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class); Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
$inputFileType = 'Xlsx'; $inputFileType = 'Xlsx';

View File

@ -23,42 +23,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_AREACHART, // plotType DataSeries::TYPE_AREACHART, // plotType
DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
@ -68,15 +68,15 @@ $series = new DataSeries(
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); $legend = new Legend(Legend::POSITION_TOPRIGHT, null, false);
$title = new Title('Test %age-Stacked Area Chart'); $title = new Title('Test %age-Stacked Area Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -88,11 +88,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -23,42 +23,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_STACKED, // plotGrouping DataSeries::GROUPING_STACKED, // plotGrouping
@ -67,19 +67,19 @@ $series = new DataSeries(
$xAxisTickValues, // plotCategory $xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a horizontal bar rather than a vertical column graph // Make it a horizontal bar rather than a vertical column graph
$series->setPlotDirection(DataSeries::DIRECTION_BAR); $series->setPlotDirection(DataSeries::DIRECTION_BAR);
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Test Chart'); $title = new Title('Test Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -91,11 +91,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -23,42 +23,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_STANDARD, // plotGrouping DataSeries::GROUPING_STANDARD, // plotGrouping
@ -67,19 +67,19 @@ $series = new DataSeries(
$xAxisTickValues, // plotCategory $xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph // Make it a vertical column rather than a horizontal bar graph
$series->setPlotDirection(DataSeries::DIRECTION_COL); $series->setPlotDirection(DataSeries::DIRECTION_COL);
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Test Column Chart'); $title = new Title('Test Column Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -91,11 +91,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -31,42 +31,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 'Budget' new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 'Budget'
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 'Forecast' new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 'Forecast'
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), // 'Actual' new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), // 'Actual'
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$B$13', null, 12), // Q1 to Q4 for 2010 to 2012
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$13', null, 12),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_CLUSTERED, // plotGrouping DataSeries::GROUPING_CLUSTERED, // plotGrouping
@ -75,20 +75,20 @@ $series = new DataSeries(
$xAxisTickValues, // plotCategory $xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph // Make it a vertical column rather than a horizontal bar graph
$series->setPlotDirection(DataSeries::DIRECTION_COL); $series->setPlotDirection(DataSeries::DIRECTION_COL);
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_BOTTOM, null, false); $legend = new Legend(Legend::POSITION_BOTTOM, null, false);
$title = new Title('Test Grouped Column Chart'); $title = new Title('Test Grouped Column Chart');
$xAxisLabel = new Title('Financial Period'); $xAxisLabel = new Title('Financial Period');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -100,11 +100,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('G2'); $chart->setTopLeftPosition('G2');
$chart->setBottomRightPosition('P20'); $chart->setBottomRightPosition('P20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -31,46 +31,46 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels1 = [ $dataSeriesLabels1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // Temperature new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // Temperature
]; ];
$dataSeriesLabels2 = [ $dataSeriesLabels2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // Rainfall new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // Rainfall
]; ];
$dataSeriesLabels3 = [ $dataSeriesLabels3 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // Humidity new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // Humidity
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues1 = [ $dataSeriesValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$13', null, 12),
]; ];
// Build the dataseries // Build the dataseries
$series1 = new DataSeries( $series1 = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_CLUSTERED, // plotGrouping DataSeries::GROUPING_CLUSTERED, // plotGrouping
@ -79,22 +79,22 @@ $series1 = new DataSeries(
$xAxisTickValues, // plotCategory $xAxisTickValues, // plotCategory
$dataSeriesValues1 // plotValues $dataSeriesValues1 // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph // Make it a vertical column rather than a horizontal bar graph
$series1->setPlotDirection(DataSeries::DIRECTION_COL); $series1->setPlotDirection(DataSeries::DIRECTION_COL);
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues2 = [ $dataSeriesValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12),
]; ];
// Build the dataseries // Build the dataseries
$series2 = new DataSeries( $series2 = new DataSeries(
DataSeries::TYPE_LINECHART, // plotType DataSeries::TYPE_LINECHART, // plotType
DataSeries::GROUPING_STANDARD, // plotGrouping DataSeries::GROUPING_STANDARD, // plotGrouping
@ -104,18 +104,18 @@ $series2 = new DataSeries(
$dataSeriesValues2 // plotValues $dataSeriesValues2 // plotValues
); );
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues3 = [ $dataSeriesValues3 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12),
]; ];
// Build the dataseries // Build the dataseries
$series3 = new DataSeries( $series3 = new DataSeries(
DataSeries::TYPE_AREACHART, // plotType DataSeries::TYPE_AREACHART, // plotType
DataSeries::GROUPING_STANDARD, // plotGrouping DataSeries::GROUPING_STANDARD, // plotGrouping
@ -125,14 +125,14 @@ $series3 = new DataSeries(
$dataSeriesValues3 // plotValues $dataSeriesValues3 // plotValues
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series1, $series2, $series3]); $plotArea = new PlotArea(null, [$series1, $series2, $series3]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Average Weather Chart for Crete'); $title = new Title('Average Weather Chart for Crete');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -144,11 +144,11 @@ $chart = new Chart(
null // yAxisLabel null // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('F2'); $chart->setTopLeftPosition('F2');
$chart->setBottomRightPosition('O16'); $chart->setBottomRightPosition('O16');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -23,35 +23,35 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
@ -59,7 +59,7 @@ $dataSeriesValues = [
]; ];
$dataSeriesValues[2]->setLineWidth(60000); $dataSeriesValues[2]->setLineWidth(60000);
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_LINECHART, // plotType DataSeries::TYPE_LINECHART, // plotType
DataSeries::GROUPING_STACKED, // plotGrouping DataSeries::GROUPING_STACKED, // plotGrouping
@ -69,15 +69,15 @@ $series = new DataSeries(
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); $legend = new Legend(Legend::POSITION_TOPRIGHT, null, false);
$title = new Title('Test Stacked Line Chart'); $title = new Title('Test Stacked Line Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -89,11 +89,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -23,42 +23,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels1 = [ $dataSeriesLabels1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues1 = [ $xAxisTickValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues1 = [ $dataSeriesValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series1 = new DataSeries( $series1 = new DataSeries(
DataSeries::TYPE_AREACHART, // plotType DataSeries::TYPE_AREACHART, // plotType
DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
@ -68,15 +68,15 @@ $series1 = new DataSeries(
$dataSeriesValues1 // plotValues $dataSeriesValues1 // plotValues
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea1 = new PlotArea(null, [$series1]); $plotArea1 = new PlotArea(null, [$series1]);
// Set the chart legend // Set the chart legend
$legend1 = new Legend(Legend::POSITION_TOPRIGHT, null, false); $legend1 = new Legend(Legend::POSITION_TOPRIGHT, null, false);
$title1 = new Title('Test %age-Stacked Area Chart'); $title1 = new Title('Test %age-Stacked Area Chart');
$yAxisLabel1 = new Title('Value ($k)'); $yAxisLabel1 = new Title('Value ($k)');
// Create the chart // Create the chart
$chart1 = new Chart( $chart1 = new Chart(
'chart1', // name 'chart1', // name
$title1, // title $title1, // title
@ -88,49 +88,49 @@ $chart1 = new Chart(
$yAxisLabel1 // yAxisLabel $yAxisLabel1 // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart1->setTopLeftPosition('A7'); $chart1->setTopLeftPosition('A7');
$chart1->setBottomRightPosition('H20'); $chart1->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart1); $worksheet->addChart($chart1);
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels2 = [ $dataSeriesLabels2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues2 = [ $xAxisTickValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues2 = [ $dataSeriesValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series2 = new DataSeries( $series2 = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_STANDARD, // plotGrouping DataSeries::GROUPING_STANDARD, // plotGrouping
@ -139,19 +139,19 @@ $series2 = new DataSeries(
$xAxisTickValues2, // plotCategory $xAxisTickValues2, // plotCategory
$dataSeriesValues2 // plotValues $dataSeriesValues2 // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph // Make it a vertical column rather than a horizontal bar graph
$series2->setPlotDirection(DataSeries::DIRECTION_COL); $series2->setPlotDirection(DataSeries::DIRECTION_COL);
// Set the series in the plot area // Set the series in the plot area
$plotArea2 = new PlotArea(null, [$series2]); $plotArea2 = new PlotArea(null, [$series2]);
// Set the chart legend // Set the chart legend
$legend2 = new Legend(Legend::POSITION_RIGHT, null, false); $legend2 = new Legend(Legend::POSITION_RIGHT, null, false);
$title2 = new Title('Test Column Chart'); $title2 = new Title('Test Column Chart');
$yAxisLabel2 = new Title('Value ($k)'); $yAxisLabel2 = new Title('Value ($k)');
// Create the chart // Create the chart
$chart2 = new Chart( $chart2 = new Chart(
'chart2', // name 'chart2', // name
$title2, // title $title2, // title
@ -163,11 +163,11 @@ $chart2 = new Chart(
$yAxisLabel2 // yAxisLabel $yAxisLabel2 // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart2->setTopLeftPosition('I7'); $chart2->setTopLeftPosition('I7');
$chart2->setBottomRightPosition('P20'); $chart2->setBottomRightPosition('P20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart2); $worksheet->addChart($chart2);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -24,38 +24,38 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels1 = [ $dataSeriesLabels1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues1 = [ $xAxisTickValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues1 = [ $dataSeriesValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series1 = new DataSeries( $series1 = new DataSeries(
DataSeries::TYPE_PIECHART, // plotType DataSeries::TYPE_PIECHART, // plotType
null, // plotGrouping (Pie charts don't have any grouping) null, // plotGrouping (Pie charts don't have any grouping)
@ -65,19 +65,19 @@ $series1 = new DataSeries(
$dataSeriesValues1 // plotValues $dataSeriesValues1 // plotValues
); );
// Set up a layout object for the Pie chart // Set up a layout object for the Pie chart
$layout1 = new Layout(); $layout1 = new Layout();
$layout1->setShowVal(true); $layout1->setShowVal(true);
$layout1->setShowPercent(true); $layout1->setShowPercent(true);
// Set the series in the plot area // Set the series in the plot area
$plotArea1 = new PlotArea($layout1, [$series1]); $plotArea1 = new PlotArea($layout1, [$series1]);
// Set the chart legend // Set the chart legend
$legend1 = new Legend(Legend::POSITION_RIGHT, null, false); $legend1 = new Legend(Legend::POSITION_RIGHT, null, false);
$title1 = new Title('Test Pie Chart'); $title1 = new Title('Test Pie Chart');
// Create the chart // Create the chart
$chart1 = new Chart( $chart1 = new Chart(
'chart1', // name 'chart1', // name
$title1, // title $title1, // title
@ -86,48 +86,48 @@ $chart1 = new Chart(
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs 0, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Pie charts don't have a Y-Axis null // yAxisLabel - Pie charts don't have a Y-Axis
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart1->setTopLeftPosition('A7'); $chart1->setTopLeftPosition('A7');
$chart1->setBottomRightPosition('H20'); $chart1->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart1); $worksheet->addChart($chart1);
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels2 = [ $dataSeriesLabels2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues2 = [ $xAxisTickValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues2 = [ $dataSeriesValues2 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series2 = new DataSeries( $series2 = new DataSeries(
DataSeries::TYPE_DONUTCHART, // plotType DataSeries::TYPE_DONUTCHART, // plotType
null, // plotGrouping (Donut charts don't have any grouping) null, // plotGrouping (Donut charts don't have any grouping)
@ -137,17 +137,17 @@ $series2 = new DataSeries(
$dataSeriesValues2 // plotValues $dataSeriesValues2 // plotValues
); );
// Set up a layout object for the Pie chart // Set up a layout object for the Pie chart
$layout2 = new Layout(); $layout2 = new Layout();
$layout2->setShowVal(true); $layout2->setShowVal(true);
$layout2->setShowCatName(true); $layout2->setShowCatName(true);
// Set the series in the plot area // Set the series in the plot area
$plotArea2 = new PlotArea($layout2, [$series2]); $plotArea2 = new PlotArea($layout2, [$series2]);
$title2 = new Title('Test Donut Chart'); $title2 = new Title('Test Donut Chart');
// Create the chart // Create the chart
$chart2 = new Chart( $chart2 = new Chart(
'chart2', // name 'chart2', // name
$title2, // title $title2, // title
@ -156,14 +156,14 @@ $chart2 = new Chart(
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs 0, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart2->setTopLeftPosition('I7'); $chart2->setTopLeftPosition('I7');
$chart2->setBottomRightPosition('P20'); $chart2->setBottomRightPosition('P20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart2); $worksheet->addChart($chart2);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -32,41 +32,41 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$13', null, 12), // Jan to Dec
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$13', null, 12),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$13', null, 12),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_RADARCHART, // plotType DataSeries::TYPE_RADARCHART, // plotType
null, // plotGrouping (Radar charts don't have any grouping) null, // plotGrouping (Radar charts don't have any grouping)
@ -79,17 +79,17 @@ $series = new DataSeries(
DataSeries::STYLE_MARKER // plotStyle DataSeries::STYLE_MARKER // plotStyle
); );
// Set up a layout object for the Pie chart // Set up a layout object for the Pie chart
$layout = new Layout(); $layout = new Layout();
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea($layout, [$series]); $plotArea = new PlotArea($layout, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Test Radar Chart'); $title = new Title('Test Radar Chart');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -98,14 +98,14 @@ $chart = new Chart(
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs 0, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Radar charts don't have a Y-Axis null // yAxisLabel - Radar charts don't have a Y-Axis
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('F2'); $chart->setTopLeftPosition('F2');
$chart->setBottomRightPosition('M15'); $chart->setBottomRightPosition('M15');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -23,36 +23,36 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_SCATTERCHART, // plotType DataSeries::TYPE_SCATTERCHART, // plotType
null, // plotGrouping (Scatter charts don't have any grouping) null, // plotGrouping (Scatter charts don't have any grouping)
@ -65,15 +65,15 @@ $series = new DataSeries(
DataSeries::STYLE_LINEMARKER // plotStyle DataSeries::STYLE_LINEMARKER // plotStyle
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false); $legend = new Legend(Legend::POSITION_TOPRIGHT, null, false);
$title = new Title('Test Scatter Chart'); $title = new Title('Test Scatter Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -85,11 +85,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -29,36 +29,36 @@ $worksheet->fromArray(
); );
$worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER_00); $worksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER_00);
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), //Max / Open new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), //Max / Open
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), //Min / Close new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), //Min / Close
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), //Min Threshold / Min new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), //Min Threshold / Min
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), //Max Threshold / Max new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$E$1', null, 1), //Max Threshold / Max
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$6', null, 5), // Counts new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$6', null, 5), // Counts
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$6', null, 5), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$6', null, 5),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$6', null, 5), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$6', null, 5),
@ -66,7 +66,7 @@ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$6', null, 5), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$E$2:$E$6', null, 5),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_STOCKCHART, // plotType DataSeries::TYPE_STOCKCHART, // plotType
null, // plotGrouping - if we set this to not null, then xlsx throws error null, // plotGrouping - if we set this to not null, then xlsx throws error
@ -76,16 +76,16 @@ $series = new DataSeries(
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Test Stock Chart'); $title = new Title('Test Stock Chart');
$xAxisLabel = new Title('Counts'); $xAxisLabel = new Title('Counts');
$yAxisLabel = new Title('Values'); $yAxisLabel = new Title('Values');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'stock-chart', // name 'stock-chart', // name
$title, // title $title, // title
@ -97,11 +97,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
// Save Excel 2007 file // Save Excel 2007 file

View File

@ -57,7 +57,7 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
// Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object // Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $spreadsheet = $reader->load($inputFileName);
// Do some processing here // Do some processing here
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
var_dump($sheetData); var_dump($sheetData);

View File

@ -60,7 +60,7 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
// Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object // Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName); $spreadsheet = $reader->load($inputFileName);
// Do some processing here // Do some processing here
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
var_dump($sheetData); var_dump($sheetData);

View File

@ -25,24 +25,24 @@ foreach ($customPropertyList as $customPropertyName) {
// Manipulate properties as appropriate for display purposes // Manipulate properties as appropriate for display purposes
switch ($propertyType) { switch ($propertyType) {
case 'i': // integer case 'i': // integer
$propertyType = 'integer number'; $propertyType = 'integer number';
break; break;
case 'f': // float case 'f': // float
$propertyType = 'floating point number'; $propertyType = 'floating point number';
break; break;
case 's': // string case 's': // string
$propertyType = 'string'; $propertyType = 'string';
break; break;
case 'd': // date case 'd': // date
$propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue); $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue);
$propertyType = 'date'; $propertyType = 'date';
break; break;
case 'b': // boolean case 'b': // boolean
$propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
$propertyType = 'boolean'; $propertyType = 'boolean';

View File

@ -20,42 +20,42 @@ $worksheet->fromArray(
] ]
); );
// Set the Labels for each data series we want to plot // Set the Labels for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesLabels = [ $dataSeriesLabels = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // 2012
]; ];
// Set the X-Axis Labels // Set the X-Axis Labels
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$xAxisTickValues = [ $xAxisTickValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4 new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
]; ];
// Set the Data values for each data series we want to plot // Set the Data values for each data series we want to plot
// Datatype // Datatype
// Cell reference for data // Cell reference for data
// Format Code // Format Code
// Number of datapoints in series // Number of datapoints in series
// Data values // Data values
// Data Marker // Data Marker
$dataSeriesValues = [ $dataSeriesValues = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4), new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', null, 4),
]; ];
// Build the dataseries // Build the dataseries
$series = new DataSeries( $series = new DataSeries(
DataSeries::TYPE_BARCHART, // plotType DataSeries::TYPE_BARCHART, // plotType
DataSeries::GROUPING_CLUSTERED, // plotGrouping DataSeries::GROUPING_CLUSTERED, // plotGrouping
@ -64,19 +64,19 @@ $series = new DataSeries(
$xAxisTickValues, // plotCategory $xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues $dataSeriesValues // plotValues
); );
// Set additional dataseries parameters // Set additional dataseries parameters
// Make it a horizontal bar rather than a vertical column graph // Make it a horizontal bar rather than a vertical column graph
$series->setPlotDirection(DataSeries::DIRECTION_BAR); $series->setPlotDirection(DataSeries::DIRECTION_BAR);
// Set the series in the plot area // Set the series in the plot area
$plotArea = new PlotArea(null, [$series]); $plotArea = new PlotArea(null, [$series]);
// Set the chart legend // Set the chart legend
$legend = new Legend(Legend::POSITION_RIGHT, null, false); $legend = new Legend(Legend::POSITION_RIGHT, null, false);
$title = new Title('Test Bar Chart'); $title = new Title('Test Bar Chart');
$yAxisLabel = new Title('Value ($k)'); $yAxisLabel = new Title('Value ($k)');
// Create the chart // Create the chart
$chart = new Chart( $chart = new Chart(
'chart1', // name 'chart1', // name
$title, // title $title, // title
@ -88,11 +88,11 @@ $chart = new Chart(
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );
// Set the position where the chart should appear in the worksheet // Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7'); $chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20'); $chart->setBottomRightPosition('H20');
// Add the chart to the worksheet // Add the chart to the worksheet
$worksheet->addChart($chart); $worksheet->addChart($chart);
return $spreadsheet; return $spreadsheet;