Hi there,
i've programmed an application in witch the users could upload xls files and as time goes by xlsx files.
With the code fragment below the upload workes fine:
IWorkbook workbook = application.Workbooks.Open(finalDestinationPath, ExcelOpenType.Automatic);
my problem is that the provided fles are password proteted and i use the fallowing code (overload 11) to open the files:
IWorkbook workbook = application.Workbooks.Open(finalDestinationPath, ExcelParseOptions.Default,true,passphrase);
any suggestions how to open the password protected files in the automatic mode?
with kind regards
Benjamin
GM
Geetha M
Syncfusion Team
January 6, 2009 06:40 AM UTC
Hi Benjamin,
Thank you for your interest in Syncfusion products.
We don't have any option to identify the Excel type when a spreadsheet is password protected. But you can workaround this by using the below set of code:
Stream stream = new FileStream(@"..\..\Test.xlsx", FileMode.Open);
if (Syncfusion.Compression.Zip.ZipArchive.ReadInt32(stream) == Syncfusion.Compression.Zip.Constants.HeaderSignature)
application.DefaultVersion = ExcelVersion.Excel2007;
else
application.DefaultVersion = ExcelVersion.Excel97to2003;
stream.Close();
IWorkbook workbook = application.Workbooks.Open(@"..\..\Test.xlsx", ExcelParseOptions.Default, true, "open");
Note: The support of opening an Encrypted .xlsx document has been implemented internally. This feature will be available in our next public release expected on January 14.
Please let me know if you have any questions.
Regards,
Geetha
BS
Benjamin Scheerer
January 8, 2009 11:52 AM UTC
Hi Geetha,
thanks for your answer and the code example.
I tried to set the defaultVersion as you`ve recommendet. The result seems to be one step forward - here is the new exception:
"Zip exception.Can't locate end of central directory record. Possible wrong file format or archive is corrupt."
I've no idea - do you?
I didnt`t get it clear from your writing: Is it possible to open password protected files with Excel 2007 format (my syncfusion version is 6.102.0.34) or not?
with kind regards
Benjamin
GM
Geetha M
Syncfusion Team
January 9, 2009 05:01 AM UTC
Hi Benjamin,
I am able to reproduce the above exception. With 6.1.x.x versions, it is not possible to open password protected xlsx file and this feature has been implemented recently which is yet to be released.
Please let me know if you have any concerns.
Regards,
Geetha
GM
Geetha M
Syncfusion Team
January 9, 2009 05:22 AM UTC
Hi Benjamin,
To give more information, the exception is reproducible as the support to open a password protected xlsx is not implemented. I tested this with the internal code (yet to be released) and it works fine.
Regards,
Geetha
BS
Benjamin Scheerer
January 13, 2009 01:06 PM UTC
Hi Geetha,
could you please tell me when the release, on witch you successfully tested it, is availible (and what is the version number)?
with kind regards
Benjamin
>Hi Benjamin,
To give more information, the exception is reproducible as the support to open a password protected xlsx is not implemented. I tested this with the internal code (yet to be released) and it works fine.
Regards,
Geetha
GM
Geetha M
Syncfusion Team
January 15, 2009 04:39 AM UTC
Hi Benjamin,
The latest RC release with this feature included in now available. You can get the download link and other details from the forum thread in the link below:
http://www.syncfusion.com/support/forums/message.aspx?MessageID=78966Note: The above version does not include option to automatically open a password protected file. You can use the workaround as updated on 1/6/2009.
Please try this and let me know if you have any questions.
Regards,
Geetha