Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Feb 12, 2018 9:32 am

Dear Syed,

Thanks for your feedback.
Did you use the latest version as well as the method CalculateAllValue()?
I could get a value(100.60924179573217), yet it is a little different from the correct value. We will look into it and inform you once there is any progress.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Feb 12, 2018 10:25 am

Dear Team,

Kindly find the below code snippet

using System.Drawing;
using Spire.Xls;
using System;
using System.Globalization;

namespace Create_Excel_File
{
class Program

{
static void Main(string[] args)
{
DateTime setl = Convert.ToDateTime("2017-12-30");

DateTime mat = Convert.ToDateTime("2018-08-30");

double cpn = Convert.ToDouble((Convert.ToDecimal(12) / 100));//copRate
double yld = Convert.ToDouble((Convert.ToDecimal(11.95) / 100));
//Initialize a new Workboook object
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xls");
//Get the first worksheet

Worksheet sheet = workbook.Worksheets[0];

//Write string values in a cell

sheet.Range["A1"].Value2 = new DateTime(2017, 12, 30);
sheet.Range["A1"].NumberFormat = "dd/mm/yyyy";
sheet.Range["A2"].Value2 = new DateTime(2018, 08, 30);
sheet.Range["A2"].NumberFormat = "dd/mm/yyyy";
sheet.Range["A3"].NumberValue = cpn;
sheet.Range["A4"].NumberValue = yld;
sheet.Range["A5"].NumberValue = 100;
sheet.Range["A6"].NumberValue = 2;
sheet.Range["A7"].NumberValue = 1;

try

{
workbook.CalculateAllValue();
Console.WriteLine(workbook.ActiveSheet.GetFormulaNumberValue(8,1));
}

catch (Exception ex) {

throw new Exception(ex.Message);
}


}

}

}

i got Nan output.
Regards,
Syed Salahuddin
Attachments
Sample.7z
attached my excel file
(4.9 KiB) Downloaded 227 times

syed7866
 
Posts: 6
Joined: Thu Feb 08, 2018 9:04 am

Mon Feb 12, 2018 11:14 am

Dear Team,
Kindly share the code snippet you are using.Bucz i got NaN as output.


Regards,
Syed Salahuddin

syed7866
 
Posts: 6
Joined: Thu Feb 08, 2018 9:04 am

Tue Feb 13, 2018 6:30 am

Dear Team,
Kindly share the code you r using to get (100.60924179573217) as price output.


Regards,
Syed Salahuddin

syed7866
 
Posts: 6
Joined: Thu Feb 08, 2018 9:04 am

Tue Feb 13, 2018 6:44 am

Dear Syed,

Thanks for sharing.
Here is my testing project, please download and run it on your side.
http://www.e-iceblue.com/downloads/attachment/12916.zip
I could get a value, and I attached a screenshot in the package. As for the result, inevitably there is a little bit deviation on the accuracy when calculating the double.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Feb 15, 2018 9:51 am

Hello,

How did the project provided by Betsy run on your side? Can you get the correct value in this project?
Thanks in advance for your valuable feedback and time.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Mar 15, 2018 8:03 am

Dear Syed,

Glad to inform you that the deviation issue has been fixed in Spire.XLS Pack(Hotfix) Version:8.3.5. Now you could get the exact value like Excel get.
Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS