Online Edit
Quick Start
Run Spire.Cloud Online Editor in Your Web Application
Getting Started with Spire.Cloud Online Editor
Spire.Cloud Word Editor
How to Add a Watermark to Word
How to Insert and Customize Footnotes
How to Insert a WordArt
How to Insert a Picture in Word
How to Insert a Link in Word
How to Add Comments in Word
How to Add a Column to Word
Spire.Cloud Excel Editor
How to Create a Table in Excel
How to Insert a Chart in Excel
Web API
.NET
Spire.Cloud.Word
Replace Text in Word Using Spire.Cloud.Word
Add, Remove or Edit Paragraphs in Word Using Spire.Cloud.Word
Convert Word to PDF or XPS Using Spire.Cloud.Word
Encrypt Word Documents Using Spire.Cloud.Word
Add Text and Image Watermarks to Word using Spire.Cloud.Word
Remove Watermarks from Word using Spire.Cloud.Word
Set Background Color and Image for Word using Spire.Cloud
Spire.Cloud.Excel
Freeze or Unfreeze Excel Columns and Rows Using Spire.Cloud.Excel
Add or Delete Excel Comments Using Spire.Cloud.Excel
Convert Excel to PDF or XPS Using Spire.Cloud.Excel
Set or Remove Excel Document Properties Using Spire.Cloud.Excel
Encrypt or Decrypt Excel Documents Using Spire.Cloud.Excel
Merge and Unmerge Excel Cells using Spire.Cloud.Excel
Protect or Unprotect Excel Worksheet using Spire.Cloud.Excel
Replace Text in Excel in C# using Spire.Cloud.Excel
Spire.Cloud.PowerPoint
Add a Table to PowerPoint Using Spire.Cloud.PowerPoint
Add an Image to PowerPoint Using Spire.Cloud.PowerPoint
Set or Remove PowerPoint Document Properties Using Spire.Cloud.PowerPoint
Convert PowerPoint to PDF or Images Using Spire.Cloud.PowerPoint
Add Background Color or Image to Slides Using Spire.Cloud.PowerPoint
Add, Update and Remove Speaker Notes in PowerPoint using Spire.Cloud.PowerPoint
Replace Text in PowerPoint using Spire.Cloud.PowerPoint
Spire.Cloud.PDF
Merge or Split PDF Documents Using Spire.Cloud.PDF
Add and Delete PDF Document Properties using Spire.Cloud.PDF
Add or Extract Images in PDF Using Spire.Cloud.PDF
Install Spire.Cloud Web API via NuGet
How to Use Spire.Cloud Web API in .NET
Java
Spire.Cloud.Word
Create a Blank Word Document using Spire.Cloud.Word
Merge Word documents in Java using Spire.Cloud.Word
Encrypt Word Documents Using Spire.Cloud.Word
Add Table to Word Document using Spire.Cloud.Word
Remove Watermark in Word Document using Spire.Cloud.Word
Replace Text in a Word document Using Spire.Cloud.Word
Convert Word to HTML in Java using Spire.Cloud.Word
Add Digital Signature to Word using Spire.Cloud.Word
Add and Delete Shapes in Word Using Spire.Cloud.Word
Add and Delete Images in Word Using Spire.Cloud.Word
Add, Get and Delete Custom Document Properties in Word using Spire.Cloud.Word
Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word
Spire.Cloud.Excel
Freeze or Unfreeze Excel Rows and Columns using Spire.Cloud.Excel
Merge Excel Cells and Set Cell Format using Spire.Cloud.Excel
Spire.Cloud.Excel Encrypt/Decrypt Excel Documents
Rename Excel Worksheet Using Spire.Cloud.Excel
Add or Delete Comments in Excel Worksheets
Set and Delete Excel Document Properties Using Spire.Cloud.Excel
Spire.Cloud.PowerPoint
Add Image to a PowerPoint Document using Spire.Cloud.PowerPoint
Create a table in PowerPoint using Spire.Cloud.PowerPoint
Convert PPT(X) to PDF using Spire.Cloud.PowerPoint
Convert PPT(X) to PNG using Spire.Cloud.PowerPoint
Set and Delete PowerPoint Document Properties Using Spire.Cloud.PowerPoint
Replace Text in PowerPoint in Java using Spire.Cloud.PowerPoint
Spire.Cloud.PDF
Add/ Delete PDF Page Using Spire.Cloud.PDF
Convert PDF to Image using Spire.Cloud.PDF
Draw Shapes in PDF Using Spire.Cloud.PDF
Convert PDF to Word Document Using Spire.Cloud.PDF
Add, Update and Delete PDF Document Properties using Spire.Cloud.PDF
Add an Image to PDF Document Using Spire.Cloud.PDF
Merge and Split PDF Documents Using Spire.Cloud.PDF
Add Lists to PDF using Spire.Cloud.PDF
Add, Update, Get and Delete Bookmarks in PDF
Install Spire.Cloud Web API from Maven Repository
How to Use Spire.Cloud Web API in Java

Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word

Spire.Cloud.Word provides developers with the ParagraphsApi interface to manipulate paragraphs in Word documents. This article will introduce how to add, replace and delete paragraphs in Word Document with this interface.

The original Word document is shown as below:

Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word

Add a paragraph

import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;

public class addParagraph {
    static String appId = "APP ID";
    static String appKey = "APP Key";
    static String baseUrl = "https://api.cloudxdocs.com";

    //Create a Configuration object based on App ID, App Key and base Url
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    //Create an instance of ParagraphsApi
    static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        //Specify the name of the original Word document
        String fileName = "Spire.Office.docx";
        String name = fileName;

        //Add a paragraph
        String nodePath = "Section/0/Body/0";
        Integer indexOfParagraph = 1;
        String text = "This is a newly added paragraph";

        //Specify the folder where the original document is stored, set it to null if there's none
        String folder = "input";
        //Specify the original password of the input document, set it to null if there's none
        String password = null;
        //Store the document in the 2G default storage space offered by E-iceblue Cloud
        String storage = null;
        //Specify the storage path and name of the generated document
        String destFilePath = "output/AddParagraph.docx";

        //Add a paragraph to the Word document with "addParagraph" method
        paragraphsApi.addParagraph(name, nodePath, destFilePath, folder, storage, indexOfParagraph, password, text);
    }
}

Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word

Replace a paragraph

import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;

public class updateParagraphText {
    static String appId = "APP ID";
    static String appKey = "APP Key";
    static String baseUrl = "https://api.cloudxdocs.com";

    //Create a Configuration object based on App ID, App Key and base Url
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    //Create an instance of ParagraphsApi
    static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        //Specify the name of the original Word document
        String fileName = "Spire.Office.docx";
        String name = fileName;

        //Replace the text in the third paragraph
        String nodePath = "Section/0/Body/0";
        Integer index = 2;
        String text = "A Brief Introduction of Spire.Office";

        //Specify the folder where the original document is stored, set it to null if there's none
        String folder = "input";
        //Specify the original password of the input document, set it to null if there's none
        String password = null;
        //Store the document in the 2G default storage space offered by E-iceblue Cloud
        String storage = null;
        //Specify the storage path and name of the generated document
        String destFilePath = "output/UpdateParagraphText.docx";

        //Replace the paragraph in the Word document with "updateParagraphText" method
        paragraphsApi.updateParagraphText(name, nodePath, index, text, destFilePath,folder, storage, password);
    }
}

Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word

Delete a paragraph

import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;

public class deleteParagraph {
    static String appId = "APP ID";
    static String appKey = "App Key";
    static String baseUrl = "https://api.cloudxdocs.com";

    //Create a Configuration object based on App ID, App Key and base Url
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    //Create an instance of ParagraphsApi
    static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        //Specify the name of the original Word document
        String fileName = "Spire.Office.docx";
        String name = fileName;

        //Delete the fourth paragraph
        String nodePath = "Section/0/Body/0";
        Integer index = 3;

        //Specify the folder where the original document is stored, set it to null if there's none
        String folder = "input";
        //Specify the original password of the input document, set it to null if there's none
        String password = null;
        //Store the document in the 2G default storage space offered by E-iceblue Cloud
        String storage = null;
        //Specify the storage path and name of the generated document
        String destFilePath = "output/DeleteParagraph.docx";

        //Delete a paragraph in the Word document with "deleteParagraph" method
        paragraphsApi.deleteParagraph(name, nodePath, index, destFilePath, folder, storage, password);
    }
}

Add/Replace/Delete Paragraphs in Word Document Using Spire.Cloud.Word