Generating a report from data on a Numbers spreadsheet.

How can I create/format a contact info directory based on the data from a spreadsheet?

For example, instead of having Name, Address, Phone, Email as a table I need the following format:

Name and Phone (in one line)

Address and Email (on the following line)

MacBook Pro (13-inch Mid 2012), iOS 9.0.2

Posted on Oct 19, 2015 5:07 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 20, 2015 1:21 PM

If by "report" you mean a listing that you can quickly generate to save or print out, you could do the following to create a TextEdit document like this:


User uploaded file

... from a table like this:

User uploaded file



  1. Copy-paste script below into Script Editor (in Applications > Utilities).
  2. Change column letters in the first line to match the columns your table.
  3. Click somewhere in the table.
  4. Click the triangle 'run' button in Script Editor.


SG




set {namCol, strCol, cityCol, stCol, codeCol, telCol, emailCol} to {"A", "B", "C", "D", "E", "F", "G"}

tell application "Numbers"

tell front document to tell active sheet

tell (first table whose selection range's class is range)

set theRpt to ""

repeat with i from header row count + 1 to row count

if column namCol's cell i's value is not missing value then

set theRpt to theRpt & ¬

column namCol's cell i's value & " " & ¬

column telCol's cell i's value & return & ¬

column strCol's cell i's value & ", " & ¬

column cityCol's cell i's value & " " & ¬

column codeCol's cell i's value & " " & ¬


columnemailCol'scelli'svalue & return & return

end if

end repeat

end tell

end tell

end tell


tell application "TextEdit"


activate

set newDoc to makenewdocument

set newDoc'stext to theRpt

end tell

3 replies
Question marked as Top-ranking reply

Oct 20, 2015 1:21 PM in response to VivianeR

If by "report" you mean a listing that you can quickly generate to save or print out, you could do the following to create a TextEdit document like this:


User uploaded file

... from a table like this:

User uploaded file



  1. Copy-paste script below into Script Editor (in Applications > Utilities).
  2. Change column letters in the first line to match the columns your table.
  3. Click somewhere in the table.
  4. Click the triangle 'run' button in Script Editor.


SG




set {namCol, strCol, cityCol, stCol, codeCol, telCol, emailCol} to {"A", "B", "C", "D", "E", "F", "G"}

tell application "Numbers"

tell front document to tell active sheet

tell (first table whose selection range's class is range)

set theRpt to ""

repeat with i from header row count + 1 to row count

if column namCol's cell i's value is not missing value then

set theRpt to theRpt & ¬

column namCol's cell i's value & " " & ¬

column telCol's cell i's value & return & ¬

column strCol's cell i's value & ", " & ¬

column cityCol's cell i's value & " " & ¬

column codeCol's cell i's value & " " & ¬


columnemailCol'scelli'svalue & return & return

end if

end repeat

end tell

end tell

end tell


tell application "TextEdit"


activate

set newDoc to makenewdocument

set newDoc'stext to theRpt

end tell

Oct 20, 2015 6:10 AM in response to VivianeR

You can do something like this:

User uploaded file


select cell E2 then double click the cell, then type (or copy and paste from here) the formula:

=A2&" "&C2&"
"&B2&" "&D2

shorthand is:

E2=A2&" "&C2&"
"&B2&" "&D2


If you are typing, please note....

There is a special character between the double quotes that appear empty..

C2&""&B2

when you type this, type it like this:

=A2&" "&C2&"


now hold the option key and type the return key (this enters a new line in the cell)


now finish typing:

"&B2&" "&D2


when entered in the cell it should appear like this:

User uploaded file



now you can fill down by selecting cell E2 (just single click this time), copy

now select cells E2 thru the end of column E, paste

Oct 20, 2015 8:52 AM in response to VivianeR

Hi VivianeR,


If you mean a "report" as data for a single person, try this as a way to pull details for a name from Table 1 into another table (Report)

User uploaded file

In the Report table:

Type a name into Cell A1


Formula in A2 (address)

=INDEX(Table 1::B,MATCH(A1,Table 1::A,0))


Formula in B1 (phone)

=INDEX(Table 1::C,MATCH(A1,Table 1::A,0))


Formula in B2 (email)

=INDEX(Table 1::D,MATCH(A1,Table 1::A,0))


Regards,

Ian.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Generating a report from data on a Numbers spreadsheet.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.