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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exporting Unbound Rows from SfDataGrid to PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

144427 May 6,2019 10:20 AM UTC May 29,2019 08:59 AM UTC Xamarin.Forms 6
loading
Tags: SfDataGrid
Julian
Asked On May 6, 2019 10:20 AM UTC

I am using a SfDataGrid which DataSource is bound to an ObservableCollection.
For further information in terms of data evaluation I added a TableSummaryRow and serveral UnboundRows.
The complete SfDataGrid should be able to be exported to Excel and also to PDF.
As mentionend in Your Documentation UnboundRows are not exported by Default.
Therefor I edited the DataGridExcelExportingOption and DataGridPdfExportOption as following code snippets show:

Excel:
            DataGridExcelExportingController excelExport = new DataGridExcelExportingController();
            var excelEngine = excelExport.ExportToExcel(sfDataGrid, new DataGridExcelExportingOption()
            {
                ExportTableSummary = true,
                ExportUnboundRows = true,
            });
            var workbook = excelEngine.Excel.Workbooks[0];
            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            //Holen der plattformspezifischen Implementierung des Interfaces mittels DependecyService
            DependencyService.Get<IFileOperator>().Save("DataGrid.xlsx", "application/msexcel", stream);

PDF:
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();
            MemoryStream stream = new MemoryStream();
            var exportToPdf = pdfExport.ExportToPdf(sfDataGrid, new DataGridPdfExportOption()
            {
                ExportTableSummary = true,
                //ExportUnboundRows = true, //!!!"NullReference"!!!
                FitAllColumnsInOnePage = true,
            });
            exportToPdf.Save(stream);
            exportToPdf.Close(true);

            //Holen der plattformspezifischen Implementierung des Interfaces mittels DependecyService           
            DependencyService.Get<IFileOperator>().Save("DataGrid.pdf", "application/pdf", stream);

While the Excel-Export works perfectly fine (showing TableSummaryRow and UnboundRow), the PDF-Export just is able to export the TableSummaryRow.
Trying to export the UnboundRow throws an exception:


NameWertTyp
$exception{System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.SfDataGrid.XForms.Exporting.DataGridPdfExportingController.ExportUnboundRowToPdf(SfDataGrid dataGrid, PdfGridRow pdfRow, DataGridPdfExportOption exportOption, GridUnboundRow gridUnboundRow, ExportCellType cellType) at Syncfusion.SfDataGrid.XForms.Exporting.DataGridPdfExportingController.ExportUnboundRowsToPdf(SfDataGrid dataGrid, PdfGrid pdfGrid, DataGridPdfExportOption exportOption, UnboundRowsPosition position, Boolean belowSummary, ObservableCollection`1 unBoundRows) at Syncfusion.SfDataGrid.XForms.Exporting.DataGridPdfExportingController.ExportToPdfGrid(SfDataGrid dataGrid, ICollectionViewAdv collectionView, DataGridPdfExportOption exportOption, PdfDocument pdfDocument) at Syncfusion.SfDataGrid.XForms.Exporting.DataGridPdfExportingController.ExportToPdf(SfDataGrid dataGrid, ICollectionViewAdv collectionView, DataGridPdfExportOption exportOption) at Syncfusion.SfDataGrid.XForms.Exporting.DataGridPdfExportingController.ExportToPdf(SfDataGrid dataGrid, DataGridPdfExportOption exportOption) at XSyncfusionContentViews.ViewModels.XTableOperatorButtonsViewModel.ExportToPDF(SfDataGrid sfDataGrid) at XSyncfusionContentViews.Views.XTableOperatorButtonsView.Pdf_Clicked(Object sender, EventArgs e) at Xamarin.Forms.Button.Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked() at Xamarin.Forms.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) at Xamarin.Forms.Button.SendClicked() at Xamarin.Forms.Platform.UWP.ButtonRenderer.OnButtonClick(Object sender, RoutedEventArgs e)}System.NullReferenceException

I am using the following versions of NuGet-Packages:

- Syncfusion.Xamarin.DataGridExport 16.4.0.54
- Syncfusion.Xamarin.Pdf 16.4.0.54
- Syncfusion.Xamarin.SfDataGrid 16.4.0.54
- Syncfusion.Xamarin.XlsIO 16.4.0.54

I would be glad, if You can help me find a solution for this particular problem. I am looking forward to hear from You soon.

Kind regards

Julian


Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 6, 2019 10:40 AM UTC

Hi Julian, 
 
Thank you for contacting Syncfusion support.

We have already found and fixed the mentioned issue “Throws exception when exporting the DataGrid with UnBoundRows to PDF” in Xamarin.Forms. The issue fix has been included the issue fix in our weekly NuGet update version 17.1.0.41 and is available for download (nuget.org). This issue fix will be including in 2019 Volume 1 Service pack release which is expected to be available by next of May 2019.  
  
Please let us know, if you have any concern. 
  
Regards,
Subburaj Pandian V  


Julian
Replied On May 6, 2019 11:08 AM UTC

Hi Subburaj Pandian V,

I updated all my used NuGet-Packages to version 17.1.0.43 (newest stable version), but the problem remains the same :/

Regards,

Julian

Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 7, 2019 08:40 AM UTC

Hi Julian, 
  
Thank you for update. 
  
We have checked the reported query "Exception is raised when we try to export DataGrid with unbound rows in Xamarin.Forms" and it working as expected from our side. We cannot able to reproduce the issue from our end with the provided information. We have attached the for your reference. 
   
   
Please check the sample and let us know if you’re still facing the same issue? If not, please modify the sample based on your scenario and revert us back with replication procedure to replicate the issue along with the following details, 
 
·       Xamarin.Forms version. 
·       Issue reproducing platform. 
 
It will be helpful for us to check on it and provide you the solution. 
 
Regards,
Subburaj Pandian V 


Julian
Replied On May 7, 2019 08:53 PM UTC

Hi Subburaj Pandian V,

thanks for the sample. I have tested it without doing any changes. That way it works fine.

Then I did some little changes to meet my purposes:

- You will see some changes in the "ExportToPdf"-method from "MainPage" but these are not causing the error.
- You will see some changes in the constructor from "MainPage", because I need the GridUnboundRow created programmatically. This little change results in my mentioned exception!

For more detail take a look at the attached zip-file.

I have not changed the Xamarin.Forms version.
I have tested it under UWP.

Now You should be able to reproduce it. If You still need any further information, feel free to cantact me.

Regards,

Julian

Attachment: ExpprtUnBoundRow1541713638_UPDATED_c28a637b.zip

Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 8, 2019 11:37 AM UTC

Hi Julian, 
 
Thank you for the update. 
  
We have checked and we can able to replicate the reported issue “Exception is raised when we try to export DataGrid with unbound rows” in Xamarin.Forms. We have logged issue report for the same, we will fix this issue and include the issue fix in our weekly NuGet update and it will be available on May 28, 2019. We appreciate your patience until then. 
  
You can also track the status of the report by following feedback link, 
  
 
Regards,
Subburaj Pandian V 


Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 29, 2019 08:59 AM UTC

Hi Julian,  
    
We have fixed the reported issue “Exception is raised when we try to export DataGrid with unbound rows” and included the issue fix in our weekly NuGet package update version 17.1.0.49 and is available for download (nuget.org). This issue fix will be included in our upcoming 2019 Volume 2 release as well. 
 
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance. 
 
Regards,
Subburaj Pandian V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon