Workbook protection

When I try to open some Excel file in Read Mode only (for example: application.Workbooks.OpenReadOnly("d:\\temp\\test.xls");), which is protected as Book Protection (in Excel see the menu Tools->Protection->Protect Workbook...), but not protected as Document Protection (see Tools->Options->choose the "Security" Tab and input some password in the "Password for open" field), I have an exception (see below). Why is it happen, if I open file in read mode only? I've tried to use other combination of "Open" method, but it fails.

P.S. Password was not specified in the "Security" tab. Password was specified in the "Protect Workbook..." dialog only.

The exception:

System.ArgumentException: Workbook is protected and password wasn't specified.

в Syncfusion.XlsIO.Implementation.WorkbookImpl.CreateDecryptor(String password, FilePassRecord filePass)
в Syncfusion.XlsIO.Implementation.WorkbookImpl.Parse(BiffReader reader, ExcelParseOptions options, String password)
в Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStgStream(StgStream stream, ExcelParseOptions options, String password)
в Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, String strFileName, ExcelParseOptions options, Boolean bReadOnly, String password)
в Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, String strTemplateFile, ExcelParseOptions options, Boolean bReadOnly, String password)
в Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open(String fileName, ExcelParseOptions options, Boolean isReadOnly, String password)


3 Replies

YG Yavanaarasi G Syncfusion Team August 14, 2008 05:38 AM UTC

Hi dvshestakov,

Thank you for your interest in Syncfusion products.

I am not able to reproduce the issue that you mentioned here. As per your requirements I have created a file, protect the workbook(Tools->Protection->ProtectWorkbook) and open the file in XlsIO using OpenReadOnly or open method. It works without any exception.

Here is the sample for your reference:


http://www.syncfusion.com/development/uploads/XlsIO_Win_OpenReadonly_aad2fee4.zip


Please take a look into the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample with your file so that we could sort out the cause of the issue and provide you a solution?

Also please provide details about the system configuration and Essential studio version that you have used.

Regards,
G.Yavana



AD Administrator Syncfusion Team September 2, 2008 05:08 AM UTC

Hi,

Sorry for delay.

I used 5.0.1.51 version, your example didn't work well. When I downloaded 6.3.0.30 version, all is ok.

Thanks.



GM Geetha M Syncfusion Team September 4, 2008 01:25 PM UTC

Hi,

Thank you for the update.

Regards,
Geetha


Loader.
Up arrow icon