public static function PHPExcel_Calculation_TextData::DOLLAR in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php \PHPExcel_Calculation_TextData::DOLLAR()
* DOLLAR * * This function converts a number to text using currency format, with the decimals rounded to the specified place. * The format used is $#,##0.00_);($#,##0.00).. * *
Parameters
float $value The value to format: * @param int $decimals The number of digits to display to the right of the decimal point. * If decimals is negative, number is rounded to the left of the decimal point. * If you omit decimals, it is assumed to be 2 * @return string
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ TextData.php, line 200
Class
- PHPExcel_Calculation_TextData
- PHPExcel_Calculation_TextData
Code
public static function DOLLAR($value = 0, $decimals = 2) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
// Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) {
return PHPExcel_Calculation_Functions::NaN();
}
$decimals = floor($decimals);
$mask = '$#,##0';
if ($decimals > 0) {
$mask .= '.' . str_repeat('0', $decimals);
}
else {
$round = pow(10, abs($decimals));
if ($value < 0) {
$round = 0 - $round;
}
$value = PHPExcel_Calculation_MathTrig::MROUND($value, $round);
}
return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask);
}