Specify Author while Write Protecting Workbook with C++
Possible Usage Scenarios
You can specify the author name while write protecting your workbook using Aspose.Cells API. Please use the Workbook.GetAuthor() property for this purpose.
Specify Author while Write Protecting Workbook
The following sample code explains the usage of the Workbook.GetAuthor() property. The code creates an empty workbook, write protects it with a password, specifies the author name, and saves it as an output Excel file. The following screenshot illustrates the effect of the sample code on the output Excel file for your reference.
Sample Code
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create empty workbook
Workbook wb;
// Write protect workbook with password
wb.GetSettings().GetWriteProtection().SetPassword(u"1234");
// Specify author while write protecting workbook
wb.GetSettings().GetWriteProtection().SetAuthor(u"SimonAspose");
// Save the workbook in XLSX format
wb.Save(outDir + u"outputSpecifyAuthorWhileWriteProtectingWorkbook.xlsx");
std::cout << "Workbook write protected with author specified successfully!" << std::endl;
Aspose::Cells::Cleanup();
}