Hi guys,
I got FileDownloadGateway class from (http://www.visualwebgui.com/Developers/Community/Projects/ApplicationVEM/Forums/tabid/179/forumid/29/threadid/22480/scope/posts/threadpage/2/Default.aspx) and tried to use it in my application (see code below). IIt works ok if I use xls file, but using xlsx file I got recovery error when I open the file.
Code:
FileDownloadGateway myDownload = new FileDownloadGateway();
myDownload.Filename = "ExportData.xlsx";
myDownload.DownloadAsAttachment = true;
myDownload.SetContentType(DownloadContentType.MicrosoftExcel2007);
System.IO.FileStream fstream;
fstream = System.IO.File.OpenRead("d:\\Template.xlsx");
byte[] f = new byte[fstream.Length + 1];
fstream.Read(f, 0, (int)fstream.Length);
fstream.Close();
System.IO.MemoryStream ms = new System.IO.MemoryStream(f);
ms.Position = 0;
myDownload.StartStreamDownload(this, ms);
where MicrosoftExcel2007 is "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
I'm doing something wrong?
Thanks and best regards,
Oliver