Content Service
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
תוכן
השירות הזה מאפשר לסקריפטים להציג טקסט בפורמטים שונים, כמו טקסט, XML או JSON. אפשר לעיין גם במדריך ל-Content Service. אם פורסים את הסקריפט הבא כאפליקציית אינטרנט, יופיע הכיתוב 'Hello, world!' בדפדפן:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
שיעורים
שם | תיאור קצר |
ContentService | שירות להחזרת תוכן טקסט מסקריפט. |
MimeType | טיפוס enum של סוגי MIME שאפשר להציג מסקריפט. |
TextOutput | אובייקט TextOutput שאפשר להציג מסקריפט. |
מאפיינים
נכס | סוג | תיאור |
CSV | Enum | סוג ה-MIME של קובץ ה-CSV |
ICAL | Enum | סוג ה-MIME של ICAL |
JAVASCRIPT | Enum | סוג ה-MIME של JAVASCRIPT |
JSON | Enum | סוג ה-MIME של JSON |
TEXT | Enum | סוג MIME של טקסט |
VCARD | Enum | סוג ה-MIME של vCard |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003eThe Content Service enables scripts to serve content like text, XML, or JSON, offering flexibility in data delivery.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the ContentService class to generate and manipulate text output within their scripts.\u003c/p\u003e\n"],["\u003cp\u003eMimeType aids in specifying the desired format for content delivery, accommodating various data types like CSV, JSON, and more.\u003c/p\u003e\n"],["\u003cp\u003eThe TextOutput class provides methods for managing the content, allowing for appending, clearing, and setting the output's format.\u003c/p\u003e\n"],["\u003cp\u003eContent served through scripts can be customized for display in browsers or downloaded as files, offering versatile content handling.\u003c/p\u003e\n"]]],[],null,["# Content Service\n\nContent\n\nThis service allows scripts to serve text in various forms, such as text,\nXML, or JSON. See also the [guide to\nContent Service](/apps-script/content_service). If you\n[deploy the following script as a web app](/apps-script/execution_web_apps),\nyou will see \"Hello, world!\" in the browser: \n\n function doGet() {\n return ContentService.createTextOutput('Hello, world!');\n }\n\nClasses\n-------\n\n| Name | Brief description |\n|------------------------------------------------------------------|----------------------------------------------------------|\n| [ContentService](/apps-script/reference/content/content-service) | Service for returning text content from a script. |\n| [MimeType](/apps-script/reference/content/mime-type) | An enum for mime types that can be served from a script. |\n| [TextOutput](/apps-script/reference/content/text-output) | A TextOutput object that can be served from a script. |\n\n[ContentService](/apps-script/reference/content/content-service)\n----------------------------------------------------------------\n\n### Properties\n\n| Property | Type | Description |\n|--------------|------------------------------------------------------|-------------|\n| `Mime``Type` | [MimeType](/apps-script/reference/content/mime-type) | |\n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------------------------------------|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|\n| [createTextOutput()](/apps-script/reference/content/content-service#createTextOutput()) | [TextOutput](/apps-script/reference/content/text-output) | Create a new [TextOutput](/apps-script/reference/content/text-output) object. |\n| [createTextOutput(content)](/apps-script/reference/content/content-service#createTextOutput(String)) | [TextOutput](/apps-script/reference/content/text-output) | Create a new [TextOutput](/apps-script/reference/content/text-output) object that can serve the given content. |\n\n[MimeType](/apps-script/reference/content/mime-type)\n----------------------------------------------------\n\n### Properties\n\n| Property | Type | Description |\n|--------------|--------|----------------------|\n| `CSV` | `Enum` | CSV Mime Type |\n| `ICAL` | `Enum` | ICAL Mime Type |\n| `JAVASCRIPT` | `Enum` | JAVASCRIPT Mime Type |\n| `JSON` | `Enum` | JSON Mime Type |\n| `TEXT` | `Enum` | TEXT Mime Type |\n| `VCARD` | `Enum` | VCARD Mime Type |\n\n[TextOutput](/apps-script/reference/content/text-output)\n--------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------------------------------------|----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| [append(addedContent)](/apps-script/reference/content/text-output#append(String)) | [TextOutput](/apps-script/reference/content/text-output) | Appends new content to the content that will be served. |\n| [clear()](/apps-script/reference/content/text-output#clear()) | [TextOutput](/apps-script/reference/content/text-output) | Clears the current content. |\n| [downloadAsFile(filename)](/apps-script/reference/content/text-output#downloadAsFile(String)) | [TextOutput](/apps-script/reference/content/text-output) | Tells browsers to download rather than display this content. |\n| [getContent()](/apps-script/reference/content/text-output#getContent()) | `String` | Gets the content that will be served. |\n| [getFileName()](/apps-script/reference/content/text-output#getFileName()) | `String` | Returns the file name to download this file as, or null if it should be displayed rather than downloaded. |\n| [getMimeType()](/apps-script/reference/content/text-output#getMimeType()) | [MimeType](/apps-script/reference/content/mime-type) | Get the mime type this content will be served with. |\n| [setContent(content)](/apps-script/reference/content/text-output#setContent(String)) | [TextOutput](/apps-script/reference/content/text-output) | Sets the content that will be served. |\n| [setMimeType(mimeType)](/apps-script/reference/content/text-output#setMimeType(MimeType)) | [TextOutput](/apps-script/reference/content/text-output) | Sets the mime type for content that will be served. |"]]