Add Annotation in XLSM File via C++
Build your own C++ apps to manipulate comments & authors in document files using server-side APIs.
How to Annotate XLSM File Using C++
In order to annotate XLSM file, we’ll use
API which is a feature-rich, powerful and easy to use document searching API for C++ platform. You can download its latest version directly, just open
package manager, search for Aspose.Cells.Cpp and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Cells.Cpp
Steps to Add Comments in XLSM via C++
- Load the XLSM Excel file using the IWorkbook class object.
- Select the relevant sheet
- Add the comment using the Add method
- Set the note of the comment using the SetNote method.
- Save the workbook using Save method
System Requirements
Aspose.Cells for C++ supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit and Linux 64 bit.
- Add reference to the Aspose.Cells for C++ DLL in your project.
Add Comments in XLSM - C++
Aspose::Cells::Startup(); | |
// Source directory path. | |
U16String srcDir = u"SourceDirectory\\Excel\\"; | |
// Output directory path. | |
U16String outDir = u"OutputDirectory\\"; | |
// Load the source ODS Excel file | |
Workbook wkb(srcDir + u"SampleFile.xlsm"); | |
// Retrieve the first worksheet | |
Worksheet wks = wkb.GetWorksheets().Get(0); | |
// Add comment to the cell F5 | |
int commentIndex = wks.GetComments().Add(u"F5"); | |
// Retrieve the comment added to the cell F5 | |
Comment cmt = wks.GetComments().Get(commentIndex); | |
// Set the comment note | |
cmt.SetNote(u"Hello Aspose!"); | |
// Save the Excel file | |
wkb.Save(outDir + u"AddComment_out.xlsm"); | |
Aspose::Cells::Cleanup(); |