Hey,
I am facing issues in exporting to excel from SfDataGrid. It gives a null reference exception on this line:
var excelEngine = StudentsDataGrid.ExportToExcel(StudentsDataGrid.View, options);
The exception message and StackTrace is as mentioned below:
Message: "Object reference not set to an instance of an object."
Source: "Syncfusion.SfGridConverter.WPF"
StackTrace: " at Syncfusion.UI.Xaml.Grid.Converter.SfDataGridToExcelConverter.ExportDetailsViewToExcel(SfDataGrid parentDataGrid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, Object rec, IPropertyAccessProvider propertyAccessProvider)\r\n at Syncfusion.UI.Xaml.Grid.Converter.SfDataGridToExcelConverter.ExportRecordsToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, IEnumerable records, IPropertyAccessProvider propertyAccessProvider, Group group)\r\n at Syncfusion.UI.Xaml.Grid.Converter.SfDataGridToExcelConverter.ExportToExcelWorksheet(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)\r\n at Syncfusion.UI.Xaml.Grid.Converter.SfDataGridToExcelConverter.ExportToExcel(SfDataGrid grid, ICollectionViewAdv view, ExcelExportingOptions excelExportingOptions)\r\n at Syncfusion.UI.Xaml.Grid.Converter.GridExcelExportExtension.ExportToExcel(SfDataGrid grid, ICollectionViewAdv gridCollectionView, ExcelExportingOptions excelExportingOptions)\r\n at MainModule.Views.FacultyHome.ExportStudentsClick(Object sender, RoutedEventArgs e) in E:\\MyApps\\AtomV2\\MainModule\\Views\\FacultyHome.xaml.cs:line 27\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)\r\n at System.Windows.Controls.Primitives.ButtonBase.OnClick()\r\n at System.Windows.Controls.Button.OnClick()\r\n at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)\r\n at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)\r\n at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)\r\n at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)\r\n at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n at System.Windows.Input.InputManager.ProcessStagingArea()\r\n at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)\r\n at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)"
TargetSite: {Void ExportDetailsViewToExcel(Syncfusion.UI.Xaml.Grid.SfDataGrid, Syncfusion.XlsIO.IWorksheet, Syncfusion.UI.Xaml.Grid.Converter.ExcelExportingOptions, System.Object, Syncfusion.Data.IPropertyAccessProvider)}
Thanks in advance for the help!
Regards
Ahmad Uzair