Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Interface DataTableSource
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
DataTableSource
Interface para objetos que podem representar seus dados como um DataTable.
Implementar classes
| Nome | Breve descrição |
DataTable | Uma tabela de dados a ser usada em gráficos. |
Range | Acessar e modificar intervalos de planilhas. |
Métodos
| Método | Tipo de retorno | Breve descrição |
getDataTable() | DataTable | Retorna os dados dentro desse objeto como uma DataTable. |
Documentação detalhada
getDataTable()
Retorna os dados dentro desse objeto como uma DataTable.
// Opens the spreadsheet file by its ID. If you created your script from a
// Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet().
// TODO(developer): Replace the ID with your own.
const ss = SpreadsheetApp.openById('abc123456');
// Gets Sheet1 by its name.
const sheet = ss.getSheetByName('Sheet1');
// Gets the range A1:B7 on Sheet1.
const range = sheet.getRange('A1:B7');
// Gets the range A1:B7 as a data table. The values in each column must be of
// the same type.
const datatable = range.getDataTable();
// Uses the Charts service to build a bar chart from the data table.
// This doesn't build an embedded chart. To do that, use
// sheet.newChart().addRange() instead.
const chart = Charts.newBarChart()
.setDataTable(datatable)
.setOption('title', 'Your Chart Title Here')
.build();
Retornar
DataTable: os dados como uma tabela de dados.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2026-04-13 UTC.
[null,null,["Última atualização 2026-04-13 UTC."],[],["The `DataTableSource` interface allows objects to represent data as a `DataTable`. It includes the `getDataTable()` method, which returns the object's data in `DataTable` format. Classes like `DataTable` and `Range` implement this interface. The provided example demonstrates retrieving a `Range` from a spreadsheet, converting it to a `DataTable` using `getDataTable()`, and then utilizing this data to construct a bar chart with the Charts service.\n"]]