FlexSheet allows you to set the number of digits after the decimal point to round to when calculating formulas using CalculationPrecision property of the FlexSheet class. Please note that setting the negative value for the CalculationPrecision property, then rounding will not be performed.
The following code demonstrates the use of CalculationPrecision property. This example uses the calculationPrecision.js file.
Controller code
HomeController.cs |
Copy Code
|
---|---|
public IActionResult Index( int val=14) { int CalculationPrecision = val; return View(CalculationPrecision); } |
View Code
Index.cshtml |
Copy Code
|
---|---|
@model int @section Scripts{<script type="text/javascript" src="~/js/flexSheet/calculationPrecision.js"></script>} <style> .btn { margin-bottom: 0; } </style> <div> <div class="copy"> <h3>Calculation Precision</h3> </div> <div class="row"> <div class="col-md-12 col-xs-24"> <div class="form-inline well well-lg"> Calculation precision value: <input type="text" class="form-control " value="@Model" id="precisionVal" /> <button type="button" class="btn btn-default" onclick="setCalculationPrecision()">OK</button> </div> </div> </div> <div> <c1-flex-sheet id="formulaSheet" class="flexSheet" calculation-precision="@Model" selection-changed="SetCellContent"> <c1-unbound-sheet name="Formulas" row-count="20" column-count="8"></c1-unbound-sheet> </c1-flex-sheet> </div> </div> |