Java (482)
Comments in Excel are used to explain the contents in cells, or to offer reminders/notes to other users. Once a comment’s been added, Microsoft Excel allows users to show, hide, edit and delete the comments easily in a worksheet. This article will introduce how to edit existing comments as well as remove comments programmatically using Spire.XLS for Java.
Install Spire.XLS for Java
First of all, you're required to add the Spire.Xls.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version>16.3.2</version>
</dependency>
</dependencies>
Edit Comments in Excel
After adding comments to your Excel workbook, you may want to make changes to the added comments. The below table lists some of the core classes and methods used to get the existing comments and then set new text as well as formatting for the comments.
| Name | Description |
| ExcelCommentObject Class | Represents a comment in an Excel document. |
| CellRange.getComment() Method | Returns a comment object that represents a comment in a specific cell range. |
| ExcelCommentObject.setText() Method | Sets the comment text. |
| ExcelCommentObject.setHeight() Method | Sets height of a comment. |
| ExcelCommentObject.setWidth() Method | Sets width of a comment. |
| ExcelCommentObject.setAutoSize() Method | Sets whether the size of the specified object is changed automatically to fit text within its boundaries. |
The following are steps to edit comments in Excel:
- Create a Workbook instance.
- Load an Excel file using Workbook.loadFromFile() method.
- Get the first worksheet of the Excel file using WorksheetsCollection.get() method.
- Get a comment in a specific cell range using CellRange.getComment() method and then set new text and height/width or auto size for the existing comment using the methods offered by ExcelCommentObject class.
- Save the document to another file using Workbook.saveToFile() method.
- Java
import com.spire.xls.*;
public class ModifyComment {
public static void main(String[] args) {
//Create a Workbook instance
Workbook wb = new Workbook();
//Load an Excel file
wb.loadFromFile("Comments.xlsx");
//Get the first worksheet
Worksheet sheet = wb.getWorksheets().get(0);
//Get comments in specific cells and set new comments
sheet.getRange().get("A8").getComment().setText("Frank has left the company.");
sheet.getRange().get("F6").getComment().setText("Best sales.");
//Set the height and width of the new comments
sheet.getRange().get("A8").getComment().setHeight(50);
sheet.getRange().get("A8").getComment().setWidth(100);
sheet.getRange().get("F6").getComment().setAutoSize(true);
//Save to file.
wb.saveToFile("ModifyComment.xlsx",ExcelVersion.Version2013);
wb.dispose();
}
}

Remove Comments in Excel
The following are steps to remove a comment in Excel:
- Create a Workbook instance.
- Load an Excel file using Workbook.loadFromFile() method.
- Get the first worksheet of the Excel file using WorksheetsCollection.get() method.
- Get a comment in a specific cell range using CellRange.getComment() method and then delete the comment using ExcelCommentObject.remove() method.
- Save the document to another file using Workbook.saveToFile() method.
- Java
import com.spire.xls.*;
public class DeleteComment {
public static void main(String[] args) {
//Create a Workbook instance
Workbook wb = new Workbook();
//Load an Excel file
wb.loadFromFile("Comments.xlsx");
//Get the first worksheet
Worksheet sheet = wb.getWorksheets().get(0);
//Get the comment in a specific cell and remove it
sheet.getRange().get("F6").getComment().remove();
//Save to file.
wb.saveToFile("DeleteComment.xlsx", ExcelVersion.Version2013);
wb.dispose();
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
A digital signature confirms that the document content originates from the signer and has not been changed. In this article, you will learn how to add a digital signature to your PowerPoint documents as well as remove all digital signatures using Spire.Presentation for Java.
Installl Spire.Presentation for Java
First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.presentation</artifactId>
<version>11.3.5</version>
</dependency>
</dependencies>
Add a Digital Signature to PowerPoint
The following are the steps to add a digital signature to a PowerPoint document.
- Create an object of Presentation class.
- Load the sample PowerPoint document using Presentation.loadFromFile() method.
- Add a digital signature to the document using Presentation.addDigitalSignature(String pfxPath, String password, String comments, java.util.Date signTime) method.
- Save the result to a .pptx file using Presentation.saveToFile() method.
- Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import java.util.Date;
public class AddDigitalSignature {
public static void main(String[] args) throws Exception {
//Create a Presentation object
Presentation presentation = new Presentation();
//Load the sample PowerPoint document
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx");
//Add a digital signature
String pfxPath = "C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx";
String password = "e-iceblue";
String comment = "Modification is not allowed";
presentation.addDigitalSignature(pfxPath,password,comment,new Date());
//Save the result to file
presentation.saveToFile("output/AddDigitalSignature.pptx", FileFormat.PPTX_2013);
}
}

Remove all Digital Signaters from PowerPoint
The following are steps to remove all digital signatures from a PowerPoint document.
- Create an object of Presentation class.
- Load the sample PowerPoint document using Presentation.loadFromFile() method.
- Determine if the document contains digital signatures using Presentation.isDigitallySigned() method.
- Remove all signatures using Presentation.removeAllDigitalSignatures() method.
- Save the result to a .pptx file using Presentation.saveToFile() method.
- Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
public class RemoveDigitalSignature {
public static void main(String[] args) throws Exception {
//Create a Presentation object
Presentation presentation = new Presentation();
//Load the sample PowerPoint document
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\AddDigitalSignature.pptx");
//Determine if the document is digitally signed
if (presentation.isDigitallySigned() == true)
{
//Remove all digital signatures
presentation.removeAllDigitalSignatures();
}
//Save the result to file
presentation.saveToFile("output/RemoveDigitalSignature.pptx", FileFormat.PPTX_2013);
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
RTF, short for Rich Text Format, is created by Microsoft in 1987 for the purpose of cross-platform document interchange. It is supported by many word processing applications, and the most popular one among them is Microsoft Word. In certain circumstances, you may need to convert an RTF document to Word Doc/Docx format or convert a Word Doc/Docx document to RTF. In this article, you will learn how to accomplish this task using Spire.Doc for Java.
Install Spire.Doc for Java
First of all, you're required to add the Spire.Doc.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc</artifactId>
<version>14.4.0</version>
</dependency>
</dependencies>
Convert RTF to Word Doc/Docx
The following are the steps to convert an RTF document to Word Doc/Docx using Spire.Doc for Java:
- Create a Document instance.
- Load an RTF document using Document.loadFromFile(String, FileFormat) method.
- Save the RTF to Doc/Docx format using Document.saveToFile(String, FileFormat) method.
- Java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
public class RtfToDocDocx {
public static void main(String[] args){
//Create a Document instance
Document document = new Document();
//Load a RTF document
document.loadFromFile("Input.rtf", FileFormat.Rtf);
//Save the document to Doc
document.saveToFile("toDoc.doc", FileFormat.Doc);
//Save the document to Docx
document.saveToFile("toDocx.docx", FileFormat.Docx_2013);
}
}

Convert Word Doc/Docx to RTF
The steps to convert a Word Doc/Docx document to RTF is very similar with that of the above example:
- Create a Document instance.
- Load a Doc or Docx document using Document.loadFromFile(String) method.
- Save the Doc/Docx document to RTF using Document.saveToFile(String, FileFormat) method.
- Java
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
public class DocDocxToRtf {
public static void main(String[] args){
//Create a Document instance
Document document = new Document();
//Load a Docx document
document.loadFromFile("input.docx");
//Load a Doc document
//document.loadFromFile("sample.doc");
//Save the document to RTF
document.saveToFile("toRTF.rtf", FileFormat.Rtf);
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.