We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

XLS to XLSX using Aspose.Cells for .NET in C#

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.

Hi Adarsh,

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.

Please also download and try the latest version: Aspose.Cells for .NET (Latest Version) and see if it makes any difference.

Hi,


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.

Thank you.

Thanks Amjad. I didn’t realize it was saving as xls file format and the error message was confusing. Above code works.

Hi Adarsh,

It is good to know that your issue is resolved now. If you encounter any other issue, please feel free to post. We will be glad to help you further.

I have a same problem, can u help?

Hi Liu,


Thank you for contacting Aspose support.

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.