Wolfram Research

Function Repository Resource:

CopyAsExcelData (1.0.0) current version: 2.0.0 »

Source Notebook

Copy a list to the clipboard in a format that can be pasted directly into a spreadsheet

Contributed by: Sjoerd Smit  |  Sjoerd Smit

ResourceFunction["CopyAsExcelData"][list]

copies list to the clipboard in plain-text (TSV) form so that it can be pasted into Excel and most other spreadsheets.

Details

ResourceFunction["CopyAsExcelData"] will copy the input data to the clipboard and also return the copied data as a string. This string can be copied from the output cell later again with the Copy As Plain Text functionality.
The copied string is in Tab-Separated-Value (TSV) format.
ResourceFunction["CopyAsExcelData"][list] attempts to clean up elements in list such as DateObjects by converting them to strings. It then uses ExportString[, "Table"] to convert the result to plain-text.
ResourceFunction["CopyAsExcelData"] only accepts lists that can be interpreted as 2D arrays.

Examples

Basic Examples (2) 

Copy an array of random numbers:

In[1]:=
SeedRandom[1];
ResourceFunction["CopyAsExcelData"][RandomInteger[10, {5, 10}]]
Out[2]=

Go into Excel or any other spreadsheet application and paste the values:

To copy the data (again) from the output cell, use the Copy As -> Plain Text functionality:


Flat lists and ragged arrays also work:

In[3]:=
ResourceFunction["CopyAsExcelData"][Range[10]]
Out[3]=
In[4]:=
ResourceFunction["CopyAsExcelData"][Range /@ Range[5]]
Out[4]=

Scope (1) 

Any element that is not a number or a string will be converted to a String:

In[5]:=
ResourceFunction[
 "CopyAsExcelData"][{1, "Hello", Now, Today, TimeObject[], Quantity[1, "USDollars"]}]
Out[5]=

Version History

  • 2.0.0 – 29 July 2022
  • 1.0.0 – 19 July 2022

Related Resources

License Information