I am using Telerik version 2015.3.930.45 in vb.net.
This is pretty simple code and I am receiving the following error. What am I missing?
-----------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.SpreadsheetDocumentProvider.GetSheets() +72
Telerik.Web.UI.RadSpreadsheet.PerformSelect() +110
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
Telerik.Web.UI.RadSpreadsheet.EnsureDataBound() +98
System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22
Telerik.Web.UI.RadDataBoundControl.OnPreRender(EventArgs e) +36
Telerik.Web.UI.RadSpreadsheet.OnPreRender(EventArgs e) +79
System.Web.UI.Control.PreRenderRecursiveInternal() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +155
System.Web.UI.Control.PreRenderRecursiveInternal() +155
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
------------------------------
Code snippets
aspx
<
div
>
<
telerik:RadSpreadsheet
runat
=
"server"
ID
=
"rssTest"
></
telerik:RadSpreadsheet
>
</
div
>
aspx.vb
Protected
Sub
Page_Init(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init
Dim
provider
As
SpreadsheetDocumentProvider<br>
Dim
path
As
String
= Server.MapPath(
"~/App_Data/20150530_C09_Schedule.xlsx"
)
provider =
New
SpreadsheetDocumentProvider(path)
rssTest.Provider = provider
End
Sub
17 Answers, 1 is accepted
There are two possible reasons for the exception. The first is that you haven't included the Telerik Document Processing Library dlls into your project. The SpreadsheetDocumentProvider relies on these dll-s, as described in the following article:
http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/using-a-data-provider
The dlls you need to add into your project are listed here:
http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadprocessing/getting-started
If you already have added the dlls and the exception is still thrown, the other possible issue might be that the file cannot be read for some reason. If this is the case, please send us the file so that we may inspect what could be the problematic data.
Regards,
Bozhidar
Telerik

Yes, I have the DLLs you referenced. See Screenshot_1.
I created a new spreadsheet and only add "1" to cell A1 and saved.
I changed my Page_Init to use one line like your example so it looks like this.
Protected
Sub
Page_Init(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init rssTest.Provider =
New
SpreadsheetDocumentProvider(Server.MapPath(
"~/App_Data/SpreadsheetTest.xlsx"
))
End
Sub
Same result. I am attaching a screenshot of the spreadsheet. How do I send the file?

Code formatter fart.​
Protected
Sub
Page_Init(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init rssTest.Provider =
New
SpreadsheetDocumentProvider(Server.MapPath(
"~/App_Data/SpreadsheetTest.xlsx"
))
End
Sub
You cannot send attachments in forum threads. Please open a support ticket and attach the sample excel file there, so that we can inspect it on our end. Once we find the reason for the issue, we will post it in this thread.
Regards,
Bozhidar
Telerik


while Updating my telerik dll from 2015 to 2016 version. The SpreadSheet funcationality not working.
Please help me out in this.
Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.SpreadsheetDocumentProvider.GetSheets() +30 Telerik.Web.UI.RadSpreadsheet.PerformSelect() +58 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74 Telerik.Web.UI.RadSpreadsheet.EnsureDataBound() +53 Telerik.Web.UI.RadSpreadsheet.OnPreRender(EventArgs e) +27 System.Web.UI.Control.PreRenderRecursiveInternal() +88 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883

Hi Trent,
Which version of the dlls you got, I´m facing the same trouble.
thanks.
This exception can happen if the Excel file is opened by another process at the time you are trying to access it. Try closing the excel file and running the application again.
Regards,
Bozhidar
Telerik

Bozhidar,
Thanks but the file is closed, I'm using the spreadsheet inside a RadMultiPage control, I tried to but the spreadsheet control outside the multipage and it works.
Now my doubt is how can I emulate something similar like a RadMultiPage in order to achive the same behavior?
This control just accept .xlsx format?
Thanks in advance.
I tried the following confituration with the Spreadsheet inside a MultiPage and it again works as expected:
<
telerik:RadMultiPage
ID
=
"RadMultiPage1"
runat
=
"server"
SelectedIndex
=
"0"
>
<
telerik:RadPageView
ID
=
"RadPageView1"
runat
=
"server"
>
<
telerik:RadSpreadsheet
ID
=
"RadSpreadsheet1"
runat
=
"server"
></
telerik:RadSpreadsheet
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadSpreadsheet1.Provider =
new
SpreadsheetDocumentProvider(Server.MapPath(
"Book1.xlsx"
));
}
The Spreadsheet offers several databinding options, which are explained in detail in our online documentation:
http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/using-a-data-provider
http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/custom-database-provider
http://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/programmatic-binding
Regards,
Bozhidar
Telerik

Hi,
I tried RadMultiPage option as well as all other binding option but I am getting below error.
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.SpreadsheetDocumentProvider.GetSheets() +72 Telerik.Web.UI.RadSpreadsheet.PerformSelect() +110 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74 Telerik.Web.UI.RadSpreadsheet.EnsureDataBound() +98 System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22 Telerik.Web.UI.RadDataBoundControl.OnPreRender(EventArgs e) +36 Telerik.Web.UI.RadSpreadsheet.OnPreRender(EventArgs e) +80 System.Web.UI.Control.PreRenderRecursiveInternal() +88 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883
I am using Telerik.Web.Spreadsheet v2016.1.108.45
Please advice.
Thanks.
Follow the suggestions from the previous posts in this thread, and if this doesn't help you can open a support ticket and send us a sample project, so that we can take a look at your concrete implementation.
Regards,
Bozhidar
Telerik

I using <telerik:RadSpreadsheet runat="server" ID="RadSpreadsheet1" > control in my asp.net project to open an excel file.
The funny thing is sometimes it works but sometimes it doesn't work and throw a very common error which is "Object reference not set to an instance of an object."
Hi keng,
Such error is usually thrown when one of the main libraries needed by the Spreadsheet are not referenced. In case you are deploying the app into Load balanced environment, make sure that the DLLs are referenced in all servers:
Regards,
Vessy
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Dear Admin,
Thanks for your reply, but the funny things is I use it to open the excel file in the same application, 1 file can open and the other 1 cannot, i check across both file and couldn't find there is any differences between these 2 files.

Hi Keng,
Can you try the approach from this article and see what the behavior will be?
Namely:
var path = Server.MapPath("~/App_Data/spreadsheet.xlsx");
SpreadsheetProvider = new SpreadsheetDocumentProvider(path);
var sheets = SpreadsheetProvider.GetSheets();
Another option is to load the files directly on the client-side, avoiding the server-side operations which are using the DPL library:
Regards,
Vessy
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).