Update Excel function samples for Date/Time and Engineering functions
This commit is contained in:
parent
420a63bc01
commit
441ae741d7
|
|
@ -24,6 +24,7 @@ $testDates = [
|
||||||
[2000, 1, 1],
|
[2000, 1, 1],
|
||||||
[2019, 2, 14],
|
[2019, 2, 14],
|
||||||
[2020, 7, 4],
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
];
|
];
|
||||||
$testDateCount = count($testDates);
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ $testDates = [
|
||||||
[2000, 1, 1],
|
[2000, 1, 1],
|
||||||
[2019, 2, 14],
|
[2019, 2, 14],
|
||||||
[2020, 7, 4],
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
[2029, 12, 31],
|
[2029, 12, 31],
|
||||||
[2525, 1, 1],
|
[2525, 1, 1],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'NETWORKDAYS';
|
||||||
|
$description = 'Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$publicHolidays = [
|
||||||
|
[2022, 1, 3, '=DATE(G1, H1, I1)', 'New Year'],
|
||||||
|
[2022, 4, 15, '=DATE(G2, H2, I2)', 'Good Friday'],
|
||||||
|
[2022, 4, 18, '=DATE(G3, H3, I3)', 'Easter Monday'],
|
||||||
|
[2022, 5, 2, '=DATE(G4, H4, I4)', 'Early May Bank Holiday'],
|
||||||
|
[2022, 6, 2, '=DATE(G5, H5, I5)', 'Spring Bank Holiday'],
|
||||||
|
[2022, 6, 3, '=DATE(G6, H6, I6)', 'Platinum Jubilee Bank Holiday'],
|
||||||
|
[2022, 8, 29, '=DATE(G7, H7, I7)', 'Summer Bank Holiday'],
|
||||||
|
[2022, 12, 26, '=DATE(G8, H8, I8)', 'Boxing Day'],
|
||||||
|
[2022, 12, 27, '=DATE(G9, H9, I9)', 'Christmas Day'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$holidayCount = count($publicHolidays);
|
||||||
|
$worksheet->fromArray($publicHolidays, null, 'G1', true);
|
||||||
|
|
||||||
|
$worksheet->getStyle('J1:J' . $holidayCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=DATE(2022,1,1)');
|
||||||
|
|
||||||
|
for ($numberOfMonths = 0; $numberOfMonths < 12; ++$numberOfMonths) {
|
||||||
|
$worksheet->setCellValue('B' . ($numberOfMonths + 1), '=EOMONTH(A1, ' . $numberOfMonths . ')');
|
||||||
|
$worksheet->setCellValue('C' . ($numberOfMonths + 1), '=NETWORKDAYS(A1, B' . ($numberOfMonths + 1) . ')');
|
||||||
|
$worksheet->setCellValue('D' . ($numberOfMonths + 1), '=NETWORKDAYS(A1, B' . ($numberOfMonths + 1) . ', J1:J' . $holidayCount . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('B1:B12')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('UK Public Holidays');
|
||||||
|
$holidayData = $worksheet->rangeToArray('J1:K' . $holidayCount, null, true, true, true);
|
||||||
|
$helper->displayGrid($holidayData);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= 12; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between %s and %s is %d working days; %d with public holidays',
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'WORKDAY';
|
||||||
|
$description = 'Returns a number that represents a date that is the indicated number of working days before or after a starting date. Working days exclude weekends and any dates identified as holidays';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$publicHolidays = [
|
||||||
|
[2022, 1, 3, '=DATE(G1, H1, I1)', 'New Year'],
|
||||||
|
[2022, 4, 15, '=DATE(G2, H2, I2)', 'Good Friday'],
|
||||||
|
[2022, 4, 18, '=DATE(G3, H3, I3)', 'Easter Monday'],
|
||||||
|
[2022, 5, 2, '=DATE(G4, H4, I4)', 'Early May Bank Holiday'],
|
||||||
|
[2022, 6, 2, '=DATE(G5, H5, I5)', 'Spring Bank Holiday'],
|
||||||
|
[2022, 6, 3, '=DATE(G6, H6, I6)', 'Platinum Jubilee Bank Holiday'],
|
||||||
|
[2022, 8, 29, '=DATE(G7, H7, I7)', 'Summer Bank Holiday'],
|
||||||
|
[2022, 12, 26, '=DATE(G8, H8, I8)', 'Boxing Day'],
|
||||||
|
[2022, 12, 27, '=DATE(G9, H9, I9)', 'Christmas Day'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$holidayCount = count($publicHolidays);
|
||||||
|
$worksheet->fromArray($publicHolidays, null, 'G1', true);
|
||||||
|
|
||||||
|
$worksheet->getStyle('J1:J' . $holidayCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=DATE(2022,1,1)');
|
||||||
|
|
||||||
|
$workdayStep = 10;
|
||||||
|
for ($days = $workdayStep; $days <= 366; $days += $workdayStep) {
|
||||||
|
$worksheet->setCellValue('B' . ((int) $days / $workdayStep + 1), $days);
|
||||||
|
$worksheet->setCellValue('C' . ((int) $days / $workdayStep + 1), '=WORKDAY(A1, B' . ((int) $days / $workdayStep + 1) . ')');
|
||||||
|
$worksheet->setCellValue('D' . ((int) $days / $workdayStep + 1), '=WORKDAY(A1, B' . ((int) $days / $workdayStep + 1) . ', J1:J' . $holidayCount . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('C1:D50')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('UK Public Holidays');
|
||||||
|
$holidayData = $worksheet->rangeToArray('J1:K' . $holidayCount, null, true, true, true);
|
||||||
|
$helper->displayGrid($holidayData);
|
||||||
|
|
||||||
|
for ($days = $workdayStep; $days <= 366; $days += $workdayStep) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%d workdays from %s is %s; %s with public holidays',
|
||||||
|
$worksheet->getCell('B' . ((int) $days / $workdayStep + 1))->getFormattedValue(),
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . ((int) $days / $workdayStep + 1))->getFormattedValue(),
|
||||||
|
$worksheet->getCell('D' . ((int) $days / $workdayStep + 1))->getFormattedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DAYS360';
|
||||||
|
$description = 'Returns the number of days between two dates based on a 360-day year';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 1, 1],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1960, 12, 19],
|
||||||
|
[1999, 12, 31],
|
||||||
|
[2000, 1, 1],
|
||||||
|
[2019, 2, 14],
|
||||||
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
|
[2029, 12, 31],
|
||||||
|
[2525, 1, 1],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DATE(2022,12,31)');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ')');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 1)');
|
||||||
|
$worksheet->setCellValue('I' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 2)');
|
||||||
|
$worksheet->setCellValue('J' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 3)');
|
||||||
|
$worksheet->setCellValue('K' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 4)');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:F' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between: %s and %s',
|
||||||
|
$worksheet->getCell('E' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - US (NASD) 30/360',
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual',
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual/360',
|
||||||
|
$worksheet->getCell('I' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual/365',
|
||||||
|
$worksheet->getCell('J' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - European 30/360',
|
||||||
|
$worksheet->getCell('K' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELI';
|
||||||
|
$description = 'Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELI({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELJ';
|
||||||
|
$description = 'Returns the Bessel function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELJ({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELK';
|
||||||
|
$description = 'Returns the modified Bessel function, which is equivalent to the Bessel functions evaluated for purely imaginary arguments';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELK({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELY';
|
||||||
|
$description = 'Returns the Bessel function, which is also called the Weber function or the Neumann function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELY({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2DEC';
|
||||||
|
$description = 'Converts a binary number to decimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2DEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is decimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2HEX';
|
||||||
|
$description = 'Converts a binary number to hexadecimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2HEX(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is hexadecimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2OCT';
|
||||||
|
$description = 'Converts a binary number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITAND';
|
||||||
|
$description = "Returns a bitwise 'AND' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITAND(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise AND of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITLSHIFT';
|
||||||
|
$description = 'Returns a number shifted left by the specified number of bits';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1],
|
||||||
|
[3],
|
||||||
|
[9],
|
||||||
|
[15],
|
||||||
|
[26],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
$worksheet->setCellValue('C' . $row, '=BITLSHIFT(A' . $row . ',1)');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITLSHIFT(A' . $row . ',2)');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=BITLSHIFT(A' . $row . ',3)');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 1 bit is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 2 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 3 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITOR';
|
||||||
|
$description = "Returns a bitwise 'OR' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITOR(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise OR of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITRSHIFT';
|
||||||
|
$description = 'Returns a number shifted right by the specified number of bits';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[9],
|
||||||
|
[15],
|
||||||
|
[26],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
$worksheet->setCellValue('C' . $row, '=BITRSHIFT(A' . $row . ',1)');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITRSHIFT(A' . $row . ',2)');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=BITRSHIFT(A' . $row . ',3)');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 1 bit is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 2 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 3 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITXOR';
|
||||||
|
$description = "Returns a bitwise 'XOR' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITXOR(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise XOR of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'COMPLEX';
|
||||||
|
$description = 'Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3, 4],
|
||||||
|
[3, 4, '"j"'],
|
||||||
|
[3.5, 4.75],
|
||||||
|
[0, 1],
|
||||||
|
[1, 0],
|
||||||
|
[0, -1],
|
||||||
|
[0, 2],
|
||||||
|
[2, 0],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('A' . $row, '=COMPLEX(' . implode(',', $testData[$row - 1]) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Formula %s result is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'CONVERT';
|
||||||
|
$description = 'Converts a number from one measurement system to another';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$conversions = [
|
||||||
|
[1, '"lbm"', '"kg"'],
|
||||||
|
[1, '"gal"', '"l"'],
|
||||||
|
[24, '"in"', '"ft"'],
|
||||||
|
[100, '"yd"', '"m"'],
|
||||||
|
[500, '"mi"', '"km"'],
|
||||||
|
[7.5, '"min"', '"sec"'],
|
||||||
|
[5, '"F"', '"C"'],
|
||||||
|
[32, '"C"', '"K"'],
|
||||||
|
[100, '"m2"', '"ft2"'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($conversions);
|
||||||
|
|
||||||
|
$worksheet->fromArray($conversions, null, 'A1');
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=CONVERT(' . implode(',', $conversions[$row - 1]) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->setCellValue('H1', '=CONVERT(CONVERT(100,"m","ft"),"m","ft")');
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Unit of Measure Conversion Formula %s - %d %s is %f %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('D' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
trim($worksheet->getCell('B' . $row)->getValue(), '"'),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
trim($worksheet->getCell('C' . $row)->getValue(), '"')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$helper->log('Old method for area conversions, before MS Excel introduced area Units of Measure');
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Unit of Measure Conversion Formula %s result is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('H1')->getValue(),
|
||||||
|
$worksheet->getCell('H1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2BIN';
|
||||||
|
$description = 'Converts a decimal number to binary';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is binary %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2HEX';
|
||||||
|
$description = 'Converts a decimal number to hexadecimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
[12345678],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2HEX(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is hexadecimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2OCT';
|
||||||
|
$description = 'Converts a decimal number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
[12345678],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DELTA';
|
||||||
|
$description = 'Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise. This function is also known as the Kronecker Delta function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[4, 5],
|
||||||
|
[3, 3],
|
||||||
|
[0.5, 0],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=DELTA(A' . $row . ',B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$comparison = [
|
||||||
|
0 => 'The values are not equal',
|
||||||
|
1 => 'The values are equal',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Compare values %d and %d - Result is %d - %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$comparison[$worksheet->getCell('C' . $row)->getCalculatedValue()]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'ERF';
|
||||||
|
$description = 'Returns the error function integrated between lower_limit and upper_limit';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData1 = [
|
||||||
|
[0.745],
|
||||||
|
[1],
|
||||||
|
[1.5],
|
||||||
|
[-2],
|
||||||
|
];
|
||||||
|
|
||||||
|
$testData2 = [
|
||||||
|
[0, 1.5],
|
||||||
|
[1, 2],
|
||||||
|
[-2, 1],
|
||||||
|
];
|
||||||
|
$testDataCount1 = count($testData1);
|
||||||
|
$testDataCount2 = count($testData2);
|
||||||
|
$testData2StartRow = $testDataCount1 + 1;
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData1, null, 'A1', true);
|
||||||
|
$worksheet->fromArray($testData2, null, "A{$testData2StartRow}", true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount1; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERF(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($row = $testDataCount1 + 1; $row <= $testDataCount2 + $testDataCount1; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERF(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('ERF() With a single argument');
|
||||||
|
for ($row = 1; $row <= $testDataCount1; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(C%d): %s The error function integrated between 0 and %f is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$helper->log('ERF() With two arguments');
|
||||||
|
for ($row = $testDataCount1 + 1; $row <= $testDataCount2 + $testDataCount1; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(C%d): %s The error function integrated between %f and %f is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'ERFC';
|
||||||
|
$description = 'Returns the complementary ERF function integrated between x and infinity';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[0],
|
||||||
|
[0.5],
|
||||||
|
[1],
|
||||||
|
[-1],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERFC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): %s The complementary error function integrated by %f and infinity is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'GESTEP';
|
||||||
|
$description = 'Returns 1 if number ≥ step; returns 0 (zero) otherwise';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[5, 4],
|
||||||
|
[5, 5],
|
||||||
|
[4, 5],
|
||||||
|
[-4, -5],
|
||||||
|
[-5, -4],
|
||||||
|
[1],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=GESTEP(A' . $row . ',B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$comparison = [
|
||||||
|
0 => 'Value %d is less than step %d',
|
||||||
|
1 => 'Value %d is greater than or equal to step %d',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Compare value %d and step %d - Result is %d - %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
sprintf(
|
||||||
|
$comparison[$worksheet->getCell('C' . $row)->getCalculatedValue()],
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2BIN';
|
||||||
|
$description = 'Converts a hexadecimal number to binary';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3],
|
||||||
|
[8],
|
||||||
|
[42],
|
||||||
|
[99],
|
||||||
|
['A2'],
|
||||||
|
['F0'],
|
||||||
|
['100'],
|
||||||
|
['128'],
|
||||||
|
['1AB'],
|
||||||
|
['1FF'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2BIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is binary %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2DEC';
|
||||||
|
$description = 'Converts a hexadecimal number to decimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['08'],
|
||||||
|
['42'],
|
||||||
|
['A2'],
|
||||||
|
['400'],
|
||||||
|
['1000'],
|
||||||
|
['1234'],
|
||||||
|
['ABCD'],
|
||||||
|
['C3B0'],
|
||||||
|
['FFFFFFFFF'],
|
||||||
|
['FFFFFFFFFF'],
|
||||||
|
['FFFFFFF800'],
|
||||||
|
['FEDCBA9876'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2DEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is decimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2OCT';
|
||||||
|
$description = 'Converts a hexadecimal number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['08'],
|
||||||
|
['42'],
|
||||||
|
['A2'],
|
||||||
|
['400'],
|
||||||
|
['100'],
|
||||||
|
['1234'],
|
||||||
|
['ABCD'],
|
||||||
|
['C3B0'],
|
||||||
|
['FFFFFFFFFF'],
|
||||||
|
['FFFFFFF800'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMABS';
|
||||||
|
$description = 'Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMABS(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The absolute value of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMAGINARY';
|
||||||
|
$description = 'Returns the imaginary coefficient of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMAGINARY(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The imaginary component of %s is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMARGUMENT';
|
||||||
|
$description = 'Returns the argument Theta, an angle expressed in radians';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMARGUMENT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Theta Argument of %s is %f radians',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCONJUGATE';
|
||||||
|
$description = 'Returns the complex conjugate of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCONJUGATE(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Conjugate of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOS';
|
||||||
|
$description = 'Returns the cosine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOS(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cosine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOSH';
|
||||||
|
$description = 'Returns the hyperbolic cosine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOSH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Cosine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOT';
|
||||||
|
$description = 'Returns the cotangent of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cotangent of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCSC';
|
||||||
|
$description = 'Returns the cosecant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCSC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cosecant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCSCH';
|
||||||
|
$description = 'Returns the hyperbolic cosecant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCSCH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Cosecant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMDIV';
|
||||||
|
$description = 'Returns the quotient of two complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMDIV(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Quotient of %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMEXP';
|
||||||
|
$description = 'Returns the exponential of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMEXP(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Exponential of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLN';
|
||||||
|
$description = 'Returns the natural logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Natural Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLOG10';
|
||||||
|
$description = 'Returns the base-10 logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLOG10(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Base-10 Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLOG2';
|
||||||
|
$description = 'Returns the base-2 logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLOG2(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Base-2 Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMPOWER';
|
||||||
|
$description = 'Returns a complex number in x + yi or x + yj text format raised to a power';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', 2],
|
||||||
|
['5-12i', 2],
|
||||||
|
['3.25+7.5i', 3],
|
||||||
|
['3.25-12.5i', 2],
|
||||||
|
['-3.25+7.5i', 3],
|
||||||
|
['-3.25-7.5i', 4],
|
||||||
|
['0-j', 5],
|
||||||
|
['0-2.5j', 3],
|
||||||
|
['0+j', 2.5],
|
||||||
|
['0+1.25j', 2],
|
||||||
|
[4, 3],
|
||||||
|
[-2.5, 2],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMPOWER(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): %s raised to the power of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMPRODUCT';
|
||||||
|
$description = 'Returns the product of two or more complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMPRODUCT(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Product of %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMREAL';
|
||||||
|
$description = 'Returns the real coefficient of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMREAL(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The real component of %s is %f radians',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSEC';
|
||||||
|
$description = 'Returns the secant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Secant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSECH';
|
||||||
|
$description = 'Returns the hyperbolic secant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSECH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Secant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSIN';
|
||||||
|
$description = 'Returns the sine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Sine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSINH';
|
||||||
|
$description = 'Returns the hyperbolic sine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSINH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Sine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSQRT';
|
||||||
|
$description = 'Returns the square root of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSQRT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Square Root of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSUB';
|
||||||
|
$description = 'Returns the difference of two complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMSUB(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Difference between %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSUM';
|
||||||
|
$description = 'Returns the sum of two or more complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMSUM(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Sum of %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMTAN';
|
||||||
|
$description = 'Returns the tangent of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMTAN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Tangent of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'OCT2BIN';
|
||||||
|
$description = 'Converts an octal number to binary';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3],
|
||||||
|
[7],
|
||||||
|
[42],
|
||||||
|
[70],
|
||||||
|
[72],
|
||||||
|
[77],
|
||||||
|
[100],
|
||||||
|
[127],
|
||||||
|
[177],
|
||||||
|
[456],
|
||||||
|
[567],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=OCT2BIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Octal %s is binary %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'OCT2DEC';
|
||||||
|
$description = 'Converts an octal number to decimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3],
|
||||||
|
[7],
|
||||||
|
[42],
|
||||||
|
[70],
|
||||||
|
[72],
|
||||||
|
[77],
|
||||||
|
[100],
|
||||||
|
[127],
|
||||||
|
[177],
|
||||||
|
[456],
|
||||||
|
[4567],
|
||||||
|
[7777700001],
|
||||||
|
[7777776543],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=OCT2DEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Octal %s is decimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'OCT2HEX';
|
||||||
|
$description = 'Converts an octal number to hexadecimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3],
|
||||||
|
[12],
|
||||||
|
[42],
|
||||||
|
[70],
|
||||||
|
[72],
|
||||||
|
[77],
|
||||||
|
[100],
|
||||||
|
[127],
|
||||||
|
[177],
|
||||||
|
[456],
|
||||||
|
[4567],
|
||||||
|
[7777700001],
|
||||||
|
[7777776543],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=OCT2HEX(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Octal %s is hexadecimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ class Compare
|
||||||
*
|
*
|
||||||
* @param array|float $number the value to test against step
|
* @param array|float $number the value to test against step
|
||||||
* Or can be an array of values
|
* Or can be an array of values
|
||||||
* @param array|float $step The threshold value. If you omit a value for step, GESTEP uses zero.
|
* @param null|array|float $step The threshold value. If you omit a value for step, GESTEP uses zero.
|
||||||
* Or can be an array of values
|
* Or can be an array of values
|
||||||
*
|
*
|
||||||
* @return array|int|string (string in the event of an error)
|
* @return array|int|string (string in the event of an error)
|
||||||
|
|
@ -72,7 +72,7 @@ class Compare
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$number = EngineeringValidations::validateFloat($number);
|
$number = EngineeringValidations::validateFloat($number);
|
||||||
$step = EngineeringValidations::validateFloat($step);
|
$step = EngineeringValidations::validateFloat($step ?? 0.0);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[6890, '18, 11, 11'], // year without centure
|
[6890, '18, 11, 11'], // year less than 1900, adds 1900 (1918-11-11)
|
||||||
|
[44809, '122, 9, 5'], // year less than 1900, adds 1900 (2022-09-05)
|
||||||
|
[693845, '1899, 9, 5'], // year less than 1900, adds 1900 (3799-09-05)
|
||||||
[1, '1900, 1, 1'], // Excel 1900 Calendar BaseDate
|
[1, '1900, 1, 1'], // Excel 1900 Calendar BaseDate
|
||||||
[59, '1900, 2, 28'], // Day before Excel mythical 1900 leap day
|
[59, '1900, 2, 28'], // Day before Excel mythical 1900 leap day
|
||||||
[60, '1900, 2, 29'], // Excel mythical 1900 leap day
|
[60, '1900, 2, 29'], // Excel mythical 1900 leap day
|
||||||
|
|
@ -15,6 +17,7 @@ return [
|
||||||
[25569, '1970, 1, 1'], // Unix Timestamp Base Date
|
[25569, '1970, 1, 1'], // Unix Timestamp Base Date
|
||||||
[30292, '1982, 12, 7'],
|
[30292, '1982, 12, 7'],
|
||||||
[39611, '2008, 6, 12'],
|
[39611, '2008, 6, 12'],
|
||||||
|
[50000, '2036, 11, 21'],
|
||||||
[50424, '2038, 1, 19'], // 32-bit signed Unix Timestamp Latest Date
|
[50424, '2038, 1, 19'], // 32-bit signed Unix Timestamp Latest Date
|
||||||
[50425, '2038, 1, 20'], // Day after 32-bit signed Unix Timestamp Latest Date
|
[50425, '2038, 1, 20'], // Day after 32-bit signed Unix Timestamp Latest Date
|
||||||
[39448, '2008, 1, 1'],
|
[39448, '2008, 1, 1'],
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ return [
|
||||||
['5', '101'],
|
['5', '101'],
|
||||||
['2', '10'],
|
['2', '10'],
|
||||||
['0', '0'],
|
['0', '0'],
|
||||||
|
['5', 101],
|
||||||
|
['100', 1100100],
|
||||||
['#NUM!', '21'], // Invalid binary number
|
['#NUM!', '21'], // Invalid binary number
|
||||||
['#VALUE!', 'true'], // Boolean okay for ODS, not for Excel/Gnumeric
|
['#VALUE!', 'true'], // Boolean okay for ODS, not for Excel/Gnumeric
|
||||||
['#VALUE!', 'false'], // Boolean okay for ODS, not for Excel/Gnumeric
|
['#VALUE!', 'false'], // Boolean okay for ODS, not for Excel/Gnumeric
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue