mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-24 02:18:30 +00:00
a34695e0f9
* Additional unit tests and rationalisation for Financial Functions * Providing a series of sample files for Financial functions * Refactor the last of the existing Financial functions * Some more unit tests with default assignments from null arguments Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com>
30 lines
968 B
PHP
30 lines
968 B
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Helpers as DateHelper;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
require __DIR__ . '/../../Header.php';
|
|
|
|
$helper->log('Returns the number of days from the beginning of a coupon\'s period to the settlement date.');
|
|
|
|
// Create new PhpSpreadsheet object
|
|
$spreadsheet = new Spreadsheet();
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
|
|
// Add some data
|
|
$arguments = [
|
|
['Settlement Date', DateHelper::getDateValue('01-Jan-2011')],
|
|
['Maturity Date', DateHelper::getDateValue('25-Oct-2012')],
|
|
['Frequency', 4],
|
|
];
|
|
|
|
// Some basic formatting for the data
|
|
$worksheet->fromArray($arguments, null, 'A1');
|
|
$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy');
|
|
|
|
// Now the formula
|
|
$worksheet->setCellValue('B6', '=COUPDAYBS(B1, B2, B3)');
|
|
|
|
$helper->log($worksheet->getCell('B6')->getValue());
|
|
$helper->log('COUPDAYBS() Result is ' . $worksheet->getCell('B6')->getFormattedValue());
|