GroupDocs.Editor Cloud SDK for PHP 支持在 PHP 应用中编辑和操作多种流行文档文件格式。只需将 GroupDocs.Editor Cloud SDK for PHP 与 GroupDocs.Editor Cloud REST API 集成,便可在任意第三方所见即所得 HTML 编辑器中上传受支持的文档,操作文档后将其保存回原始文档格式,且编辑后外观不受影响。PHP 编辑器库支持多种文档格式,包括 Microsoft Word(DOC、DOCX、WordML)、Excel(XLS、XLSX、SpreadsheetML)、演示文稿(PPT、PPTX)、HTML、XML、TXT 和 OpenDocument。
GroupDocs.Editor Cloud SDK for PHP 构建在 GroupDocs.Editor Cloud REST API 之上,作为一层封装,通过管理底层请求和处理响应,为您节省宝贵的开发时间。开发者可以专注于在项目中仅编写所需的特定代码。
如果您正在寻找用于在云端标注文件的源代码,请查看 GroupDocs.Editor Cloud SDK for PHP at GitHub。
您可以尝试 GroupDocs.Editor Low-Code PHP APIs,且没有任何限制。
GroupDocs.Editor Cloud 也提供 Docker 镜像,可用于 self-host 服务。或者,您可以使用 GroupDocs.Editor High-code APIs(https://products.groupdocs.com/editor/)自行构建服务,该技术目前驱动我们的 REST APIs。
//Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).
$AppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
$AppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid($AppSid);
$configuration->setAppKey($AppKey);
$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);
// The document already uploaded into the storage
// Load it into editable state
$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Spreadsheet/four-sheets.xlsx");
$loadOptions = new Model\SpreadsheetLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadOptions->setWorksheetIndex(0);
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));
// Download html document
$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());
// Edit something...
$html = str_replace("This is sample sheet", "This is sample sheep", $html);
// Upload html back to storage
file_put_contents($htmlFile->getRealPath(), $html);
$uploadRequest = new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath());
$fileApi->uploadFile($uploadRequest);
// Save html back to xlsx
$saveOptions = new Model\SpreadsheetSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.xlsx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));
// Done.
echo "Document edited: " . $saveResult->getPath();