方法为格式化日期,使用的format方法参考
https://blog.csdn/lsfhack/article/details/120605457
1、EOMONTH函数是返回start-date之前或之后指定月份中最后一天的序列号
/**
*Excel中Emonth函数
*/
function Emonth(startDate,Month){
var d = new Date(startDate);
d.setMonth(d.getMonth()+Month+1);
let lastDay = d.setDate(0);
return new Date(lastDay).format("yyyy-MM-dd");
}
2、MOD函数是excel的取模函数,在js里实现比较简单
//obj1 被除数 obj2 除数
function mod(obj1,obj2){
if(obj2>0){
return obj1%obj2;
}else{
return "请输入正确的数字";
}
}
3、NPV 使用贴现率和一系列未来支出(负值)和收益(正值)来计算一项投资的净现值。
function NPV(rate,vals) {
var value = 0;
for (var j = 1; j < vals.length; j++) {
value += vals[j] / Math.pow(1 + rate, j);
}
return value;
}
更多推荐
JS实现Excel公式中的函数【持续更新中】
发布评论