Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Style; use PhpOf..
Decoded Output download
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Style;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class NumberFormatRoundTest extends TestCase
{
public static function testRound(): void
{
// Inconsistent rounding due to letting sprintf do it rather than round.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->getStyle('A1:H2')->getNumberFormat()->setFormatCode('0');
$sheet->getStyle('A3:H3')->getNumberFormat()->setFormatCode('0.0');
$sheet->fromArray(
[
[-3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5],
[-3.1, -2.9, -1.4, -0.3, 0.7, 1.6, 2.4, 3.7],
[-3.15, -2.85, -1.43, -0.87, 0.72, 1.60, 2.45, 3.75],
]
);
$expected = [
[-4, -3, -2, -1, 1, 2, 3, 4],
[-3, -3, -1, 0, 1, 2, 2, 4],
[-3.2, -2.9, -1.4, -0.9, 0.7, 1.6, 2.5, 3.8],
];
self::assertEquals($expected, $sheet->toArray());
$spreadsheet->disconnectWorksheets();
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Style;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class NumberFormatRoundTest extends TestCase
{
public static function testRound(): void
{
// Inconsistent rounding due to letting sprintf do it rather than round.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->getStyle('A1:H2')->getNumberFormat()->setFormatCode('0');
$sheet->getStyle('A3:H3')->getNumberFormat()->setFormatCode('0.0');
$sheet->fromArray(
[
[-3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5],
[-3.1, -2.9, -1.4, -0.3, 0.7, 1.6, 2.4, 3.7],
[-3.15, -2.85, -1.43, -0.87, 0.72, 1.60, 2.45, 3.75],
]
);
$expected = [
[-4, -3, -2, -1, 1, 2, 3, 4],
[-3, -3, -1, 0, 1, 2, 2, 4],
[-3.2, -2.9, -1.4, -0.9, 0.7, 1.6, 2.5, 3.8],
];
self::assertEquals($expected, $sheet->toArray());
$spreadsheet->disconnectWorksheets();
}
}
Function Calls
None |
Stats
MD5 | 0d913c6c2cdfa22e54a63e1461fa66bd |
Eval Count | 0 |
Decode Time | 76 ms |