Add Comments in Excel Worksheet Java

Comments are used to add additional information or to explain a formula in the Excel worksheet. MS Excel also allows you to set the font size, height, width, etc. of the comments. In this article, you will learn how to add comments to the Excel files in Java. Furthermore, the article will also cover how to format the comments.

Java API to Add Comments in Excel - Free Download

In order to add comments to the cells in Excel worksheets, we will use Aspose.Cells for Java. The API lets you create, modify, and convert Excel files from within your Java applications. You can either download the API or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>21.7</version>
</dependency>

Easy Steps to Add Comments in Excel in Java

Using Aspose.Cells for Java, you can add comments to the Excel files within a few steps. The following steps give an overview of how to insert comments to a worksheet in an Excel file.

  • Load the Excel file from the disk.
  • Access the desired worksheet.
  • Add comment to the desired cell.
  • Save the Excel file.

Now, let’s have a look at how to transform the above-mentioned steps into code and add comments in an Excel file in Java.

Add Comments in Excel File in Java

The following are the steps to add a comment to a cell in an Excel file in Java.

The following code sample shows how to insert a comment in an Excel file in Java.

Java: Add Comments in Excel with Formatting

The following are the steps to apply formatting to the comments in Excel in Java.

The following code sample shows how to set formatting of the comments in Excel.

Java API to Add Comments in Excel - Get a Free License

You can use Aspose.Cells for Java without evaluation limitations using a temporary license.

Conclusion

In this article, you have learned how to add comments to the cells in Excel files in Java. Furthermore, you have seen how to apply formatting to the comments programmatically. You can visit the documentation to explore other features of Aspose.Cells for Java. In case you would have any queries, feel free to post to our forum.

See Also