Hi,
I need to apply a formula into the selected WorksheetRegion. I'm using the following code to achieve this:
var selectionRange = _grid.ActiveSelection.CellRanges.First(); formula.ApplyTo(new WorksheetRegion(_grid.ActiveWorksheet, selectionRange.FirstRow, selectionRange.FirstColumn, selectionRange.LastRow, selectionRange.LastColumn));
It works well, except when I try to copy and paste the resulting data. A couple of copy/pastes causes the following null reference exception:
System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Documents.Excel.Serialization.BIFF8.Biff8RecordStream.WriteRefU(WorksheetRegion region) at Infragistics.Documents.Excel.Serialization.BIFF8.BiffRecords.SHRFMLARecord.Save(WorkbookSaveManagerExcel2003 saveManager) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.WriteRecord(BIFF8RecordType type) at Infragistics.Documents.Excel.Serialization.BIFF8.BiffRecords.FORMULARecord.SaveCellValue(WorkbookSaveManagerExcel2003 saveManager, MemoryStream initialData) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.WriteRecord(BIFF8RecordType type) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.WriteCellRecord() at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.<>c__DisplayClass15.<>c__DisplayClass17.<WriteWorksheetRowBlock>b__12(CellDataContext cellDataContext) at Infragistics.Documents.Core.Async.ForEachSliceHelper`1.ExecuteNext() at Infragistics.Documents.Core.Async.Try(Func`1 try, Action finally) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.<>c__DisplayClass15.<WriteWorksheetRowBlock>b__11(WorksheetRow row) at Infragistics.Documents.Core.Async.ForEachHelper`1.ExecuteNext() at Infragistics.Documents.Core.WorkItem.WorkItemAsync.ExecuteCore(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)--- End of stack trace from previous location where exception was thrown --- at TryThrowExceptionDispatchInfo(Object ) at Infragistics.Documents.Core.WorkItem.ExceptionInfo.Rethrow() at Infragistics.Documents.Core.WorkItemExtensions.GetResult[TResult](WorkItem`1 this) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.<>c__DisplayClass21.<WriteWorksheetRowBlocks>b__1f(WorkItem`1 t) at Infragistics.Documents.Core.WorkItem.WorkItemSync.ExecuteCore(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)--- End of stack trace from previous location where exception was thrown --- at TryThrowExceptionDispatchInfo(Object ) at Infragistics.Documents.Core.WorkItem.ExceptionInfo.Rethrow() at Infragistics.Documents.Core.WorkItemExtensions.GetResult[TResult](WorkItem`1 this) at Infragistics.Documents.Excel.Serialization.WorkbookSaveManagerExcel2003.<>c__DisplayClassc.<SaveWorksheet>b__b(WorkItem`1 t) at Infragistics.Documents.Core.WorkItem.WorkItemSync.ExecuteCore(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)--- End of stack trace from previous location where exception was thrown --- at TryThrowExceptionDispatchInfo(Object ) at Infragistics.Documents.Core.WorkItem.ExceptionInfo.Rethrow() at Infragistics.Documents.Core.WorkItemExtensions.<ExecuteWithDefaultScheduler>b__0(WorkItem t) at Infragistics.Documents.Core.WorkItem.WorkItemSync.ExecuteCore(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)--- End of stack trace from previous location where exception was thrown --- at TryThrowExceptionDispatchInfo(Object ) at Infragistics.Documents.Core.WorkItem.ExceptionInfo.Rethrow() at Infragistics.Documents.Core.WorkItem.RunNextWorkItem(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler) at Infragistics.Documents.Core.WorkItemScheduler.SynchronousImpl.Execute(WorkItem workItem) at Infragistics.Documents.Excel.Workbook.Save(Stream stream, WorkbookSaveOptions saveOptions) at Infragistics.Controls.Grids.Core.IGExcelSerializationProvider.Save(WorkbookDataObjectSaveContext context) at Infragistics.Controls.Grids.Core.WorkbookDataObjectManager.CreateDataObject(Boolean isDragDrop) at Infragistics.Controls.Grids.Core.WorkbookDataObjectManager.CopyToClipboard() at Infragistics.Controls.Grids.Core.Spreadsheet.ExecuteCommand(SpreadsheetCommandType command, Object commandParameter, Object sourceElement, Int64 currentState) at Infragistics.Controls.Grids.Core.Spreadsheet.ProcessKeyDown(Key key, ModifierKeys modifierKeys) at Infragistics.Controls.Grids.XamSpreadsheet.ProcessKeyDown(KeyEventArgs e) at Infragistics.Controls.Grids.Primitives.SpreadsheetCellEditor.OnKeyDown(KeyEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers) at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled) at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled) at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at Desktop.App.Main()
Hello Tg,
I have been looking into your issue but unfortunately I am not able to reproduce it. Can you please provide me with information what version of our components you are using and review the sample that I have created for you and see whether it works on your environment or try to modify in such a way that I can reproduce it also?
The steps I tried are:1) Select some region (e.g. D1:F1)2) Press the button "ApplyFormula"3) Copy the selected region4) Paste the date somewhere else
And didn't notice nothing strange and NRE was not thrown.
I am looking forward to hearing from you.
I am using Infragistics WPF 15.2. I tried your sample, and it also fails (this time when pasting). It's still probably the same problem though.
The steps to reproduce this:
1) Select some region
2) Press the button "ApplyFormula"
3) Copy some part of the resulting data
4) Paste it
5) Copy some other part of the data
6) Paste it
Hi Tg,
I was able to reproduce the issue. On step 6) I am getting an error dialog with the following text: "An error occurred during the paste operation:Value cannot be null.Parameter name: address"
I have logged this behavior in our tracking system, with an issue ID of 223524. I have also created a support ticket on your behalf with number CAS-176232-K5K1W1 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
Is there any estimate when this bug will be fixed? It is really annoying and is preventing me from releasing a product.
Best regards,
Antti
Hello,
The fix for development issue 223524 is available in the latest Service Release and can be downloaded from the Keys and Downloads page.
Thank you for using Infragistics Components.
Sincerely,
Teodor
Issue "223524: Copy pasting cells with formula is throwing error dialog" has been fixed and verified by our Engineering Team in the following versions WPF_2016.1, WPF_2016.2. You can expect this fixed in the next Service Release. For more information you can have a look at the case(CAS-176232-K5K1W1) that I have created for you.
Sincerely,Teodor