We currently use Epplus for creating Excel reports and are looking to buy Aspose.Cells as there are few limitations with Epplus. I'm currently trying out Aspose.Cells for few of the problems we have with Epplus so just replacing some of the Epplus code to Aspose.Cells code to see if Aspose solves our problems.
I'm getting following error with the below code. I'm assuming that you password protect the sheet. How can I make this working?
Error: Can not open the package. Package is an OLE compound document. If this is an encrypted package, please supply the password
Code:
var wrkBook = new Workbook(this.TemplateFilePath);
wrkBook.Worksheets.AddCopy("Template");
var stream = wrkBook.SaveToStream();
var excelPackage = new ExcelPackage(stream); // Using the Aspose stream to create the Epplus package gives me the above error
Thanks for your posting and considering Aspose.Cells.
It seems this is not the issue with Aspose.Cells and related to Epplus. You should provide us your template file and the sample project replicating this issue. We will look into it and see if we could resolve it.
Well, if you are saving XLS (Excel 97-2003) file format, please do not use the older SaveToStream method as this method is used to save the template workbook to steam for XLS file format only. Please use Workbook.Save(steam, SaveFormat.XLSX) instead if you are saving/saving as an XLSX (or other advanced Excel 2007/2010 file formats). See the lines of code for your reference.
Sample code:
var wrkBook = new Workbook(this.TemplateFilePath);
wrkBook.Worksheets.AddCopy(“Template”);
MemoryStream stream = new MemoryStream();
wrkBook.Save(stream, SaveFormat.Xlsx);
stream.Position = 0;
var excelPackage = new ExcelPackage(stream);
If you still find the issue, kindly do post a sample project with template Excel file here as Shakeel Faiz suggested, we will check your issue soon.
We would request you to please give a try to the latest version of Aspose.Cells for .NET (Latest version) in perspective of this suggestion. In case the problem persists, please provide an executable standalone sample application along with problem description. Please make an archive (zip) of your project before attaching it to the forum thread.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.