Polskie
 Polskie

Edytor Word, Excel, PowerPoint i PDF dla .NET i Java

Użyj wybranego edytora HTML do edytowania plików PDF, DOCX, XLSX, PPTX, ODT, XPS, TXT, RTF, HTML i wielu innych typów plików w .NET i Java, tworząc bogate w funkcje aplikacje do edycji dokumentów.

Wypróbuj nasze interfejsy API za darmoUzyskaj tymczasową licencję

Niezależne od platformy interfejsy API do edycji plików PDF, dokumentów Word, arkuszy kalkulacyjnych, prezentacji i innych plików danych

Edycja dokumentu w kontekście modyfikowania plików cyfrowych odnosi się do procesu zmiany tekstu, obrazów lub innych elementów w dokumencie. Cyfrową edycję plików danych można wykorzystać do poprawy dokładności i przejrzystości treści, dodania poprawek do istniejącej treści, ułatwienia czytania dokumentu i wielu innych. Wraz ze stale rosnącym wykorzystaniem różnego rodzaju dokumentów cyfrowych, potrzeba ich elektronicznej edycji staje się coraz ważniejsza.

Możliwość elektronicznej edycji dokumentów cyfrowych stała się podstawową umiejętnością każdego, kto pracuje z dokumentami. Wiedza o tym, jak szybko i dokładnie edytować pliki PDF, pliki pakietu Microsoft Office i inne pliki danych, może znacznie zaoszczędzić czas. W tym celu możesz użyć interfejsów API GroupDocs.Editor, które obsługują edycję wielu popularnych formatów plików danych, takich jak PDF, Word, Excel, PowerPoint, OpenDocument, RTF, Text, HTML, eBooks i wiele innych na platformach .NET i Java .

Rozpoczęcie pracy

Aby rozpocząć edytowanie dokumentów w .NET lub Javie, musisz najpierw zainstalować wymaganą wersję GroupDocs.Editor. Zapoznaj się z instrukcjami udostępnionymi w poniższych sekcjach, aby poprawnie skonfigurować GroupDocs.Editor dla platformy .NET lub Java.

GroupDocs.Editor do instalacji .NET

Zachęcamy do pobrania instalatora DLL lub MSI z sekcji pobierania lub skorzystania z NuGet, aby zainstalować interfejs API. Możesz także skorzystać z konsoli Menedżera pakietów:

PM> Install-Package GroupDocs.Editor 

Aby uzyskać dodatkową pomoc dotyczącą instalacji, zapoznaj się z tym przewodnikiem.

GroupDocs.Editor do instalacji Java

W przypadku wersji Java możesz pobrać plik JAR z sekcji pobierania lub dodać następujące konfiguracje repozytorium i zależność w twoich (opartych na Maven) aplikacjach Java:

<repository>
<id>GroupDocsJavaAPI</id>
    <name>GroupDocs Java API</name> 
    <url>https://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
            <artifactId>groupdocs-editor</artifactId>
        <version>20.11</version> 
</dependency>

Zapoznaj się z tym przewodnikiem instalacji, jeśli potrzebujesz więcej informacji.

Przypadki użycia do edycji plików PDF i innych plików danych

Teraz, gdy masz już skonfigurowaną poprawną wersję interfejsu API, sprawdźmy niektóre z powszechnie używanych scenariuszy przypadków edycji dokumentów wieloformatowych.

Przypadki użycia do edycji plików PDF i innych plików danych

Naucz się edytować dokumenty PDF w swoich aplikacjach .NET

Format PDF jest popularnym typem pliku używanym w dokumentach, raportach i innych treściach cyfrowych. Skrót oznacza Portable Document Format i jest szeroko stosowany ze względu na możliwość tworzenia wysokiej jakości dokumentów, które można łatwo udostępniać. Różni się od innych popularnych formatów plików danych, ponieważ oferuje stały układ i zachowuje to samo formatowanie i układ niezależnie od urządzenia i systemu operacyjnego, na którym je czytasz lub przeglądasz.

Ale co, jeśli musisz wprowadzić zmiany w dokumencie PDF? Edytowanie plików PDF może być trudnym procesem, ale nie musi tak być, jeśli korzystasz z GroupDocs.Editor for .NET API. Ten interfejs API umożliwia edycję plików PDF za pomocą edytora WYSIWYG, tak jak każdy inny dokument. Obecnie edytowanie plików PDF jest obsługiwane tylko w wersji .NET interfejsu GroupDocs.Editor API, a nie w wersji Java.

Naucz się edytować dokumenty PDF w swoich aplikacjach .NET

Edycja dokumentów PDF w .NET

Użyj następującego kodu do ładowania, edytowania, a następnie zapisywania pliku PDF w .NET:

  //1. Simple preparations of input data
const string filename = "sample.pdf";
const string password = "password"; 
string inputPath = System.IO.Path.Combine(Common.TestHelper.PdfFolder, filename);
//2. Create a load options class with password
GroupDocs.Editor.Options.PdfLoadOptions loadOptions = new PdfLoadOptions();
loadOptions.Password = password;
//3. Create edit options and tune/adjust if necessary
GroupDocs.Editor.Options.PdfEditOptions editOptions = new PdfEditOptions();
editOptions.EnablePagination = true; //Enable pagination for per-page processing in WYSIWYG-editor
editOptions.Pages = PageRange.FromStartPageTillEnd(3); //Edit not all pages, but starting from 3rd and till the end
//4. Create an Editor instance, load a document
GroupDocs.Editor.Editor editor = new Editor(inputPath, delegate () { return loadOptions; });
//5. Edit a document and generate EditableDocument
GroupDocs.Editor.EditableDocument originalDoc = editor.Edit(editOptions);
//6. Generate HTML/CSS, send it to WYSIWYG, edit there, and obtain edited version
string originalContent = originalDoc.GetEmbeddedHtml();
string editedContent = originalContent.Replace(".NET Framework", "I love Java!!!");
//7. Generate EditableDocument from edited content
EditableDocument editedDoc = EditableDocument.FromMarkup(editedContent, null);
//8. Create and adjust save options
GroupDocs.Editor.Options.PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.Compliance = PdfCompliance.Pdf20;
//9. Save to a file or a stream
string outputPath = System.IO.Path.Combine(Common.TestHelper.OutputFolder, filename);
editor.Save(editedDoc, outputPath, saveOptions);
//10. Don't forget to dispose all resources
originalDoc.Dispose();
editedDoc.Dispose();
editor.Dispose(); 

Jak edytować dokumenty edytora tekstu, arkusze kalkulacyjne i prezentacje w .NET i Javie?

Microsoft Word, Excel i PowerPoint to powszechnie używane formaty do tworzenia odpowiednio dokumentów, arkuszy kalkulacyjnych i prezentacji. Są one używane jako standardowe formaty w większości firm i organizacji i są niezbędnymi narzędziami dla każdego, kto chce organizować, analizować i prezentować dane w efektywny sposób.

Czy chcesz programowo edytować którykolwiek z tych formatów dokumentów w .NET lub Javie? Jeśli tak, możesz używać interfejsów API GroupDocs.Editor i edytować dokumenty Microsoft Word, Excel i PowerPoint, a do tego nie potrzebujesz nawet zainstalowanego pakietu Microsoft Office w swoim systemie.

Jak edytować dokumenty edytora tekstu, arkusze kalkulacyjne i prezentacje w .NET i Javie?

Edytowanie dokumentów programu Word w aplikacjach .NET

Aby edytować dokumenty Word (DOCX) w .NET, użyj tego kodu:

    using (FileStream fs = File.OpenRead("filepath/document.docx"))
{   
    // Load Document
    Options.WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
    loadOptions.Password = "password-if-any";
    // Edit Document
    using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; }))
    {
        Options.WordProcessingEditOptions editOptions = new WordProcessingEditOptions();
        editOptions.FontExtraction = FontExtractionOptions.ExtractEmbeddedWithoutSystem;
        editOptions.EnableLanguageInformation = true;
        editOptions.EnablePagination = true;
        using (EditableDocument beforeEdit = editor.Edit(editOptions))
        {
            string originalContent = beforeEdit.GetContent();
            List allResources = beforeEdit.AllResources;
            string editedContent = originalContent.Replace("document", "edited document");
            // Save Document
            using (EditableDocument afterEdit = EditableDocument.FromMarkup(editedContent, allResources))
            {
                WordProcessingFormats docxFormat = WordProcessingFormats.Docx;
                Options.WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions(docxFormat);
                saveOptions.EnablePagination = true;
                saveOptions.Locale = System.Globalization.CultureInfo.GetCultureInfo("en-US");
                saveOptions.OptimizeMemoryUsage = true;
                saveOptions.Password = "password";
                saveOptions.Protection = new WordProcessingProtection(WordProcessingProtectionType.ReadOnly, "write_password");
                using (FileStream outputStream = File.Create("filepath/editedDocument.docx"))
                {
                    editor.Save(afterEdit, outputStream, saveOptions);
                }
            }
        }
    }
} 

Zmodyfikuj pliki Microsoft Word w Javie

Aby edytować dokumenty programu Word w Javie, użyj następującego kodu:

    // Edit the Word DOC/DOCX documents in Java
Options.WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
loadOptions.setPassword("password-if-any");
Editor editor = new Editor("path/document.docx", loadOptions);
EditableDocument defaultWordProcessingDoc = editor.edit();
// Either edit using any WYSIWYG editor or edit programmatically
String allEmbeddedInsideString = defaultWordProcessingDoc.getEmbeddedHtml();
String allEmbeddedInsideStringEdited = allEmbeddedInsideString.replace("document", "edited document");
// Save the edited document
EditableDocument editedDoc = EditableDocument.fromMarkup(allEmbeddedInsideStringEdited, null);
WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docx);
editor.save(editedDoc, "path/edited-document.docx", saveOptions); 

Edycja arkuszy kalkulacyjnych Excel w .NET

Możesz edytować dokumenty programu Excel w .NET przy użyciu następującego kodu C#:

Options.SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.Password = "password";
// Load the Spreadsheet
Editor editor = new Editor("path/spreadsheet.xlsx", delegate { return loadOptions; });
// Get 1st tab of the Spreadsheet
SpreadsheetEditOptions sheetTab1EditOptions = new SpreadsheetEditOptions();
sheetTab1EditOptions.WorksheetIndex = 0; // first worksheet
// Obtain HTML markup from some EditableDocument instance
EditableDocument firstTab = editor.Edit(sheetTab1EditOptions);
string bodyContent = firstTab.GetBodyContent(); // HTML markup from inside the HTML -> BODY element
string allContent = firstTab.GetContent();      // Full HTML markup of all document, with HTML -> HEAD header and all its content
List onlyImages = firstTab.Images;
List allResourcesTogether = firstTab.AllResources;
string editedContent = allContent.Replace("Company Name", "New Company Name");
EditableDocument afterEdit = EditableDocument.FromMarkup(editedContent, allResourcesTogether);
// Create save options
SpreadsheetFormats xlsxFormat = SpreadsheetFormats.Xlsx;
Options.SpreadsheetSaveOptions saveOptions = new SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx);
// Set new opening password
saveOptions.Password = "newPassword";
saveOptions.WorksheetProtection = new WorksheetProtection(WorksheetProtectionType.All, "WriteProtectionPassword");
// Create output stream
using (FileStream outputStream = File.Create("path/editedSpreadsheet.xlsx"))
{
    editor.Save(afterEdit, outputStream, saveOptions);
} 

Edytuj dokumenty Microsoft Excel w Javie

Aby edytować arkusze kalkulacyjne programu Excel w Javie, możesz użyć tego fragmentu kodu:

// Edit the Excel XLS/XLSX documents in Java
SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setPassword("password-if-any");
// Loading Spreadsheet
Editor editor = new Editor("path/sample_sheet.xlsx", loadOptions);
// Edit 1st tab of the Spreadsheet
SpreadsheetEditOptions editOptions = new SpreadsheetEditOptions();
editOptions.setWorksheetIndex(0); // index is 0-based, so this is 1st tab
EditableDocument firstTab = editor.edit(editOptions);
String bodyContent = firstTab.getBodyContent();
String allContent = firstTab.getContent();
List onlyImages = firstTab.getImages();
List allResourcesTogether = firstTab.getAllResources();
String editedSheetContent = allContent.replace("Old Company Name","New Company Name");
EditableDocument editedDoc = EditableDocument.fromMarkup(editedSheetContent, null);
SpreadsheetSaveOptions saveOptions = new SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx);
saveOptions.setPassword("new-password");
editor.save(editedDoc, "path/edited_spreadsheet.xlsx", saveOptions);
firstTab.dispose();
editor.dispose()

Podobnie możesz edytować prezentacje programu PowerPoint za pomocą interfejsu API GroupDocs.Editor. Sprawdź platformę .NET i edycja Java, aby uzyskać dodatkową pomoc.

Naucz się edytować dokumenty tekstowe w .NET i Javie oraz tworzyć własne aplikacje edytora tekstu

Pliki tekstowe (oznaczone jako TXT) to jeden z najczęściej używanych formatów plików, ponieważ są lekkie, proste i łatwe do tworzenia i udostępniania. Są używane na różne sposoby, od pisania kodu po tworzenie zwykłych dokumentów tekstowych. Dokumenty tekstowe nie zawierają żadnego formatowania tekstu, obrazów, formularzy, tabel ani żadnych innych elementów tekstu sformatowanego.

Interfejsy API GroupDocs.Editor obsługują edytowanie plików tekstowych na platformach .NET i Java. Możesz zintegrować funkcje edycji dokumentów tekstowych z istniejącą aplikacją i rozszerzyć jej możliwości lub zbudować w tym celu własną aplikację edytora tekstu.

Naucz się edytować dokumenty tekstowe w .NET i Javie oraz tworzyć własne aplikacje edytora tekstu

Edytuj dokumenty tekstowe na platformie .NET

Poniższy przykładowy kod może służyć do edycji plików tekstowych w .NET. Edytowany plik można zapisać w formacie TXT i edytora tekstu (DOCM):

//Load the text file
string inputTxtPath = "C://input/file.txt";
Editor editor = new Editor(inputTxtPath);
TextEditOptions editOptions = new TextEditOptions();
editOptions.Encoding = System.Text.Encoding.UTF8;
editOptions.RecognizeLists = true;
editOptions.LeadingSpaces = TextLeadingSpacesOptions.ConvertToIndent;
editOptions.TrailingSpaces = TextTrailingSpacesOptions.Trim;
editOptions.Direction = TextDirection.Auto;
EditableDocument beforeEdit = editor.Edit(editOptions); // Create EditableDocument instance
string originalTextContent = beforeEdit.GetContent(); // Get HTML content
string updatedTextContent = originalTextContent.Replace("text", "EDITED text"); // Edit the content
List allResources = beforeEdit.AllResources; // Get resources (only one stylesheet in this case)
//Finally, create new EditableDocument
EditableDocument afterEdit = EditableDocument.FromMarkup(updatedTextContent, allResources);\
//Save the edited document to TXT and DOCM format
TextSaveOptions txtSaveOptions = new TextSaveOptions();
txtSaveOptions.AddBidiMarks = true;
txtSaveOptions.PreserveTableLayout = true;
WordProcessingSaveOptions wordSaveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docm);
string outputTxtPath = "C:\output\document.txt";
string outputWordPath = "C:\output\document.docm";
editor.Save(afterEdit, outputTxtPath, txtSaveOptions);
editor.Save(afterEdit, outputWordPath, wordSaveOptions); 

Edycja dokumentów tekstowych (TXT) w Javie

Aby edytować pliki tekstowe w Javie, możesz użyć kodu pokazanego poniżej. Zmodyfikowany dokument można następnie zapisać w formacie pliku TXT lub Word (DOCM):

// Loading the text document
String inputTxtPath = "C://input//file.txt";
Editor editor = new Editor(inputTxtPath);
TextEditOptions editOptions = new TextEditOptions();
editOptions.setEncoding(StandardCharsets.UTF_8);
editOptions.setRecognizeLists(true);
editOptions.setLeadingSpaces(TextLeadingSpacesOptions.ConvertToIndent);
editOptions.setTrailingSpaces(TextTrailingSpacesOptions.Trim);
editOptions.setDirection(TextDirection.Auto);
EditableDocument beforeEdit = editor.edit(editOptions); // Create EditableDocument instance
String originalTextContent = beforeEdit.getContent(); // Get HTML content
String updatedTextContent = originalTextContent.replace("text", "EDITED text"); // Edit the content
List allResources = beforeEdit.getAllResources(); // Get resources (only one stylesheet actually in this case)
//Finally, create new EditableDocument
EditableDocument afterEdit = EditableDocument.fromMarkup(updatedTextContent, allResources);
//Saving the modified file to TXT and DOCM formats
TextSaveOptions txtSaveOptions = new TextSaveOptions();
txtSaveOptions.setAddBidiMarks(true);
txtSaveOptions.setPreserveTableLayout(true);
WordProcessingSaveOptions wordSaveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docm);
String outputTxtPath = "C:\\output\\document.txt";
String outputWordPath = "C:\\output\\document.docm";
editor.save(afterEdit, outputTxtPath, txtSaveOptions);
editor.save(afterEdit, outputWordPath, wordSaveOptions);  

Jakie są formaty dokumentów e-mail i jak można je edytować w .NET i Javie?

Dokumenty wiadomości e-mail to pliki zawierające treść wiadomości e-mail, w tym treść wiadomości i wszelkie załączniki. Pliki te są zwykle używane do przesyłania wiadomości e-mail między różnymi klientami poczty e-mail lub do przechowywania ich w standardowym formacie. Są używane przez różnych klientów poczty e-mail, takich jak Microsoft Outlook, Apple Mail i Mozilla Thunderbird. Dokumenty te stanowią integralną część sposobu, w jaki komunikujemy się ze sobą w erze cyfrowej.

Wraz ze wzrostem wykorzystania tych typów plików, ich edycja staje się również powszechna. Automatyzacja procesu edycji może być nieoceniona, niezależnie od tego, czy chcesz zintegrować proces z innym systemem, czy zastosować niestandardową logikę. Interfejsy API GroupDocs.Editor (dla .NET i Java) umożliwiają właśnie to. Korzystając z tych interfejsów API, możesz edytować dokumenty e-mail w popularnych formatach.

Jakie są formaty dokumentów e-mail i jak można je edytować w .NET i Javie?

Jak edytować dokumenty e-mail w .NET?

Jeśli chcesz ładować, edytować i zapisywać wiadomość e-mail (MSG), skorzystaj z tej kod C#:

//1. Prepare a sample file
const string msgFilename = "ComplexExample.msg";
string msgInputPath = System.IO.Path.Combine(Common.TestHelper.EmailFolder, msgFilename);
//2. Load to the Editor class
Editor msgEditor = new Editor(msgInputPath);
//3. Create edit options with all content
Options.EmailEditOptions editOptions = new EmailEditOptions(MailMessageOutput.All);
//4. Generate an editable document
EditableDocument originalDoc = msgEditor.Edit(editOptions);
//5. Emit HTML from EditableDocument, send it to the client-side, edit it there in WYSIWYG-editor (omitted here)
string savedHtmlContent = originalDoc.GetEmbeddedHtml();
//6. Obtain edited content from the client-side and generate a new EditableDocument from it (omitted here)
EditableDocument editedDoc = EditableDocument.FromMarkup(savedHtmlContent, null);
//7. Create 1st save options
EmailSaveOptions saveOptions1 = new EmailSaveOptions(MailMessageOutput.Common);
//8. Create 2nd save options
EmailSaveOptions saveOptions2 = new EmailSaveOptions(MailMessageOutput.Body | MailMessageOutput.Attachments);
//9. Generate and save 1st output MSG to the file
string outputMsgPath = System.IO.Path.Combine(Common.TestHelper.OutputFolder, "OutputFile.msg");
msgEditor.Save(editedDoc, outputMsgPath, saveOptions1);
//10. Generate and save 2nd output MSG to the stream
Stream outputMsgStream = File.Create(Path.Combine(Common.TestHelper.OutputFolder, "OutputStream.msg"));
msgEditor.Save(editedDoc, outputMsgStream, saveOptions2);
//11. Dispose all resources
outputMsgStream.Dispose();
editedDoc.Dispose();
originalDoc.Dispose();
msgEditor.Dispose(); 

Edycja dokumentów e-mail w Javie

Aby ładować, edytować i zapisywać plik wiadomości e-mail (MSG), możesz użyć następującego kodu :

//1. Prepare a sample file
String msgInputPath = "C:\ComplexExample.msg";
//2. Load to the Editor class
Editor msgEditor = new Editor(msgInputPath);
//3. Create edit options with all content
EmailEditOptions editOptions = new EmailEditOptions(MailMessageOutput.All);
//4. Generate an editable document
EditableDocument originalDoc = msgEditor.edit(editOptions);
//5. Emit HTML from EditableDocument, send it to the client-side, edit it there in WYSIWYG-editor (omitted here)
String savedHtmlContent = originalDoc.getEmbeddedHtml();
//6. Obtain edited content from the client-side and generate a new EditableDocument from it (omitted here)
EditableDocument editedDoc = EditableDocument.fromMarkup(savedHtmlContent, null);
//7. Create 1st save options
EmailSaveOptions saveOptions1 = new EmailSaveOptions(MailMessageOutput.Common);
//8. Create 2nd save options
EmailSaveOptions saveOptions2 = new EmailSaveOptions(MailMessageOutput.Body | MailMessageOutput.Attachments);
//9. Generate and save 1st output MSG to the file
String outputMsgPath = "C:\OutputFile.msg";
msgEditor.save(editedDoc, outputMsgPath, saveOptions1);
//10. Generate and save 2nd output MSG to the stream
Stream outputMsgStream = "C:\OutputStream.msg";
msgEditor.save(editedDoc, outputMsgStream, saveOptions2);
//11. Dispose all resources
outputMsgStream.dispose();
editedDoc.dispose();
originalDoc.dispose();
msgEditor.dispose(); 

Możesz także edytować pliki PDF, DOCX, XLSX, PPTX, ODT, ODS, RTF, TXT, CSV, XML, EPUB i wiele innych dokumentów w locie, korzystając z naszej Bezpłatne aplikacje do edycji dokumentów na wybrane urządzenie, więc zachęcamy do ich wypróbowania.

Szukasz pomocy?

Sprawdź nasze kanały wsparcia, aby uzyskać pomoc w przypadku pytań związanych z funkcjami i działaniem interfejsu API produktu Conholdate.