You can find detailed information at: Add Comments in Excel Worksheets using C++
Last active
September 7, 2021 11:06
-
-
Save aspose-com-gists/3fba100568c3e5988c396dd0630449d2 to your computer and use it in GitHub Desktop.
Add Comments in Excel Worksheets using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the source Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Retrieve the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Add comment to the cell F5 | |
int commentIndex = worksheet->GetIComments()->Add(new String("F5")); | |
// Retrieve the comment added to the cell F5 | |
intrusive_ptr<IComment> comment = worksheet->GetIComments()->GetObjectByIndex(commentIndex); | |
// Set the comment note | |
comment->SetNote(new String("Hello Aspose!")); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("AddComment_out.xlsx"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source directory path. | |
StringPtr srcDir = new String("SourceDirectory\\Excel\\"); | |
// Output directory path. | |
StringPtr outDir = new String("OutputDirectory\\"); | |
// Load the source Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(srcDir->StringAppend(new String("Sample1.xlsx"))); | |
// Retrieve the first worksheet | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Add comment to the cell F5 | |
int commentIndex = worksheet->GetIComments()->Add(new String("F5")); | |
// Retrieve the comment added to the cell F5 | |
intrusive_ptr<IComment> comment = worksheet->GetIComments()->GetObjectByIndex(commentIndex); | |
// Set the comment note | |
comment->SetNote(new String("Hello Aspose!")); | |
// Set the font size | |
comment->GetIFont()->SetSize(14); | |
// Set the font weight | |
comment->GetIFont()->SetBold(true); | |
// Set the height in CM | |
comment->SetHeightCM(10); | |
// Set the width in CM | |
comment->SetWidthCM(2); | |
// Save the Excel file | |
workbook->Save(outDir->StringAppend(new String("ApplyFormattingToComment_out.xlsx"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment