Free Support Forum - aspose.com

Exception calculating date range

Hi,

I’m trying to calculate the number of days between two dates by taking one date away from another and i get an exception when i recalculate the workbook.

My sheet looks like this:

| a | b | c
| 1 | =(b2-b1)+1 | 21/04/2006 |
| 2 | | 22/04/2006 |

And my code this:

using System;
using System.Data;
using Aspose.Cells;

namespace ConsoleApplication1
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(“C:\Aspose.lic”);

Excel excel = new Excel();
excel.Open(“C:\basic.xls”);

try
{
string val = excel.Worksheets[0].Cells[0,0].Value.ToString(); // this line returns ‘2’
excel.CalculateFormula(false); // this line throws the exception { “Error in calculating cell A1 in Worksheet0” }
Console.WriteLine(val);
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}

I’ve attached my workbook and i’m using the latest version of Aspose.

Any help would be appreciated,

paul

Please try this attached version.

That worked. But, I then wrapped one of the dates in ROUNDDOWN method and i get another exception.

Can this be fixed too?

paul

ROUNDDOWN function is not supported yet. Please check http://www.aspose.com/Products/Aspose.Cells/Api/Aspose.Cells.Excel.CalculateFormula1.html .

We will add it in the future release. It will be available in the next week.