Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-kb/8c4312591b9d21eb5694647bfc66074b to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-kb/8c4312591b9d21eb5694647bfc66074b to your computer and use it in GitHub Desktop.
Add Threaded Comments in Excel using Java. For details: https://kb.aspose.com/cells/java/add-threaded-comments-in-excel-using-java/
import com.aspose.cells.*;
public class ThreadedCommentsDemo {
public static void main(String[] args) throws Exception {
// Apply Aspose.Cells license
License license = new License();
license.setLicense("license.lic");
// Create a workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
// Add a value to cell A1
sheet.getCells().get("A1").putValue("Hello");
// Create an author for threaded comments
int authorIndex = workbook.getWorksheets()
.getThreadedCommentAuthors()
.add("Aspose Test", "", "");
ThreadedCommentAuthor author =
workbook.getWorksheets()
.getThreadedCommentAuthors()
.get(authorIndex);
// Add a threaded comment to cell A1
sheet.getComments()
.addThreadedComment("A1", "Test Threaded Comment", author);
// Save the Excel file
workbook.save("AddThreadedComments_out.xlsx");
System.out.println("Threaded comment added successfully.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment