2

In indesign is it possible to automatically round numbers to x decimal places within a table?

2
  • If you know how to write JavaScript, you can definitely whip something up pretty easily.
    – atrnh
    Commented Mar 17, 2015 at 13:59
  • I found a couple scripts like this: indesignsecrets.com/… but I don't know JavaScript unfortunately!
    – PaulBarr
    Commented Mar 17, 2015 at 17:25

2 Answers 2

2

Probably your best bet for this is to create the table in Excel, where you have good control over decimal places, and then link the table from InDesign to your Excel spreadsheet. There are a few things to watch out for in terms of holding your beautiful InDesign formatting, but these are very well explained through this complimentary Lynda tutorial at:

http://www.lynda.com/articles/indesign-secrets-linking-a-table-to-an-excel-spreadsheet-for-easy-updating

0

I used this, not using a table but should work the same.

https://creativepro.com/downloads/number_adjuster_1_2.zip

But it doesn't round up. So...

I edited the "return" line in the block below... Use case was for a restaurant menu. Increase price by 3%, then round up to the nearest 25 cents. Assuming with some fancy math you can do anything here.. I am no programmer, feel like I got lucky with experimenting. The "Math.ceil" rounds up. There are others that round down.

Got more info here https://stackoverflow.com/questions/45453312/math-round-only-up-quarter

Edit code in text editor, then loaded to indesign scripts.

//====================================================\ //Function to round numbers function numRounder(myNumber, myRoundto) { myRoundMod = 1; for(rounding = 0; rounding < myRoundto; rounding++) { myRoundMod = myRoundMod * 10;
} return Math.ceil(4 * myNumber) / 4; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.