A
Ali
Dear Excel Guruz..
I have to calculate Yield using excel yield function in my C# program.In
order to do that I have import
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
and write yield calcuation function . My function work fine for office 2007
but onces I unistall 2007 , my code stopped wokring on any perivious version.
What I have observed my last line i.e used to calculate yield has problem
result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");
even though I change my dates arguments , though nothing happens in result.
Help me in this regards
// ***********************Code*********************************
Excel.Application xl = new Excel.Application();
Excel.WorksheetFunction wsf = xl.WorksheetFunction;
string satelmentdt = dtsatelment.Value.ToString();
string maturitydt = dtmaturity.Value.ToString();
dtobjectsatelemnt = DateTime.Parse(satelmentdt.ToString());
dtobjectmaturity = DateTime.Parse(maturitydt.ToString());
days = (dtobjectsatelemnt - startdt).Days;
days1 = (dtobjectmaturity - startdt).Days;
days = days + 2;
days1 = days1 + 2;
string rate = this.rate.Text;
double par = double.Parse(this.par.Text.ToString());
double redumptation =
double.Parse(this.redemption.Text.ToString());
string facevalue = "100";
string frequency = "2";
string basis = "1";
object result;
result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");
result.Text = result.ToString();
I have to calculate Yield using excel yield function in my C# program.In
order to do that I have import
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
and write yield calcuation function . My function work fine for office 2007
but onces I unistall 2007 , my code stopped wokring on any perivious version.
What I have observed my last line i.e used to calculate yield has problem
result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");
even though I change my dates arguments , though nothing happens in result.
Help me in this regards
// ***********************Code*********************************
Excel.Application xl = new Excel.Application();
Excel.WorksheetFunction wsf = xl.WorksheetFunction;
string satelmentdt = dtsatelment.Value.ToString();
string maturitydt = dtmaturity.Value.ToString();
dtobjectsatelemnt = DateTime.Parse(satelmentdt.ToString());
dtobjectmaturity = DateTime.Parse(maturitydt.ToString());
days = (dtobjectsatelemnt - startdt).Days;
days1 = (dtobjectmaturity - startdt).Days;
days = days + 2;
days1 = days1 + 2;
string rate = this.rate.Text;
double par = double.Parse(this.par.Text.ToString());
double redumptation =
double.Parse(this.redemption.Text.ToString());
string facevalue = "100";
string frequency = "2";
string basis = "1";
object result;
result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");
result.Text = result.ToString();