Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Save XLSX files to a memory stream
posted

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.

// save
SpreadSheet.Workbook.SetCurrentFormat(WorkbookFormat.Excel97To2003);
MemoryStream stream = new MemoryStream();
SpreadSheet.Workbook.Save(stream);

// load
Workbook 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?