Excell Formulas to Javascript

I just got a request to convert an Excel file to PDF, and make the form calculate.  The calculations are pretty complex (at least to me they are).  There are four different types of formulas needed.  I've copied the information below.  Can someone help me with writing the scripts for PDF that would accomplish what the Excel formulas do?  I don't even know if it's possible to do and where to start.
Thanks
Connie Bretes
Break Date:
=IF(A20>0,$A$3+D20," ")
If there is a tag number entered for the corresponding row, the equation will take the date cast and add the number of days until it's break, and give the date of the break. If no tag number (or any form of ID)
is entered into the tag number cell, a blank cell will be shown.
Correction Factor (C.F.):
=IF(N20>0,LOOKUP('Correction Factor'!A3,'Correction Factor'!$C$3:$C$104,'Correction Factor'!$D$3:$D$104)," ")
If there is a number entered in the corresponding Total Load cell, the equation will look up the correction factor value from the list in the correction factor tab based on the length and diameter ratio calculated in column A in the Correction Factor Tab, and give the proper correction factor.  If no total load value is given, a blank cell will be shown.
P.S.I.
=IF(N20>0,ROUND(((N20/(3.1415926535*((L20/2)^2)))*M20),-1)," ")
If there is a number entered in the corresponding Total Load cell, the equation will solve (total load) / (pi * (diameter / 2)^2) to get PSI, and then multiply by the corresponding Correction factor to give it the appropriate PSI value.  The round function then rounds it to the nearest 10 value.  If no total load value is given, a blank cell will be shown.
Average:
=IF(N20>0,ROUND(AVERAGE(O20:O21),-1)," ")
If there is a number entered in the corresponding Total Load cell, the equation will average the values of the 2 breaks for the cylinders cast for that day and round to the nearest 10 value. If no load value is given, a blank cell will be shown.

First there is no direct conversion from Excel formulas to Acrobat's JavaScript. You need to know that even the simplified field notation and the field selection for some calculations both use JavaScript behind the scenes to perform the calculation.
There is no easy date calculation like in Excel in JavaScript, you need to write custom JavaScript to convert the date string to a date object and then convert the date object to a date unit value and perform your calculation and then convert the result back to the date object for conversion to a string value. The format of the date strings is very important for these conversions.
You also need to be aware that JavaScript's use of the IEEE floating point standard for decimal numbers introduces an error when using JavaScript's Math.round method so you need to create rounding function. JavaScript's Math.round method only works for integers.
You might want to start with the tutorials at the http://acrobatusers.com/tutorials
or www.pdfscripting.com

Similar Messages

  • Converting excel formulas to javascripts

    Hello, I am not experience in Excel formulas and creating "if" statements in Adobe Acrobat, so I'm hoping someone can help me with this. I have two problems.
    1.  Here is an excel formula that I need to convert over to javascripts. Can someone help with this?
    =IF(Q13>0,Q13+0,"")
    2.  Here is the second one,
    =IF(N16*Q16>0,((N16*Q16)+U16),"")
    In addition to these two formulas I need help with, the owner of the forms does not want the numbers to round up. Is there a way to get the exact answer and not rounding the numbers up in javascript?
    Thanks for your assistance.
    I have Adobe Acrobat X.

    Hi George, on the first script
    var Q13 = +getField("Q13").value;
      event.value = Q13 > 0 ? Q13, "";
    It comes up with a SyntaxError: missing : in conditional express 2: at line 3
    Do you know what that means and how to correct?
    Thanks
    Connie

  • I need help converting an excel formula to javascript for a fillable form.

    Here is the scenario,
    If a person travels for 1 or 2 days we pay out a mealsrate of 75% per day. If 3 or more days we pay # days less 2 days * 25%. I hope that makes sense.
    V7 = Days, F14 = Mealsrate
    Formula in Excel
    =IF($V$7 = 1,$F$14*0.75,($V$7*$F$14)-(($F$14*0.25)*2))  and it works.
    I am VERY NEW to javascript (like yesterday) so don't laugh. I really have no idea what I am doing, but I was trying. Here is what i got. (by the way, It doesn't work)
    if(this.getField( ("Days").value=="1")){
    var f =this.getField("Mealsrate");
    event.value= f.value * .75;
    }else event.value = (Days * f.value)- (f.value *.25)*2;
    I appreciate all the help i can get.
    Tracie
    I'll be back on Monday, I hope I can find my post.

    OK, that Excel formula can be reduced a bit. The following custom Calculate scipt will do what the formula does:
    // Custom Calculate script
    (function () {
        // Get the inputs
        var days = getField("Days").value;
        var rate = getField("Mealsrate").value;
        // Set this field value
        if (days == 1) {
            event.value = 0.75 * rate;
        } else {
            event.value = (days - 0.5) * rate;
    It would make sense to add additional code to deal with negative numbers in either of the input fields.
    Edit: corrected a typo

  • How to convert an Excel Formula to a Custom Calculation Script in a Adobe Acrobat 9 Form?

    Hello,
    I am not familiar whatsoever with Javascript and need some help in converting the following Excel Formula so that I can enter it into a Custom Calculation Script in a Adobe PDF Form. Here is the formula:
    =IF(E15<25.01,9.95,IF(E15<50.01,11.95,IF(E15<75.01,13.95,IF(E15<100.01,16.95,IF(E15<150.01 ,19.95,IF(E15<200.01,24.95,IF(E15>200.00,E15*0.125)))))))
    Where "E15" will be the text field named "Subtotal" on my Adobe PDF Form.
    Thank you for any help you can provide!

    Fortunately JavaScript has the 'switch' statement so nested if statements can be avoided.
    var E15 = this.getField("Subtotal").value;
    switch(true) {
    case (E15 < 25.01) :
    event.value = 9.95;
    break;
    case (E15 < 50.01) :
    event.value = 11.95;
    break;
    case (E15 < 75.01) :
    event.value = 13.95;13
    break;
    case (E15 < 100.01) :
    event.value = 16.95;
    break;
    case (E15 < 150.01) :
    event.value = 19.95;
    break;
    case (E15 < 200.01) :
    event.value = 24.95;
    break;
    case (E15 > 200) :
    event.value = E15 * 0.125;
    break;
    default:
    event.value = "";
    break;
    } // end switch;

  • How to use Excell formula's within EVDRE

    Hi,
    we want to built a rather large P&L with time in columns and account and cost center in the rows.
    We would like to insert some subtotals within the P&L strucure using simple excel formula's.
    So we create the P&L structure and leave some empty rows in between, which are filled up with excell formula's. The row key range is adapted, so it does not reference the excell formula's. If we hit refresh workbook, our P&L is ready and displaying the correct data.
    Problem now is if we select 'expand all'. My entire P&L structure is changed and displayes the last section of the row key range several times (as many as we have different row key ranges) ... I've put "noexpand" on all of the dimensions on row and column ...
    So normally does one use the functionality of excell formula's within a EVDRE report?
    D
    solved it

    Hi D
    One way is to switch of the expansions and insert the rows and then have the subtotals. to swith of expansion just edit the cell where you have written the evdre function and then remove the formulas pointing to expand range.
    EVSUB in after range would not work here as the whole range is related to one dimension and it works if we have two dimensions and need subtotals
    Regards
    Harish B K

  • SAP BPC 10.0 NW - Delete excel formulas

    Hello Experts,
    I have both "Keep formula on data" chekboxes selected (inside Edit Report and inside Sheet Options) and in my computer when I refresh the workbook the formulas are not deleted, but in other computers, also with the same version of EPM add-in the formulas are deleted.
    Any ideas?
    Thanks,
    Nadine

    Hello Guys,
    I've tried to put the last 2 options selected as you said Nilanjan but no results.
    Rohit, the report is static. I've created the report with Insert new member functionality and so the values of some cells are coming from input forms and others are just excel formulas. When I open the report in my computer everything works, when I try to open it in other computers the Excel formulas are deleted...
    Do you have any ideia of what is happening?
    Thanks in advance,
    Nadine

  • Numbers Equivalent of Excel Formula for Converting HH:MM:SS to DD:HH:MM:SS

    I am not sure if this has been asked before.
    What would be the Numbers formula for converting HH:MM:SS to DD:HH:MM:SS?  The Excel formula is entering 396:59:45 into a cell and then in another cell is the following =TEXT(A2,"dd:hh:mm:ss").  The A2 is the example cell.

    There is no formula to actually do the conversion. It is a matter setting the cell format. After that all you need to do is add a simple =<cell> formula to get the value in (i.e. - see my previous post), or a formula to add the two values (=A2+A5). Use Duration rather then Time for the cell formats.
    A duration in Numbers for iOS will not appear 10:16:25:03, it will display as 10d 16h 25m 03s. If it is the actual display punctuation you are trying to change, it may be possible using a combination of a Duration and TEXT functions but would be quite lengthy, convoluted, and more trouble than it is worth.

  • Use of Excel Formulas in EVDRE reports

    Dear Freinds,
    I am trying to use excel formulas in EVDER (report).
                                                      2011.MAR
    Account(Base level member)  =SUM(RANGE)
    this at somepaces is working and in some places its  not working. Kindly share the knowldge how to use them in excel

    Hi Vishwanath,
    Whenever we expandan EVDRE report or Input schedule, the formula (if any) in the first cell is applied to the to the other cells as well. Thus in expansion we will loose any formula specified in the other cells.
    If you donot want this to happen, it is better to make the evdre static. This should help you use formulae as required.
    Hope this helps.
    Regards,
    Shoba

  • EvDRE - SortRange - AfterRange - Copy Excel formula

    Hi all,
    In BPC NW 7.5 SP04 I have performed the following actions:
    I have sorted the EvDRE based on some column and added an AfterRange parameter.
    In the AfterRange cells I have entered various Excel formulas as well as evsub.
    The system would copy the Excel formulas to the line with the EV_AFTER and the copy was like standard Excel.
    e.g. - In the AfterRange I would specify cell B2. in B2 I would write the formula A1B1.
    When the EvDRE would run, assume that the after range had to be in cell E16, The value of E16 would be the result of the formula D15+E15.
    This year we have upgraded to SP06. This functionality stopped working. I tackle 2 situations:
    1. If the cell is defined in general format - the system simply copies the result of the formula. In the example above if A1+B1 is 0, I would simply get 0 all over (copy the value and not the formula).
    2. If the cell is defined as TEXT in Excel, the original formula is copied (i.e. in the example above all cells would have the formula A1+B1).
    evsub works as it should.
    Any idea why did this happen? is there a note? does the system now works as it should and I simply enjoyed a bug in SP04?
    Thanks,
    Avihay

    Hi Ethan,
    I have Accounts in Rows and Time in columns. Range E24:E26 is in AfterRange filed on column expansion. 'E24:E26' range adds prior 2 time columns. I want to display this summation on a particular condition, say only if cell D11 = 1. So I wrote a formula in AfterRange field in Column expansion: =IF(D11=1,"E24:E26","") .
    This formula in AfterRage field doesn't work. But if I manually type value 'E24:E26' in that field, it correctly adds up prious 2 time periods. I think the issue is with formatting.
    Thanks, John

  • Retrieving BEx Query Results Area for use in Excel formulas

    Hello,
    I run BEx queries in workbooks and then use Excel formulas ( mostly VLOOKUP(LookupValue, ResultsArea, ColumnReturned,) ) to retrieve certain information from the query ResultsArea.
    ****Problem:
    Depending on the query parameters, the query "Results Area" is larger or smaller.
    ****Non-optimal solution:
    One way to define the  ever changing Excel range occupied by the Results Area is to create an Excel name as:
    QueryRange = OFFSET(QueryFirstCell,,,COUNTA(OFFSET(Sheet1!$A:$A,,COLUMN(QueryFirstCell)-1,,)),COUNTA(OFFSET(Sheet1!$1:$1,ROW(QueryFirstCell)-1,,,)))
    Then, the only input required is the top-left cell of the Results Area, which stays the same (unless the query definition changes).
    ****Question
    What is the best way to refer to an ever-changing query Results Area in an Excel formula?
    Thank you!
    Louis

    It is actually much easier than that.
    Use a VBA statement like the following:
    Set RptRng = ActiveCell.CurrentRegion
    This will retrieve the data in the Results Area, no matter what the size is.
    Hope this helps...
    Bob

  • How do you display excel formulas?

    How do you display EXCEL formulas in Numbers once imported?

    select the cell and look at the bottom of the window or doubel click the cell:
    after double clicking cell:

  • Convert mathematical formulat to excel formula

    I have a formula that was generated by excel when using a trendline on a graph. I need to convert this formula into an excel formula I can use again.
    the formula is below. Assume that the value for X will be in Cell A1. Any help converting this to an excel formula would be awesome. FYI = for a X value of 20,000, the formula should output something close enough to 20,000 ( +- 5 or 10k).
    y = 1.8932x6
    - 116.85x5 + 2669.5x4
    - 27947x3 + 140531x2
    - 298100x + 199955

    Test the result according to the formular that you provide initially and get the result 16993.54 (B2=1) which it is should be.
    =1.8932*B2^6 -116.85*B2^5 +2669.5*B2^4-27947*B2^3+140531*B2^2-298100*B2+199955
    (The fomular you provide last time is different from your initial request.)
    Cheers,
    Tony Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact
    [email protected]

  • Converting Excel formulas in Numbers

    I am new to Numbers and have an Excel Spreadsheet that I've used previously that calculates the best 4 scores from golfers over a 10 week period. In Excel I used =sum(LARGE[e2:n2,{1,2,3,4}]) but when I use it in Numbers I get a Syntax Error message. Is there anyone who can help me convert the Excel formula so that it works in Numbers.

    Numbers does not use excels array functions so this will probably work:
    =SUM(LARGE(E2:N2, 1), LARGE(E2:N2, 2), LARGE(E2:N2, 3), LARGE(E2:N2, 4))

  • How to apply Excel formula in BPS layout

    Hi ,
       I need to apply the following logic in my BPS layout.
    There are three data columns called C,D,E respectivelt
    redord 1   user input data for all the columns,
    Record 2   C2 = D1 + E2.
    Record 3   C3 = D2 + E3.
    Record n   Cn = D(n-1) + En.
      n is the number of record in teh layout.
    1: Can we use Excel formula to achive this?
    2: If the anser is yes, how can we configure the BPS layout? I am not sure if we can do it at the last step of change layout.
    3: If the answer is no, what is the other choice? I have tried to use user exit, but had some problem in passing the data to xth_data table in the orginal order sequence.
    thanks in advance.

    JW,
    please see my answer to your original post "data in BPS layout columns"
    Regards,
    Marc
    SAP NetWeaver RIG

  • Smart View - Excel Formulas

    Hello -
    New to the system, but wanted to know if there's a way to keep Excel formulas after refreshing in SmartView. Appears as though we lose the formulas after clicking the refresh icon.
    Thanks in advance

    We have this issue as well. It has contributed to our startup with Smartview being very poor and given our implementation a bad name. In our experience, Smartview does not deal well with Formulas. We worked around this by using one tab to feed another with the correct formulas. In our experience, Smartview is OK on raw numbers but do not hope or epect it to output fully formatted excel reports.
    In particular, Smartview, at least in our simple implementation, is very poor at mixing Excel formulas into a table.

Maybe you are looking for

  • How can I give me the access to create a developer key in the market?

    Hi! I'm new in the basis area and I don't have access to create a developer key. A consultant need a developer key. How can I give me the access in the market place to create it? Thanks!

  • Ipod Won't Connect To Computer Or Turn Off

    I connected my ipod to my mac and the ipod screen turned to the usual do not connect. But the iPod icon did not show up on the desktop or iTunes menu. I unconnected my iPod and tried to turn it off but it won't. It continued to show the do not discon

  • Why can't i install any updates to pse 10?

    I get an error that says "please close Elements autoanalyzer.exe.  I don't even have it running. Help!

  • Another check box question

    For some reason all my songs have become unchecked. I don't know why. Is there an easy way to recheck them all. Rather than having to click in every box? It seems that because the aren't checked Genius will not recognize them. They were all working u

  • Iphone os 3.1 issues, cause of error !?

    Hello, maybe I am on of a thousound who is experiencing issues for OS 3.1. I've got the frozen iphone problem, when trying to unlock the slider after standby. And just the same for taking calls from standby. Besides, my phone won't suddenly dial out