We are using version 16.1.20161.2118 of Infragistics4.Win.UltraWinSpreadsheet.v16.1. I am able to save a loaded Excel file into a memory stream in Excel97 format and load it back in Excel97 format successfully. But when I try to save it to a memory stream in Excel2007 format I get an invalid or unrecognized file format error when trying to load it back.
// saveSpreadSheet.Workbook.SetCurrentFormat(WorkbookFormat.Excel97To2003);MemoryStream stream = new MemoryStream();SpreadSheet.Workbook.Save(stream);
// loadWorkbook wb = new Workbook(WorkbookFormat.Excel97To2003);MemoryStream stream = new MemoryStream();stream.Write(bytFile, 0, bytFile.Length - 1);wb = Infragistics.Documents.Excel.Workbook.Load(stream);
How can I save a 2007+ file to a memory stream?
Hello Joe,
We have investigated this further. It seems that there is an issue in the way you are calling Save method. You are excluding the last byte, i.e. you have:
loadStream.Write(bytFile, 0, bytFile.Length - 1);
However, the last parameter is the count so it should be:
loadStream.Write(bytFile, 0, bytFile.Length);
Please let me know if you need any further assistance.
Yes, you are correct. I did a typo. Instead of loading the load stream I loaded the save stream. Nevertheless, I test your sample and was able to reproduce this issue. I have asked our engineering staff to examine why exception is thrown while trying to load workbook from memory stream further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of #232359. Therefore, I have created a case for you CAS-181228-R1N0J8, and will update you for the progress of this issue via the mentioned case. You could reach your case following the link below:
https://es.infragistics.com/my-account/support-activity
Thank you for using Infragistics Components.
The example you sent actually reloaded the initial stream again rather than the second stream. I have changed that and made a few changes to illustrate how the Excel 97 and 2007 behave differently. Please take a look at the attached sample.
I followed the steps you suggested and was unable to reproduce the behavior you are describing. I created a small sample project and added UltraSpreadSheet to it. Then I paste the code snippet you had provided. When I run my project, I did not receive any errors or exceptions.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this issue.
If the project does not work correctly, this indicates either an issue possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using Infragistics for Windows Forms 2016 volume 1 with latest service release. So could you please let me know the exact version of Infragistics components which you are using?
If the project does show the product feature working correctly, this indicates a possible issue in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back.
Please let me know if I can provide any further assistance.