Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to embed a Google Spreadsheet into a Google Document à la Microsoft Excel and Microsoft Word? How about a chart from a Spreadsheet?

share|improve this question
1  
You can copy and paste a chart from your spreadsheets into a document. No luck with trying to embed the spreadsheet itself though. I have submitted this as a feature request on the Google Group for docs. – mikeschuld May 9 '12 at 20:26
up vote 3 down vote accepted

From today (2016-05-20) on, Google is starting to roll out the ability to embed a chart from a Google spreadsheet into a Google document. At this point, two of my 3 Google accounts make the option available in the Insert menu, with a new Insert→Chart submenu below the Insert→Drawing… item.

When you insert such charts, they remain linked to the original spreadsheet. If all you want is tabular data, there's a table chart type that you can use to present your data as a simple table.

There are some limitations at this stage (e.g. regarding the size of the chart) and the chart must pre-exist in the spreadsheet before you can insert it, but this is going in the right direction…

The chart is not updated live if you modify the source spreadsheet while your document is opened, however, the document will detect changes and offer you to update your chart to reflect the latest changes in the source.

share|improve this answer

AFAIK, you can only copy and paste from the spreadsheet to the text document. The spreadsheet is inserted as a table, but they are not linked: if you change something in the Spreadsheet, it will not get reflected in the text document.

Of course, I'd absolutely love to be proved wrong!

share|improve this answer
1  
Sadly, that does appear my only option at this point. – Al E. Jul 7 '10 at 13:33
    
See my answer below, there's a new option now that makes this a bit friendlier and provides for dynamic updates. – Jean-Rene Bouvier May 20 at 8:44

Here is a script-based solution which allows one to insert a table with the contents from a given range within a given spreadsheet. I did not try to find a way to sync data real-time, as it didn't seem practical given potentially large volume of data that would have to be transferred with every edit to the spreadsheet. Instead, the script adds a custom menu item "update data" to the document.

The script should be bound to the document (i.e., created using Tools > Script Editor in the document menu). The spreadsheet URL, as well as the sheet and range to use, are specified within the script. To embed all the data on the sheet, replace .getRange(rangeName) with .getDataRange().

When the function updateData is first executed, it appends the table at the end of document. At subsequent runs, it updates the table in place (i.e., if more text is added after the table, the order will be preserved).

Note that cutting-pasting the table would break the updating process (the script would add a new table at the end) since the pasted copy is a new object. Instead, cut-paste the text around the table.

function onOpen() {
  DocumentApp.getUi()
             .createMenu('Custom')
             .addItem('Update Data', 'updateData')
             .addToUi();
}

function updateData() {
  var ssUrl = ' spreadsheet url here ';
  var sheetName = 'Sheet2';   // name of sheet to use
  var rangeName = 'A1:C3';    // range of values to include 

  var values = SpreadsheetApp.openByUrl(ssUrl)
                             .getSheetByName(sheetName)
                             .getRange(rangeName)
                             .getValues();
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var ranges = doc.getNamedRanges('embeddedSheet-range');
  if (ranges.length == 0) {
    var table = body.appendTable(values);
  }
  else {
    tableRange = ranges[0];
    table = tableRange.getRange().getRangeElements()[0].getElement();
    var ind = body.getChildIndex(table);
    tableRange.remove();
    body.removeChild(table);
    table = body.insertTable(ind, values);
  }
  var rangeBuilder = doc.newRange();
  rangeBuilder.addElement(table);
  doc.addNamedRange('embeddedSheet-range', rangeBuilder.build());
}

Technical notes

  1. It's also possible to sync the data every hour, in addition to manually. Just add a time-based trigger from Script Editor's Resources menu, so that it runs the function updateData.

  2. One can also adapt this script to be bound to the source spreadsheet instead. This would require changes in how the document is opened (e.g., by URL), but otherwise the logic is the same.

  3. The cumbersome part of the script is getting the handle of the existing table in the document. This requires placing it within a Named Range. Also, it is much more expedient to completely replace the table element than to mess with the entries of an existing table. Since a Named Range is immutable, it is also removed with the table it contains, and then created again, along with the new table.

share|improve this answer
    
Works great. Any way to get formatting (in particular cell background colors)? – cheshirekow May 6 at 15:42
    
NOTE: The 'spreadsheet URL' should apparently contain the full url including the /edit#gid=0 stuff at the end. – cheshirekow May 6 at 15:43
    
There is no way to import the formatting of another spreadsheet. – ᴡᴏʀᴅs May 6 at 15:55
    
Links also aren't transfering over, neither are colors. Is there any way to modify this script to include all the formatting? Very clever work around to the cut-paste issue, worked like a charm! – unc0nnected Jul 2 at 17:34

An alternative is to use Google Sites, or any other content editor that allow embedding iframes content.

To embed Google spreadsheets in a page of Google Sites

  1. Create a new site or go to an existing site.
  2. Create a new page or click on Edit on an existing page.
  3. Click on Insert > Drive > Spreadsheet
  4. Select the spreadsheet
  5. Set the options
  6. Click on Save
share|improve this answer

protected by Community Apr 20 at 19:54

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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