浏览我们的产品

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

安装

该软件包在PyPI可用,可以通过执行以下命令通过pip安装:

pip install groupdocs-editor-cloud

PyPI - Version PyPI - Downloads Python-GroupDocsCloud


要求

依赖关系

SDK自动安装以下软件包:

PackageConstraint
urllib3>= 1.15
six>= 1.10
certifi
python-dateutil

通过 REST 在云中编辑 40 多种文档格式

GroupDocs.Editor Cloud Python SDK 是一个 REST API,旨在将文档编辑功能集成到 Python Web 应用程序、脚本和自动化工作流程中。该 API 支持 40 多种文件格式,使您可以直接从云端轻松编辑 Word 文档、电子表格、演示文稿等,而无需使用 MS Office 等第三方软件。功能包括处理受密码保护的文件、多语言支持和可自定义的格式选项。开发人员可以跨 Web、桌面和移动平台轻松执行加载、编辑和保存文档等文件操作。

编辑文字处理Documents

支持的格式 - DOC、DOCX、DOCM、DOT、DOTM、DOTX、ODT、OTT、RTF 等。
云存储工作流程 - 直接从云存储上传、编辑和保存Word处理文档。
受密码保护的文档 - 在加载和保存过程中处理受密码保护的 Word 文档。
加载选项 - 启用分页、提取字体和处理多语言信息。

编辑电子表格 Documents

支持的格式 - XLS、XLSX、XLSM、XLSB、ODS、CSV、TSV 等。
工作表选择 - 将电子表格加载到可编辑的 HTML 中并处理特定的工作表。
隐藏工作表 - 如果需要,可从编辑中排除隐藏工作表。
密码保护 - 处理受密码保护的电子表格文档。

编辑演示文稿 Documents

支持的格式 - PPT、PPTX、PPTM、PPSX、POTX、ODP、OTP 等。
幻灯片选择 - 从演示文稿中加载特定幻灯片进行编辑。
隐藏幻灯片 - 在编辑过程中包含或排除隐藏幻灯片。

编辑文本Documents

纯文本支持 - 处理 TXT 文件并识别简单的结构,例如列表和缩进。
保存为 Word 格式 - 如果需要,将编辑的 TXT 文件保存回 Word 处理格式。
格式选项 - 控制前导和尾随空格并在输出 HTML 中启用分页。

编辑分隔符分隔值 (DSV) Documents

自定义分隔符 - 支持 CSV、TSV 和带有自定义分隔符的文件。
数据转换 - 指定自定义分隔符并处理日期/数字数据转换。
连续分隔符 - 将连续分隔符视为单个实体的选项。

文档信息检索

文件详细信息 - 检索文件扩展名、文档大小、页数和密码保护状态。
支持的格式信息 - 从 API 获取可编辑文件类型的完整列表。

文件和存储操作

下载文件 - 通过 API 从云存储下载文件。
文件版本 - 从支持版本控制的存储系统中检索特定文件版本。
存储检查 - 验证云存储是否存在并列出文件夹内的文件。

许可和身份验证

评估模式 - 使用免费试用帐户试用 API。
安全身份验证 - 使用 Client ID 和 Client Secret 进行安全 API 访问。
MIT License - Python SDK 根据 MIT License 获得许可。

支持的文档格式

GroupDocs.Editor Cloud 支持 40 多种文件格式,具有编辑和自动检测功能:

  • 文字处理: DOC、DOCX、DOCM、DOT、DOTM、DOTX、ODT、OTT、RTF、FlatOPC、WordML
  • 电子表格: XLS、XLT、XLSX、XLSM、XLTX、XLTM、XLSB、XLAM、ODS、FODS、DIF、CSV、TSV、DSV
  • 演示文稿: PPT、PPTX、PPTM、PPS、PPSX、PPSM、POT、POTX、POTM、ODP、OTP
  • 其他: TXT、HTML、XML

支持的操作因格式而异。有关完整的格式矩阵,请参阅文档

快速入门

获取您的 API 凭证

要使用GroupDocs.Editor Cloud,请在GroupDocs.Cloud仪表板注册并获取您的Client IDClient Secret

初始化API

使用以下代码开始使用GroupDocs.Editor Cloud SDK for Python:

import groupdocs_editor_cloud

# Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
client_id = "YourClientId"
client_secret = "YourClientSecret"

# Create API configuration
configuration = groupdocs_editor_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"

# Create instance of the Edit API
edit_api = groupdocs_editor_cloud.EditApi.from_config(configuration)

编辑Word文档

初始化后,使用此基本示例加载 DOCX 文件,编辑其 HTML 表示形式,然后保存结果:

import groupdocs_editor_cloud

edit_api = groupdocs_editor_cloud.EditApi.from_keys("YourClientId", "YourClientSecret")
file_api = groupdocs_editor_cloud.FileApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("WordProcessing/password-protected.docx", None, None, "password")
load_options = groupdocs_editor_cloud.WordProcessingLoadOptions()
load_options.file_info = file_info
load_options.output_path = "output"
load_result = edit_api.load(groupdocs_editor_cloud.LoadRequest(load_options))

html_file = file_api.download_file(groupdocs_editor_cloud.DownloadFileRequest(load_result.html_path))
with open(html_file, "r") as file:
    html = file.read()

html = html.replace("Sample test text", "Hello world")

with open(html_file, "w") as file:
    file.write(html)

file_api.upload_file(groupdocs_editor_cloud.UploadFileRequest(load_result.html_path, html_file))

save_options = groupdocs_editor_cloud.WordProcessingSaveOptions()
save_options.file_info = file_info
save_options.output_path = "output/edited.docx"
save_options.html_path = load_result.html_path
save_options.resources_path = load_result.resources_path
save_result = edit_api.save(groupdocs_editor_cloud.SaveRequest(save_options))

print("Document edited: " + save_result.path)

通过本快速入门指南,您就可以开始在 Python 应用程序中使用 GroupDocs.Editor Cloud 编辑文档了。欲了解更多详情,请访问文档

获取支持的文件类型

通过编辑器 API 检索可用的受支持文件格式的完整列表。

import groupdocs_editor_cloud

info_api = groupdocs_editor_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

result = info_api.get_supported_file_formats()

for fmt in result.formats:
    print(fmt.file_format)

获取文档信息

检索文档元数据,例如页数和密码保护状态。

import groupdocs_editor_cloud

info_api = groupdocs_editor_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("WordProcessing/password-protected.docx", None, None, "password")
result = info_api.get_info(groupdocs_editor_cloud.GetInfoRequest(file_info))

print("Page count = " + str(result.page_count))

编辑电子表格文档

从 XLSX 文件加载特定工作表,编辑其 HTML 内容,然后保存回电子表格格式。

import groupdocs_editor_cloud

edit_api = groupdocs_editor_cloud.EditApi.from_keys("YourClientId", "YourClientSecret")
file_api = groupdocs_editor_cloud.FileApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("Spreadsheet/four-sheets.xlsx")
load_options = groupdocs_editor_cloud.SpreadsheetLoadOptions()
load_options.file_info = file_info
load_options.output_path = "output"
load_options.worksheet_index = 0
load_result = edit_api.load(groupdocs_editor_cloud.LoadRequest(load_options))

html_file = file_api.download_file(groupdocs_editor_cloud.DownloadFileRequest(load_result.html_path))
with open(html_file, "r") as file:
    html = file.read()

html = html.replace("This is sample sheet", "This is sample sheep")

with open(html_file, "w") as file:
    file.write(html)

file_api.upload_file(groupdocs_editor_cloud.UploadFileRequest(load_result.html_path, html_file))

save_options = groupdocs_editor_cloud.SpreadsheetSaveOptions()
save_options.file_info = file_info
save_options.output_path = "output/edited.xlsx"
save_options.html_path = load_result.html_path
save_options.resources_path = load_result.resources_path
save_result = edit_api.save(groupdocs_editor_cloud.SaveRequest(save_options))

print("Document edited: " + save_result.path)

编辑演示文档

从 PPTX 文件加载特定幻灯片,编辑其 HTML 内容,然后保存回演示文稿格式。

import groupdocs_editor_cloud

edit_api = groupdocs_editor_cloud.EditApi.from_keys("YourClientId", "YourClientSecret")
file_api = groupdocs_editor_cloud.FileApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("Presentation/with-notes.pptx")
load_options = groupdocs_editor_cloud.PresentationLoadOptions()
load_options.file_info = file_info
load_options.output_path = "output"
load_options.slide_number = 0
load_result = edit_api.load(groupdocs_editor_cloud.LoadRequest(load_options))

html_file = file_api.download_file(groupdocs_editor_cloud.DownloadFileRequest(load_result.html_path))
with open(html_file, "r") as file:
    html = file.read()

html = html.replace("Slide sub-heading", "Hello world!")

with open(html_file, "w") as file:
    file.write(html)

file_api.upload_file(groupdocs_editor_cloud.UploadFileRequest(load_result.html_path, html_file))

save_options = groupdocs_editor_cloud.PresentationSaveOptions()
save_options.file_info = file_info
save_options.output_path = "output/edited.pptx"
save_options.html_path = load_result.html_path
save_options.resources_path = load_result.resources_path
save_result = edit_api.save(groupdocs_editor_cloud.SaveRequest(save_options))

print("Document edited: " + save_result.path)

编辑 DSV 文档

加载分隔符分隔值文件,编辑其 HTML 表示形式,然后保存回 TSV 格式。

import groupdocs_editor_cloud

edit_api = groupdocs_editor_cloud.EditApi.from_keys("YourClientId", "YourClientSecret")
file_api = groupdocs_editor_cloud.FileApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("Spreadsheet/sample.tsv")
load_options = groupdocs_editor_cloud.DelimitedTextLoadOptions()
load_options.file_info = file_info
load_options.output_path = "output"
load_result = edit_api.load(groupdocs_editor_cloud.LoadRequest(load_options))

html_file = file_api.download_file(groupdocs_editor_cloud.DownloadFileRequest(load_result.html_path))
with open(html_file, "r") as file:
    html = file.read()

html = html.replace("32", "66")

with open(html_file, "w") as file:
    file.write(html)

file_api.upload_file(groupdocs_editor_cloud.UploadFileRequest(load_result.html_path, html_file))

save_options = groupdocs_editor_cloud.DelimitedTextSaveOptions()
save_options.file_info = file_info
save_options.output_path = "output/edited.tsv"
save_options.html_path = load_result.html_path
save_options.resources_path = load_result.resources_path
save_result = edit_api.save(groupdocs_editor_cloud.SaveRequest(save_options))

print("Document edited: " + save_result.path)

编辑文本文档

加载纯文本文件,编辑其 HTML 表示形式,然后保存结果。

import groupdocs_editor_cloud

edit_api = groupdocs_editor_cloud.EditApi.from_keys("YourClientId", "YourClientSecret")
file_api = groupdocs_editor_cloud.FileApi.from_keys("YourClientId", "YourClientSecret")

file_info = groupdocs_editor_cloud.FileInfo("Text/document.txt")
load_options = groupdocs_editor_cloud.TextLoadOptions()
load_options.file_info = file_info
load_options.output_path = "output"
load_result = edit_api.load(groupdocs_editor_cloud.LoadRequest(load_options))

html_file = file_api.download_file(groupdocs_editor_cloud.DownloadFileRequest(load_result.html_path))
with open(html_file, "r") as file:
    html = file.read()

html = html.replace("Page Text", "New Text")

with open(html_file, "w") as file:
    file.write(html)

file_api.upload_file(groupdocs_editor_cloud.UploadFileRequest(load_result.html_path, html_file))

save_options = groupdocs_editor_cloud.TextSaveOptions()
save_options.file_info = file_info
save_options.output_path = "output/edited.txt"
save_options.html_path = load_result.html_path
save_options.resources_path = load_result.resources_path
save_result = edit_api.save(groupdocs_editor_cloud.SaveRequest(save_options))

print("Document edited: " + save_result.path)

GitHub 上的示例项目

GroupDocs.Editor Cloud Python 示例 存储库包含可立即运行的示例,涵盖:

CategoryExamples
GetSupportedFileTypesSupported file types
GetInfoDocument information (page count, password status)
EditOperations — WordEdit word processing documents (including password-protected)
EditOperations — SpreadsheetEdit spreadsheet documents with worksheet selection
EditOperations — PresentationEdit presentation documents with slide selection
EditOperations — DSVEdit delimiter-separated values documents (CSV, TSV)
EditOperations — TextEdit plain text documents

如何运行示例

  1. 克隆或下载示例存储库
  2. 编辑Examples/RunExamples.py并设置client_idclient_secret 3.进入Examples目录 4.运行pip install groupdocs-editor-cloud -U 5.执行python RunExamples.py

欲了解更多详情,请访问入门


Product Docs Swagger Examples Blog Support Dashboard


标签

Document Editing API | Python Cloud API | GroupDocs.Editor Cloud | REST API | Word Processing Formats | Spreadsheet Formats | Presentation Formats | Text Formats | CSV Files | DOCX Documents | XLSX Documents | PPTX Presentations | Password-Protected Files | Cloud Storage Integration | Document Info Retrieval | File Operations | WYSIWYG Editing | Multi-Platform Support | Secure API Access | HTML Editing | Cross-platform API



 简体中文