We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Could not set the password in XLSX and XLSM excel sheet


 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))

Attachment: Blank_267592b7.zip

1 Reply

SS Sridhar Sukumar Syncfusion Team April 13, 2017 01:02 PM UTC

Hi Vasanth, 
Thank you for contacting Syncfusion support. 

We were able to reproduce the issue. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates 




Please let me know if you have any questions. 



Sridhar S. 

SIGN IN To post a reply.
Live Chat Icon For mobile
Up arrow icon