Hi..,
I try to set the password in XLSX and XLSM file but i could not.
if i initialize PasswordToOpen property worksheet could not saved it will throw object set reference error.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.OnPasswordRequired += application_OnPasswordRequired;
application.DefaultVersion = ExcelVersion.Excel2013;
//Loads or open an existing workbook through Open method of IWorkbooks
MemoryStream ms_template = new MemoryStream();
byte[] buffer = File.ReadAllBytes(@"D:\Book1.xlsx");
ms_template.Position = 0;
ms_template.Write(buffer, 0, buffer.Length);
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(ms_template, ExcelOpenType.SpreadsheetML2010);
using (var fileStream_write = new FileStream(@"D:\TemplateEmpty.xlsx", FileMode.Create, FileAccess.Write))
{
workbook.SaveAs(fileStream_write);
}
Attachment:
Blank_267592b7.zip