We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

export to excel from grid

hi,

i got error in export to excel from grid. when click excel button i got below error

"Object reference not set to an instance of an object."

plz help me

Attachment: error_f3234d7a.rar

6 Replies

JK Jayaprakash Kamaraj Syncfusion Team May 2, 2016 01:02 PM UTC

Hi Satheyaraaj, 

Thanks for contacting Syncfusion support. 

We were unable to reproduce the issue. But we suspect that the issue occurs when a column field is not defined in the Grid dataSource and obtained as null value, and hence throws a null exception.  
Refer to the following knowledgebase document.

https://www.syncfusion.com/kb/3018/Null-Exception-while-exporting 

 If you still face the issue, share the following information to find the cause of the issue. 
1.       Client side and server side full code example. 
2.       Are you performing any Grid operations like filtering\searching before exporting? 
3.       Essential studio version. 
4.       An issue reproducing sample if possible or sample hosted link or replicate the issue in the following sample. 
 
Regards, 
 
Jayaprakash K. 



SA satheyaraaj May 3, 2016 01:05 PM UTC

Hi,

Same error continues. im using Essential Studio Version.

Datasource Assign Code :

         grdvwConrpt.DataSource = dt
        grdvwConrpt.DataBind()




SA satheyaraaj replied to Jayaprakash Kamaraj May 3, 2016 01:07 PM UTC

Hi Satheyaraaj, 

Thanks for contacting Syncfusion support. 

We were unable to reproduce the issue. But we suspect that the issue occurs when a column field is not defined in the Grid dataSource and obtained as null value, and hence throws a null exception.  
Refer to the following knowledgebase document.

https://www.syncfusion.com/kb/3018/Null-Exception-while-exporting 

 If you still face the issue, share the following information to find the cause of the issue. 
1.       Client side and server side full code example. 
2.       Are you performing any Grid operations like filtering\searching before exporting? 
3.       Essential studio version. 
4.       An issue reproducing sample if possible or sample hosted link or replicate the issue in the following sample. 
 
Regards, 
 
Jayaprakash K. 


Hi,

Same error continues. im using Essential Studio Version.

Datasource Assign Code :

         grdvwConrpt.DataSource = dt
        grdvwConrpt.DataBind()


JK Jayaprakash Kamaraj Syncfusion Team May 4, 2016 09:41 AM UTC

Hi Satheyaraaj, 
 
Thanks for the update. 
 
We suspect that you have bound dataTable as dataSource for the Grid, which is the cause of the reported issue. We have provided “DataTable support while exporting” from v14.1.0.41. So, if you are using older version, please upgrade to our latest version. 
 
After doing the above, if the issue has still not resolved, please provide the following 
 
1.     Datatype of your dataSource 
2.     Ensure if you have referred the v14.1.0.41 dll’s, scripts and css in your sample project? 
3.     Grid rendering code and server side exporting code. 
4.     Issue reproducible sample or sample hosted link or replicate the issue in the attached sample. 
 
We have created a sample, which can be downloaded from below location. 
 
 
Regards, 
 
Jayaprakash K. 



SA satheyaraaj replied to Jayaprakash Kamaraj May 20, 2016 06:17 AM UTC

Hi Satheyaraaj, 
 
Thanks for the update. 
 
We suspect that you have bound dataTable as dataSource for the Grid, which is the cause of the reported issue. We have provided “DataTable support while exporting” from v14.1.0.41. So, if you are using older version, please upgrade to our latest version. 
 
After doing the above, if the issue has still not resolved, please provide the following 
 
1.     Datatype of your dataSource 
2.     Ensure if you have referred the v14.1.0.41 dll’s, scripts and css in your sample project? 
3.     Grid rendering code and server side exporting code. 
4.     Issue reproducible sample or sample hosted link or replicate the issue in the attached sample. 
 
We have created a sample, which can be downloaded from below location. 
 
 
Regards, 
 
Jayaprakash K. 


Hi,

I'm using  v14.1.0.41. i copied your sample code and use my project. but same error occurred. 
note : im using master page.

 my code :

 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then

            lssql = "SELECT * from Orders"
            If dbConn.State = ConnectionState.Closed Then dbConn.Open()
            cmdCStr = New SqlCommand(lssql, dbConn)
            adapter.SelectCommand = cmdCStr
            adapter.Fill(ds)

            Grid1.DataSource = ds
            Grid1.DataBind()


            Response.Buffer = True
            Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0)
            Response.Expires = -1500
            Response.CacheControl = "no-cache"
        End If
    End Sub

    Protected Sub FlatGrid_ServerExcelExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
        Dim exp As New ExcelExport()
        exp.Export(Grid1.Model, DirectCast(Grid1.DataSource, DataTable), "Export.xlsx", ExcelVersion.Excel2010, True, True, "flat-lime")
    End Sub

    Protected Sub FlatGrid_ServerWordExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
        Dim exp As New WordExport()
        exp.Export(Grid1.Model, DirectCast(Grid1.DataSource, DataTable), "Export.docx", True, True, "flat-lime")
    End Sub

    Protected Sub FlatGrid_ServerPdfExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
        Dim exp As New PdfExport()
        exp.Export(Grid1.Model, DirectCast(Grid1.DataSource, DataTable), "Export.pdf", True, True, "flat-lime")
    End Sub

Thanks & Regards
Satheyaraaj PT


JK Jayaprakash Kamaraj Syncfusion Team May 23, 2016 12:55 PM UTC

Hi Satheyaraaj, 

We have created a sample with 14.1.0.41 version and we have used your codes in master page. But, mentioned issue is not reproducing at our end and we have attached video for your reference. 



     If you are still facing the issue, please share the following:                                                                            
1.       please ensure you are referred 14.1.0.41 dll’s in your sample  
2.       given sample changed into issue reproducible. 

Regards, 

Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon