EXCEL的CUMIPMT功能的数学公式是什么(如何计算)? 我想用数学方法计算它。 请帮忙
答案 0 :(得分:3)
在Excel中实现CUMIPMT
是不可能的,因为Excel不是开源的。
然而,Google搜索中出现了大量结果,例如Javascript中的this implementation,Javascript中的this other implementation或PHP中的PHPExcel's implementation。
最接近的结果可能是查看Open Office的C ++实现 - 这与Excel的实现非常接近或相同。
它可以在Github
上的OpenOffice存储库中找到double SAL_CALL AnalysisAddIn::getCumipmt( double fRate, sal_Int32 nNumPeriods, double fVal,
sal_Int32 nStartPer, sal_Int32 nEndPer, sal_Int32 nPayType ) THROWDEF_RTE_IAE
{
double fRmz, fZinsZ;
if( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0.0 || nEndPer > nNumPeriods || nNumPeriods <= 0 ||
fVal <= 0.0 || ( nPayType != 0 && nPayType != 1 ) )
THROW_IAE;
fRmz = GetRmz( fRate, nNumPeriods, fVal, 0.0, nPayType );
fZinsZ = 0.0;
sal_uInt32 nStart = sal_uInt32( nStartPer );
sal_uInt32 nEnd = sal_uInt32( nEndPer );
if( nStart == 1 )
{
if( nPayType <= 0 )
fZinsZ = -fVal;
nStart++;
}
for( sal_uInt32 i = nStart ; i <= nEnd ; i++ )
{
if( nPayType > 0 )
fZinsZ += GetZw( fRate, double( i - 2 ), fRmz, fVal, 1 ) - fRmz;
else
fZinsZ += GetZw( fRate, double( i - 1 ), fRmz, fVal, 0 );
}
fZinsZ *= fRate;
RETURN_FINITE( fZinsZ );
}
答案 1 :(得分:0)
完整的OpenOffice公式根据Daniel的建议转换为C#:
function dranges = yyyyqq_range(dateStart, dateEnd)
% initiates a list of the date ranges
dates = (dateStart:dateEnd)';
datesstr = cellstr(datestr(dates,'yyyyqq'));
datesstr = strrep(datesstr,'Q1','01');
datesstr = strrep(datesstr,'Q2','02');
datesstr = strrep(datesstr,'Q3','03');
datesstr = strrep(datesstr,'Q4','04');
datesnumb = str2double(datesstr);
dranges = unique(datesnumb);
end