You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

Export Part of spreadsheet to csv

Is it possible to export part of a spreadsheet to csv (or any other format) please?

MacBook Pro 13″, macOS 12.2

Posted on Jan 27, 2022 3:58 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 27, 2022 8:10 AM

gerrynuk wrote:

I'll have a look at the AppleScript


If you're on Monterey on the Mac or on iOS then the Shortcuts App allows you to do this much more easily than with an AppleScript.


Launch Shortcuts and drag in a Get Clipboard, Set variable, Replace and Copy actions and set up as shown, making sure Regular Expression is checked:




Then select the relevant cells in your table and command-c to copy to the clipboard.



Click the triangle run button in Shortcuts.


Click wherever you want and command-v to paste the results. I clicked in a text box beneath the original table and pasted, giving this:




You can tell Shortcuts App to save the results as a file if that is easier than pasting.


You can give your Shortcut a name and save it for reuse. Via the File menu in Shortcuts App you can even add it to the Dock if you want for easy access.


SG


(P.S. Forgive typos resulting in misspelling of Stalbridge and Hertfordshire).

11 replies
Question marked as Top-ranking reply

Jan 27, 2022 8:10 AM in response to gerrynuk

gerrynuk wrote:

I'll have a look at the AppleScript


If you're on Monterey on the Mac or on iOS then the Shortcuts App allows you to do this much more easily than with an AppleScript.


Launch Shortcuts and drag in a Get Clipboard, Set variable, Replace and Copy actions and set up as shown, making sure Regular Expression is checked:




Then select the relevant cells in your table and command-c to copy to the clipboard.



Click the triangle run button in Shortcuts.


Click wherever you want and command-v to paste the results. I clicked in a text box beneath the original table and pasted, giving this:




You can tell Shortcuts App to save the results as a file if that is easier than pasting.


You can give your Shortcut a name and save it for reuse. Via the File menu in Shortcuts App you can even add it to the Dock if you want for easy access.


SG


(P.S. Forgive typos resulting in misspelling of Stalbridge and Hertfordshire).

Jan 27, 2022 5:02 AM in response to gerrynuk

Given that you are talking exporting to CSV, I will assume "part of a spreadsheet" means a single table or part of a table.


  1. Select the table or portion of the table
  2. Copy
  3. Create a new blank document
  4. Delete the default table
  5. Paste
  6. Export to the format of your choosing


If you create a truly blank document and save it as a template you use that template each time and skip step 4.


If you want an entire sheet including tables, charts, shapes, etc., then select all those elements in step 1. Formulas that reference cells on other sheets will be replaced with their latest value. Charts that reference values on other sheets will create their own tables.


If "any other format" includes PDF, whatever you can print to paper you can print to PDF instead. So you can create a PDF of a single page that has whatever you have put on it.



Jan 27, 2022 5:45 AM in response to Badunit

Thanks, Badunit. I'm using the spreadsheet as a template for recording family history data. The destination is a free-form text page and the data needs to look something like this, with the template supplying the headings:



If I do a simple cut and paste from the spreadsheet to the free-form text it is saved as an image of the spreadsheet table. So I need a simple way to get the data into CSV format, as above. For some reason it doesn't seem to be possible to export either a single Table or part of a Table in a multi-table spreadsheet.


Your series of steps would work but would be fiddly and time-consuming for the large number of entries needed but I may be able to reduce the number steps required if the spreadsheet has only have one record at a time.


So thanks for your help.

Jan 27, 2022 6:03 AM in response to gerrynuk

Now that I see you data, SGIII's idea ought to work. If you paste into a plain text TextEdit document it will paste as tab separated. You can set TextEdit so it defaults to plain text (in TextEdit Preferences) so you don't have to change from rich to plain each time. Then find/replace the tabs with commas.


There is also an AppleScript that converts the clipboard to text. Then you can skip TextEdit and paste directly into your document then find/replace the tabs there. Or an AppleScript could be written to convert it to text and find/replace tabs so all you would have to do is paste the results. I don't have time to work on it now.

Export Part of spreadsheet to csv

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