Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
DataTableBuilder
Erstellt DataTable-Objekte. Um eine Datentabelle zu erstellen, müssen Sie zuerst die Spalten angeben und dann die Zeilen nacheinander hinzufügen. Beispiel:
Fügen Sie der Datentabelle eine Spalte hinzu. Die Spalten werden von 0 bis n hinzugefügt.
Die erste Spalte wird in Diagrammen häufig für Labels verwendet, z. B. X‑Achsenlabels in Liniendiagrammen oder Segmentlabels in Kreisdiagrammen. Die anderen Spalten werden häufig für Daten verwendet und erfordern daher oft numerische Werte.
Error – wenn die Datentabelle leer oder anderweitig fehlerhaft ist
setValue(row, column, value)
Legt einen bestimmten Wert in der Tabelle fest.
Sie können einen Wert festlegen, bevor Sie die Spalte der Datentabelle hinzufügen. Wenn die Spalte jedoch nicht hinzugefügt wird, wird der Wert ignoriert.
Nicht alle Spaltenwerte müssen ausgefüllt werden. Fehlende Werte werden als null betrachtet.
Parameter
Name
Typ
Beschreibung
row
Integer
den Zeilenindex (die erste Zeile hat den Index 0)
column
Integer
den Spaltenindex (die erste Spalte hat den Index 0)
value
Object
den Wert der Tabellenzelle (muss den richtigen Typ für die Spalte haben).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003eDataTableBuilder facilitates the creation of DataTable objects by defining columns and adding rows sequentially.\u003c/p\u003e\n"],["\u003cp\u003eColumns are defined using \u003ccode\u003eaddColumn\u003c/code\u003e with specified data type and label, and rows are added using \u003ccode\u003eaddRow\u003c/code\u003e with corresponding values.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ebuild\u003c/code\u003e method finalizes the DataTable construction and returns the resulting object.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esetValue\u003c/code\u003e allows modification of individual cell values within the table by specifying row, column, and the new value.\u003c/p\u003e\n"],["\u003cp\u003eDataTableBuilder uses a chaining pattern, where method calls can be linked for streamlined table construction.\u003c/p\u003e\n"]]],[],null,["DataTableBuilder\n\nBuilder of DataTable objects. Building a data table consists of first specifying its columns, and\nthen adding its rows, one at a time. Example:\n\n```javascript\nconst data = Charts.newDataTable()\n .addColumn(Charts.ColumnType.STRING, 'Month')\n .addColumn(Charts.ColumnType.NUMBER, 'In Store')\n .addColumn(Charts.ColumnType.NUMBER, 'Online')\n .addRow(['January', 10, 1])\n .addRow(['February', 12, 1])\n .addRow(['March', 20, 2])\n .addRow(['April', 25, 3])\n .addRow(['May', 30, 4])\n .build();\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------|-------------------------------------------------------|-------------------------------------|\n| [addColumn(type, label)](#addColumn(ColumnType,String)) | [DataTableBuilder](#) | Adds a column to the data table. |\n| [addRow(values)](#addRow(Object)) | [DataTableBuilder](#) | Adds a row to the data table. |\n| [build()](#build()) | [DataTable](/apps-script/reference/charts/data-table) | Builds and returns a data table. |\n| [setValue(row, column, value)](#setValue(Integer,Integer,Object)) | [DataTableBuilder](#) | Sets a specific value in the table. |\n\nDetailed documentation \n\n`add``Column(type, label)` \nAdds a column to the data table. Columns will be added from 0 to n.\n\nThe first column is often used by charts for labels (for instance, X-axis labels on line\ncharts, or slice labels in pie charts). The other columns are often used for data and therefore\noften require numeric values.\n\nParameters\n\n| Name | Type | Description |\n|---------|---------------------------------------------------------|------------------------------------------------------|\n| `type` | [ColumnType](/apps-script/reference/charts/column-type) | type of data in the column (number, string, or date) |\n| `label` | `String` | label of the column (it's used for chart legends). |\n\nReturn\n\n\n[DataTableBuilder](#) --- this builder, for chaining.\n\n*** ** * ** ***\n\n`add``Row(values)` \nAdds a row to the data table.\n\nParameters\n\n| Name | Type | Description |\n|----------|------------|-------------------------------------------------------------------------------|\n| `values` | `Object[]` | values for the row, specified in the same order that the columns are entered. |\n\nReturn\n\n\n[DataTableBuilder](#) --- this builder, for chaining.\n\n*** ** * ** ***\n\n`build()` \nBuilds and returns a data table.\n\nReturn\n\n\n[DataTable](/apps-script/reference/charts/data-table) --- the data table\n\nThrows\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the data table is empty or otherwise malformed\n\n*** ** * ** ***\n\n`set``Value(row, column, value)` \nSets a specific value in the table.\n\nYou may set a value before adding the column to the data table. However, unless the column\nis added at some point, the value will be ignored.\n\nNot all column values need to be filled in. Those missing will be considered `null`.\n\nParameters\n\n| Name | Type | Description |\n|----------|-----------|--------------------------------------------------------------------------|\n| `row` | `Integer` | the row index (the first row has index 0) |\n| `column` | `Integer` | the column index (the first column has index 0) |\n| `value` | `Object` | the value of the table cell (should have the right type for the column). |\n\nReturn\n\n\n[DataTableBuilder](#) --- this builder, for chaining"]]