Просмотрите наши продукты

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

Установка

Пакет доступен на nuget.org. Его можно установить через консоль диспетчера пакетов следующей командой:

NuGet\Install-Package GroupDocs.editor-Cloud

Version NuGet NuGet-GroupDocsCloud


Требования

  • .NET Framework 2.0 или .NET Standard 2.0
  • NuGet
  • System.Web при целевой платформе .NET Framework 2.0
  • Учетные данные GroupDocs Cloud — Client ID and Client Secret на панели

Быстрый старт

Получение учетных данных API

Чтобы использовать GroupDocs.Editor Cloud, зарегистрируйтесь на панели GroupDocs.Cloud и получите Client ID и Client Secret.

Инициализация API

Следующий код запускает GroupDocs.Editor Cloud SDK for .NET.

using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;

string MyClientId = "YourClientId";
string MyClientSecret = "YourClientSecret";

var config = new Configuration(MyClientId, MyClientSecret);

var apiInstance = new EditApi(config);

Полный пример см. в Common.cs.

Редактирование документа Word

В этом примере загружается защищенный паролем документ Word, текст в HTML заменяется и сохраняется файл DOCX.

using System.IO;
using System.Text;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using FileInfo = GroupDocs.Editor.Cloud.Sdk.Model.FileInfo;

var config = new Configuration("YourClientId", "YourClientSecret");
var editApi = new EditApi(config);
var fileApi = new FileApi(config);

var loadOptions = new WordProcessingLoadOptions
{
    FileInfo = new FileInfo
    {
        FilePath = "WordProcessing/password-protected.docx",
        Password = "password"
    },
    OutputPath = "output"
};

var loadResult = editApi.Load(new LoadRequest(loadOptions));
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
htmlString = htmlString.Replace("Sample test text", "Hello world");

fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath, new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));

var saveOptions = new WordProcessingSaveOptions
{
    FileInfo = loadOptions.FileInfo,
    OutputPath = "output/edited.docx",
    HtmlPath = loadResult.HtmlPath,
    ResourcesPath = loadResult.ResourcesPath
};

var saveResult = editApi.Save(new SaveRequest(saveOptions));
Console.WriteLine("Document edited: " + saveResult.Path);

Полный пример см. в EditWordProcessingDocument.cs.

Редактирование таблицы

В этом примере загружается первый лист, текст заменяется и сохраняется файл XLSX.

using System.IO;
using System.Text;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using FileInfo = GroupDocs.Editor.Cloud.Sdk.Model.FileInfo;

var config = new Configuration("YourClientId", "YourClientSecret");
var editApi = new EditApi(config);
var fileApi = new FileApi(config);

var loadOptions = new SpreadsheetLoadOptions
{
    FileInfo = new FileInfo { FilePath = "Spreadsheet/four-sheets.xlsx" },
    OutputPath = "output",
    WorksheetIndex = 0
};

var loadResult = editApi.Load(new LoadRequest(loadOptions));
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
htmlString = htmlString.Replace("This is sample sheet", "This is sample sheep");

fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath, new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));

var saveOptions = new SpreadsheetSaveOptions
{
    FileInfo = loadOptions.FileInfo,
    OutputPath = "output/edited.xlsx",
    HtmlPath = loadResult.HtmlPath,
    ResourcesPath = loadResult.ResourcesPath
};

var saveResult = editApi.Save(new SaveRequest(saveOptions));
Console.WriteLine("Document edited: " + saveResult.Path);

Полный пример см. в EditSpreadsheetDocument.cs.

Получение сведений о документе

В этом примере возвращается число страниц защищенного паролем документа Word.

using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;

var config = new Configuration("YourClientId", "YourClientSecret");
var apiInstance = new InfoApi(config);

var request = new GetInfoRequest(new FileInfo
{
    FilePath = "WordProcessing/password-protected.docx",
    Password = "password"
});

var response = apiInstance.GetInfo(request);
Console.WriteLine("InfoResult.Pages.Count: " + response.PageCount);

Полный пример см. в GetDocumentInformation.cs.

Получение поддерживаемых типов файлов

Получите форматы, которые принимает API editor.

using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;

var config = new Configuration("YourClientId", "YourClientSecret");
var apiInstance = new InfoApi(config);

var response = apiInstance.GetSupportedFileFormats();

foreach (var entry in response.Formats)
{
    Console.WriteLine($"{entry.FileFormat}: {string.Join(",", entry.Extension)}");
}

Полный пример см. в GetSupportedFileTypes.cs.

Примеры на GitHub

Репозиторий GroupDocs.Editor Cloud .NET Examples содержит готовые к запуску примеры по темам:

CategoryExamples
РедактированиеТекстовый документ, таблица, презентация, текст с разделителями, простой текст
InfoСведения о документе, поддерживаемые типы файлов, расход лицензии

Как запустить примеры

  1. Клонируйте или скачайте репозиторий примеров
  2. Откройте Examples/GroupDocs.Editor.Cloud.Examples.CSharp.sln в Visual Studio 2017 или новее
  3. Щелкните решение правой кнопкой мыши и выберите Enable NuGet Package Restore
  4. Измените Examples/GroupDocs.Editor.Cloud.Examples.CSharp/RunExamples.cs и задайте Common.MyClientId и Common.MyClientSecret
  5. Соберите и запустите

Подробности см. в разделе Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Теги

Document Editing API | .NET 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 | API Explorer | Multi-Platform Support | SDK Support | Secure API Access


 Русский