最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to convert the Excel formula into javascript - Stack Overflow

programmeradmin1浏览0评论

I have the formula in the excel sheet like

=IF($F6=0,"",IF(I6=0,"",$F6/I6))

where F6=7000; I6="";

The excel result is showing no data for the Formula, now in javascript I need to convert.

 function AB6(F6)
 {
     var AB6="";         
     if(F6==0)
          AB6='data';
          alert("Data: "+AB6);  
     if(I6==0)
    {    
             AB6="";         
             AB6=F6/I6;
             alert(AB6);             
     }

     return AB6;
 }

is this a right function in javascript for the below formula.

I have the formula in the excel sheet like

=IF($F6=0,"",IF(I6=0,"",$F6/I6))

where F6=7000; I6="";

The excel result is showing no data for the Formula, now in javascript I need to convert.

 function AB6(F6)
 {
     var AB6="";         
     if(F6==0)
          AB6='data';
          alert("Data: "+AB6);  
     if(I6==0)
    {    
             AB6="";         
             AB6=F6/I6;
             alert(AB6);             
     }

     return AB6;
 }

is this a right function in javascript for the below formula.

Share Improve this question asked Oct 23, 2013 at 11:43 NavyahNavyah 1,68011 gold badges33 silver badges59 bronze badges 3
  • 1 Please don't write in ALL CAPS, it's hard to read. – user9876 Commented Oct 23, 2013 at 11:45
  • 1 there are lot of converters available. Make use of them.excelformulabeautifier. – The Hungry Dictator Commented Oct 23, 2013 at 11:48
  • I dont want a conevrt if just giving if condition, i want result for that if condition – Navyah Commented Oct 23, 2013 at 11:58
Add a ment  | 

1 Answer 1

Reset to default 2

No. The I6 parison in excel is only executed when the F6 parison failed. Even more, there is never an else part in your javascript...

This is the javascript equivalent:

if (F6 == 0) {
    AB6="";
} else {
    if (I6 == 0) {
        AB6 = "";
    } else {
        AB6 = F6/I6;
    }
}
发布评论

评论列表(0)

  1. 暂无评论