Skip to main content
Participant
Aug 19, 2022 3:35 PM UTC
Question

Excel Formula to Java in PDF Forms

Hi All,

 

This is regarding an IF statement in excel to "translate it" in JavaScript for PDF forms.

I know this kind of question has been addressed so many times, however, all of the questions are with only 1 cell, whereas my case is a bit more complex.

This is the excel function as is:

=IF(B12="Ball",IF(C26=1,20,IF(C26=2,30,(C26-2)*5+40)),IF(B12="Rocket",IF(C26=1,10,IF(OR(C26=2,C26=3),15,20))))

As you can see there are multiple dependent cells and I can't seem to make it work in Java. 

Note: every cell name is a corresponding field in PDF form.

 

Your support will be highly appreciated.

Thank you,

Mihai

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

try67
Community Expert
Community Expert
Aug 19, 2022 7:46 PM UTC
Legend
Aug 19, 2022 5:19 PM UTC

Not Java, JavaScript. This may seem picky, but if you go searching the web for info on Java and Acrobat you will get nothing useful at all. You will need to use getField for each named cell (field). And IF needs to be written as a series of tests, rather than the one IF(cond,yes,no) form.

Translate
Participant
Aug 19, 2022 6:03 PM UTC

Corect, is Java Script, please excuse my typo. I believe it is clear that I have little knowledge on how to script this. I do know the same conditional in excell doesn't work in JavaScript and you have to break it down, I just don't know how as I have no knowledge of JavaScript. My work domain is totally different.

I managed to get the code for only 1 condition, but what I need is a bit more complex, as the result depends on a selection of 2 choices.

Can you help me?

Translate