Free Support Forum - aspose.com

About a function supported in CalculateFormula Method

Hello.
Please teach it again.

I do not work by a function supported in CalculateFormula Method normally?
Would you teach it?

Excel excel = new Excel();

Worksheet sheet = excel.Worksheets[0];
sheet.Name = "Sheet1";

sheet.Cells[0,0].Formula = "=YEAR(2005)";
sheet.Cells[0,1].Formula = "=MONTH(12)";
sheet.Cells[0,2].Formula = "=DAY(24)";

sheet.Cells[1,0].Formula = "=DATE(A1,B1,C1)";

excel.CalculateFormula();

Console.WriteLine(sheet.Cells[0,0].StringValue);
Console.WriteLine(sheet.Cells[0,1].StringValue);
Console.WriteLine(sheet.Cells[0,2].StringValue);
Console.WriteLine(sheet.Cells[1,0].StringValue);

The output on the console is:

1905
VSX9llyJqxvIIGMrZA
24
#VALUE!

Why will not it be output as follows?
2005
12
24
2005/12/24 0:00:00


daimaru(japan)
I translate this sentence by translation software

Please try this attached fix.

The output should be same as MS Excel:

1905

1

24

1905-12-24 0:00:00

In previous version:

1905
VSX9llyJqxvIIGMrZA
24
#VALUE!

The second line of garbage text is an evaluation limitation and the fourth is a bug.

Please try this attached fix with the following sample code:

Excel excel = new Excel();

Worksheet sheet = excel.Worksheets[0];
sheet.Name = "Sheet1";

sheet.Cells[0,0].Formula = "=YEAR(2005)";
sheet.Cells[0,1].Formula = "=MONTH(12)";
sheet.Cells[0,2].Formula = "=DAY(24)";

sheet.Cells[1,0].Formula = "=DATE(A1,B1,C1)";

sheet.Cells[100,100].PutValue(12);

excel.CalculateFormula();

Console.WriteLine(sheet.Cells[0,0].StringValue);
Console.WriteLine(sheet.Cells[0,1].StringValue);
Console.WriteLine(sheet.Cells[0,2].StringValue);
Console.WriteLine(sheet.Cells[1,0].StringValue);

Thank you.
I worked well. Yes [Y]
Flexibility such as your company has not watched a certain correspondence till now, and I think very favorably.Smile [:)]

Hello.
It is one step more, but I want to increase only 1st on the date that I led by a DATE function, but do not work by this program.
Will there be measures method?

Excel excel = new Excel();
excel.Open(@"C:\TEMP.XLS");
Worksheet sheet = excel.Worksheets[0];
DateTime dt = new DateTime(2005,12,24);
sheet.Cells[1,1].PutValue(dt);
sheet.Cells[0,0].Formula = "=YEAR(B2)";
sheet.Cells[0,1].Formula = "=MONTH(B2)";
sheet.Cells[0,2].Formula = "=DAY(B2)";

sheet.Cells[1,0].Formula = "=DATE(A1,B1,C1)";
sheet.Cells[1,2].Formula = "=B1+1";

excel.CalculateFormula();

Console.WriteLine(sheet.Cells[1,0].StringValue);
Console.WriteLine(sheet.Cells[1,2].StringValue);

The output on the console is:

2005/12/24 0:00:00
#VALUE!


Why will not it be output as follows?
2005/12/24 0:00:00
2005/12/25 0:00:00


daimaru(japan)
I translate this sentence by translation software