Here is a good example of how to use an Excel spreadsheet as the data source for a RadGrid...
Is there a way to modify this example to use a spreadsheet data source that was uploaded with RadAsyncUpload without saving the xlsx to the server first - like a file stream or something? Any advice or examples would be appreciated.
6 Answers, 1 is accepted
Thank you for contacting us.
A possible solution is to use RadSpreadProcessing control to achieve your scenario. Generally you after the file is uploaded you can use the XlsxFormatProvider Import property which will hold the file data. Then you can use MemoryStream to download the file locally and not on the server. Please check out the following live example which demonstrates that.
I hope this information helps.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Can you tell me how to set grdImportedRecords.DataSource? Much appreciated!
Thank you to Petya for the help with this.
For some obscure reason I get a an error on the line :
workbook = fileFormatProvider.Import(file.InputStream);
Any Ideas on a workaround on this one?
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte buffer, Int32 offset, Int32 count)
at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
at System.IO.Stream.CopyTo(Stream destination)
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.GetStreamFromZipPackage(ZipArchiveEntry entry, Stream& stream)
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.ImportXlsxPartFromArchive(ZipArchiveEntry zipEntry, OpenXmlPartBase part, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.Import(Stream input, IOpenXmlImportContext context)
at Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider.ImportOverride(Stream input)
at Telerik.Windows.Documents.Spreadsheet.FormatProviders.WorkbookFormatProviderBase.Import(Stream input)
at DBFUpload.fuWeeklyHarvest_FileUploaded(Object sender, FileUploadedEventArgs e) in e:\DROPBOX_OLD\VSS_WD\CMC.root\CMC\CMC_V2\Uploads\DBFUpload.aspx.cs:line 68
at Telerik.Web.UI.RadAsyncUpload.OnFileUploaded(FileUploadedEventArgs e)
I am guessing here, but it looks like your spreadsheet may be too big for the memory on the machine you are trying to do this on. The only advice I could give is to add additional RAM to that machine.
That is a negative. It is on my dev notebook, 32gb of RAM. It is a 27mb spreadsheet, 140k lines, and about 15 columns. I opened up resource monitor before uploading, error comes up about 2 sec after hitting that line, ram never goes up above 8gb. So not sure ram is the issue. If i close, re-open solution, it jumps that line. Second time it hits the error. Not sure of the Asyncupload dumps/flush the memory stream after processing the opened file. It will continue until i unload and reload the whole project by opening and closing the solution, rebuild and run again.