Accept or Reject Tracked Changes in Word Using Java
source link: https://dev.to/jazzzzz/accept-or-reject-tracked-changes-in-word-using-java-4506
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Accept or Reject Tracked Changes in Word Using Java
Jul 12
・1 min read
If you are collaborating with multiple people on contracts or school assignments, tracking changes can be very help because it helps you to review each change made by other people, and you can decide whether to accept or reject those changes. In this article, I will share how to accept or reject all tracked changes in a Word document using Free Spire.XLS for Java.
Import Jar Dependency (2 methods)
● Download the Free Spire.Doc for Java and unzip it, then add the Spire.Doc.jar file to your Java application as dependency.
● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>
Sample Code
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
public class AcceptOrRejectChanges {
public static void main(String[] args) {
//Create a Document object
Document doc = new Document();
//Load the sample Word file
doc.loadFromFile("Oscar Wilde.docx");
//Accept all changes in the entire document
doc.acceptChanges();
////Reject all changes in the entire document
//doc.rejectChanges();
//Save the document
doc.saveToFile("AcceptAllChanges.docx", FileFormat.Docx);
}
}
Before
After
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK