Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Save or export Numbers table to HTML

I'm wondering if there is a way to save a Numbers table to HTML such that I can view the table using Safari.

I'm using Numbers 5.1 and OS 10.13.6.

Thank you.

MacBook Pro (Retina, 15-inch, Mid 2015), macOS High Sierra (10.13.6)

Posted on Aug 31, 2018 6:06 AM

Reply
Question marked as Best reply

Posted on Aug 31, 2018 6:52 AM

Hi vjb, there are a number of ways to do that.


(1) You could take a screenshot of your spreadsheet, and save it as an image. Safari can easily display images.


(2) You could do File > Export to ... PDF. Safari easily displays PDF files.


(3) You could do File > Export to ... Excel. Then, open the doc with Excel (if you have Excel), and Export to a web page from there.


(4) You could do File > Export to ... CSV. Then use any of the widely-available tools to convert CSV files to HTML. (Google "csv to html").

5 replies
Question marked as Best reply

Aug 31, 2018 6:52 AM in response to vjb1976

Hi vjb, there are a number of ways to do that.


(1) You could take a screenshot of your spreadsheet, and save it as an image. Safari can easily display images.


(2) You could do File > Export to ... PDF. Safari easily displays PDF files.


(3) You could do File > Export to ... Excel. Then, open the doc with Excel (if you have Excel), and Export to a web page from there.


(4) You could do File > Export to ... CSV. Then use any of the widely-available tools to convert CSV files to HTML. (Google "csv to html").

Aug 31, 2018 6:40 PM in response to vjb1976

A short script like the one below can export a basic html table without special formatting. (Maybe Jason can introduce some formatting).


  1. Copy-paste script into Script Editor (in Applications > Utilities)
  2. Make sure Script Editor is listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.
  3. Click once in the Numbers table you want to export and then click the 'run' button in Script Editor.


SG




# get the data from a Numbers table

tell application "Numbers"

tell front document's active sheet

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

set tableData to rows'scells'sformatted value

end tell

end tell

end tell


# place the data in html tags

set tableHtml to "<table>" & return

set text item delimiters to "</td><td>"

repeat with r from 1 to (count tableData)

set tableHtml to tableHtml & "<tr><td>" & (tableData's item r as text) & "<td></tr>" & return

end repeat

set tableHtml to tableHtml & "</table>"


# save the html to a file

set oFile to (choose file namewith prompt "Save As File" default name "My File.html" default locationpath todesktop) as text

set f to open for accessoFile with write permission

set eoffto 0

write tableHtml to f as «class utf8»

close accessf

Aug 31, 2018 6:42 PM in response to vjb1976

Thank you to all who responded. My reason for wanting to do this is to have a table of hyperlinks as a home page. I was doing that with Excel but I abandoned that when Microsoft went to Office 365. I did try saving my spreadsheet to PDF and opened it in Safari. The hyperlinks were preserved so that really did the trick!

I thought I was going to have to finally break down and learn HTML. 😁

Sep 5, 2018 5:23 PM in response to SGIII

SG, Yours is much cleaner than mine. I don't understand how the item delimiter works well enough to make something that concise, I went with much more linear code. (oh and I can't seem to get my code to paste from the script editor correctly into this editor area)


tell application "Numbers"

activate


try

if not (exists document 1) then error number 1000

tell document 1

try

tell active sheet

set the selectedTable to ¬

(the first table whose class of selection range is range)

end tell

on error

error number 1001

end try

tell active sheet

tell selectedTable

set myhtml to "<Table border=\"1\">" & return

repeat with curRow from 1 to the count of rows

set myhtml to myhtml & " <TR>" & return

tell row curRow

repeat with curCell from 1 to count of columns

if (the value of cell curCell) is missing value then

set MyCellValue to ""

else

set MyCellValue to the value of cell curCell

end if

set myhtml to myhtml & " <td>" & MyCellValue & "</td>" & return

end repeat

end tell

set myhtml to myhtml & " </TR>" & return

end repeat

set myhtml to myhtml & "</table>"

end tell

make new text item with properties {object text:myhtml}

end tell

end tell

end try


end tell

Save or export Numbers table to HTML

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