Content Service
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
المحتوى
تسمح هذه الخدمة للنصوص البرمجية بعرض النصوص بأشكال مختلفة، مثل النص أو
XML أو JSON. يُرجى الاطّلاع أيضًا على دليل استخدام
Content Service. إذا
نشرت النص البرمجي التالي كتطبيق ويب،
سيظهر لك النص "مرحبًا، عالم!" في المتصفّح:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
صفوف
الاسم | وصف قصير |
ContentService | خدمة لعرض محتوى نصي من نص برمجي |
MimeType | تسرد هذه السمة أنواع 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 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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. |"]]