1

I have a .numbers file in following format:

Product Quantity Price
Apple   5        3
Banana  7        2
Orange  3        4

I need to get three variables with new-line separated values, e.g. identical to what I entered in script for testing:

set Products to "Apple
Banana
Orange"

set Quantities to "5
7
3"

set Prices to "3
2
4"

At best loading the file with closed Numbers.app, but selecting a range is also OK.

0

In the process of doing this exercise I understood lists are much better for storing read data. So here is the working code:

tell application "Numbers" to tell the front document to tell the active sheet to tell table 1
    repeat with i from 2 to the count of cells of column "A" -- row 1 is a header
        set theProduct to formatted value of cell i of column "A"
        set theQuamtity to formatted value of cell i of column "B"
        set thePrice to formatted value of cell i of column "C"

        set the end of Products to theProduct
        set the end of Quantities theQuantity
        set the end of Prices to thePrice
    end repeat
end tell
  • thanks, fixed the wording here – Pavel Jan 13 at 22:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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