Rev | Line | |
---|
[12074] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
| 6 |
|
---|
| 7 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions.Math
|
---|
| 8 | {
|
---|
| 9 | public class Rand : ExcelFunction
|
---|
| 10 | {
|
---|
| 11 | private static int Seed
|
---|
| 12 | {
|
---|
| 13 | get;
|
---|
| 14 | set;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
| 18 | {
|
---|
| 19 | Seed = Seed > 50 ? 0 : Seed + 5;
|
---|
| 20 | var val = new Random(System.DateTime.Now.Millisecond + Seed).NextDouble();
|
---|
| 21 | return CreateResult(val, DataType.Decimal);
|
---|
| 22 | }
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.