i have excel file saved in SQL database as byte format, now i want to convert this bytes into excel and render it over RadSpreadsheet
Below is my code by getting exception "Value of type 'Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider' cannot be converted to 'Telerik.Web.UI.SpreadsheetProviderBase'"
5 Answers, 1 is accepted
It seems that you are trying to use the ASP.NET RadSpreadsheet with the XlsxFormatProvider. This format provider is designed for the Silverlight / WPF RadSpreadsheet control and the Document Processing Library (DPL). The ASP.NET RadSpreadsheet has a separate format provider which should be used in this case.
Please, let me know if you have any further questions or comments.
For convenience, I am sharing the answer from the support ticket here. Let us continue the discussion there and if we have other solutions and suggestions, we will share them here.
The provided SpreadsheetDocumentProvider can load only files from a file by passing a path to the file in the provider's constructor.
To use a MemoryStream for the Spreadsheet, you should create a Custom Provider - https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/custom-database-provider.
Another possible approach is to load the MemoryStream to a provider from the DocumentProcessingLibrary and then to convert the DocumentProcessingLibrary Workbook to a Spreadsheet Workbook - https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/formats-and-conversion/xlsx/xlsxformatprovider.
Then, from the Spreadsheet Workbook, you can get the sheets and return them from the GetSheetsMethod of the Custom provider or populate the Spreadsheet programmatically - https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/programmatic-binding.
If you would like to save the workbook to a MemoryStream, you can get the workbook as demonstrated here https://www.telerik.com/support/kb/aspnet-ajax/spreadsheet/details/access-the-spreadsheet-workbook-on-the-server and then convert it to a stream.
We cannot translate your code in vb.net (SkippedTokensTrivia)
using (Stream input = new MemoryStream(new byte))
dplWorkbook = formatProvider.Import(input);
Can you suggest an implementation for vb.net please?
The problem with the convertor is probably the fact that it considers the using() as a method. With that said, if you wrap this in a simple method declaration it will convert it properly to:
Using input As Stream = New MemoryStream(byteArr) dplWorkbook = formatProvider.Import(input) End Using
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.