简体   繁体   English

如何将Excel公式转换为javascript

[英]How to convert the Excel formula into javascript

I have the formula in the excel sheet like 我在excel表中有公式

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

where F6=7000; 其中F6 = 7000; I6=""; I6 = “”;

The excel result is showing no data for the Formula, now in javascript I need to convert. excel结果显示公式没有数据,现在我需要转换为javascript。

 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. 对于以下公式,这是javascript中的正确功能。

No. The I6 comparison in excel is only executed when the F6 comparison failed. 不可以.excel中的I6比较仅在F6比较失败时执行。 Even more, there is never an else part in your javascript... else是,你的javascript中从来没有else部分......

This is the javascript equivalent: 这是javascript等价物:

if (F6 == 0) {
    AB6="";
} else {
    if (I6 == 0) {
        AB6 = "";
    } else {
        AB6 = F6/I6;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM