ASP.NET - to calculate financial function[which are available in excel] in .net

Asked By anbu n on 28-Oct-11 03:48 AM
to calculate financial function[which are available in excel] in .net ,

i need to calculate following formulas in asp.net, c#

=-PMT(F15/12,F16*12,F20)*12
=-PV($F$15/12,($F$16-F29)*12,F30/12)
=IRR(E58:J58)
Jitendra Faye replied to anbu n on 28-Oct-11 04:21 AM
Follow these links-

http://www.codeproject.com/KB/cs/pmtapp.aspx
http://archive.msdn.microsoft.com/FinancialFunctions
http://am22tech.com/s/22/Forum1/yaf_postst153_How-to-use-PMT-function-in-C--to-calculate-financial-EMI-value.aspx

Hope this will help you.
smr replied to anbu n on 28-Oct-11 04:41 AM
Hi

ou can try this:

Install the last microsoft office web components.

Add reference to "Microsoft Office Web Componenets".

And use this code:


Microsoft.Office.Interop.Owc11.SpreadsheetClass ws = new Microsoft.Office.Interop.Owc11.SpreadsheetClass();

ws.get_Range("B1","B1").Value2 = 1;
ws.get_Range("B2", "B2").Value2 = 2;
ws.get_Range("B3", "B2").Value2 = 3;
 
ws.get_Range("A1", "A1").Formula = "=SUM(B1:B3)";
double value = (double)ws.get_Range("A1", "A1").Value2;

refer
http://msdn.microsoft.com/en-us/library/dd789430%28v=office.12%29.aspx
http://bytes.com/topic/c-sharp/answers/507275-using-excel-functions-c
http://csharpopensource.com/excelfinancialfunctionsfordotnet.aspx
Anoop S replied to anbu n on 28-Oct-11 04:52 AM
PMT
Returns a Double specifying the payment for an annuity based on periodic, fixed payments and a fixed interest rate.

Function Pmt( _
   ByVal Rate As Double, _
   ByVal NPer As Double, _
   ByVal PV As Double, _
   Optional ByVal FV As Double = 0, _
   Optional ByVal Due As DueDate = DueDate.EndOfPeriod _
) As Double


Rate
    Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
NPer
    Required. Double specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
PV
    Required. Double specifying present value (or lump sum) that a series of payments to be paid in the future is worth now. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
FV
    Optional. Double specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
Due
    Optional. Object of type Microsoft.VisualBasic.DueDate that specifies when payments are due. This argument must be either DueDate.EndOfPeriod if payments are due at the end of the payment period, or DueDate.BegOfPeriod if payments are due at the beginning of the period. If omitted, DueDate.EndOfPeriod is assumed.

http://msdn.microsoft.com/en-us/library/hyd90ysd%28v=vs.71%29.aspx
Anoop S replied to anbu n on 28-Oct-11 04:54 AM
PV Function
Returns a Double specifying the present value of an annuity based on periodic, fixed payments to be paid in the future and a fixed interest rate.
Copy

Function PV( _
   ByVal Rate As Double, _
   ByVal NPer As Double, _
   ByVal Pmt As Double, _
   Optional ByVal FV As Double = 0, _
   Optional ByVal Due As DueDate = DueDate.EndOfPeriod _
) As Double

Parameters

Rate
    Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
NPer
    Required. Double specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
Pmt
    Required. Double specifying payment to be made each period. Payments usually contain principal and interest that doesn't change over the life of the annuity.
FV
    Optional. Double specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
Due
    Optional. Object of type Microsoft.VisualBasic.DueDate that specifies when payments are due. This argument must be either DueDate.EndOfPeriod if payments are due at the end of the payment period, or DueDate.BegOfPeriod if payments are due at the beginning of the period. If omitted, DueDate.EndOfPeriod is assumed.

http://msdn.microsoft.com/en-us/library/0thk570e%28v=vs.71%29.aspx

IRR Function

Returns a Double specifying the internal rate of return for a series of periodic cash flows (payments and receipts).
Copy

Function IRR( _
    ByRef ValueArray() As Double, _
   Optional ByVal Guess As Double = 0.1 _
) As Double

Parameters

ValueArray()
    Required. Array of Double specifying cash flow values. The array must contain at least one negative value (a payment) and one positive value (a receipt).
Guess
    Optional. Object specifying value you estimate will be returned by IRR. If omitted, Guess is 0.1 (10 percent).

http://msdn.microsoft.com/en-us/library/w8h9s5b4%28v=vs.71%29.aspx