This is a migrated thread and some comments may be shown as answers.

Exception when copy pasting data from gridview to excel

4 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mausami
Top achievements
Rank 1
Mausami asked on 20 Jun 2011, 02:41 PM
Hello Telerik team,

With the below grid settings I select multiple cells of the grid keeping the Ctrl button pressed.

<telerik:RadGridView x:Name="radgvActivity" 
                             Grid.Row="2"
                             Margin="0" 
                             IsReadOnly="False"
                             RowIndicatorVisibility="Visible"                                                          
                             ScrollMode="RealTime"
                             AutoGenerateColumns="False" 
                             EnableRowVirtualization="True"
                             CanUserFreezeColumns="False" 
                             CanUserResizeColumns="True"                            
                             Width="780" Height="600"
                             SelectionMode="Extended"
                             ClipboardCopyMode="All"
                             ClipboardPasteMode="Default"
                             SelectionUnit="Cell"
                             BeginningEdit="radgvActivity_BeginningEdit"
                             RowEditEnded="radgvActivity_RowEditEnded"
                             >



Now, on click of Ctrl + C, I get a System.NullReferenceException {"Object reference not set to an instance of an object."}
Please find the stack trace of the exception.

at Telerik.Windows.Controls.GridView.Clipboard.Writers.WriterBase.<GetSelectedItemsAsClipboardData>b__3(GridViewColumn c)
at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count)
at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
at System.Linq.Enumerable.ElementAtOrDefault[TSource](IEnumerable`1 source, Int32 index)
at Telerik.Windows.Controls.GridView.Clipboard.Writers.WriterBase.RenderHeaderRow()
at Telerik.Windows.Controls.GridView.Clipboard.Writers.WriterBase.Render()
at Telerik.Windows.Controls.GridView.Clipboard.Writers.HtmlWriter.Render()
at Telerik.Windows.Controls.GridView.GridViewDataControl.CopyToClipboard()
at Telerik.Windows.Controls.GridView.GridViewDataControl.CopyExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
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.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
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.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
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, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
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.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at ~\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I donot get this exception on setting the selection unit to fullrow. SelectionUnit="FullRow"


Please help with this matter.



Thanks,
Regards,
Mausami

4 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 20 Jun 2011, 02:48 PM
Hi Mausami,

 Would it be possible for you to post a screen shot of your RadGridView with the cells selected before you try to copy its contents?

All the best, Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mausami
Top achievements
Rank 1
answered on 20 Jun 2011, 07:36 PM
Hi Yavor,

Could you please let me know how can I attach the snapshots.
I don't see any option for attachment.


Regards,
Thanks,
Mausami

0
Mausami
Top achievements
Rank 1
answered on 20 Jun 2011, 07:56 PM
Hi Yavor,

Could you please let me know how can I attach the snapshots.
I don't see any option for attaching.

Anyways, below is the content of the cells selected

cell1 : ACTTEMP1151
cell2 : ACTTEMP1156
cell3 : CAPPS_AN
cell4 : HILL_GR
 
The cells are located at different places and selected randomly.
I don't get the exception only for particular cells selection but always when I press Ctrl + C after selecting any random cells.

Here's the gridview

<telerik:RadGridView x:Name="radgvActivity" 
    Grid.Row="2"
    Margin="0" 
    IsReadOnly="False"
    RowIndicatorVisibility="Visible" 
    ScrollMode="RealTime"
    AutoGenerateColumns="False" 
    EnableRowVirtualization="True"
    CanUserFreezeColumns="False" 
    CanUserResizeColumns="True" 
    Width="780" Height="600"
    SelectionMode="Extended"
    ClipboardCopyMode="All"
    ClipboardPasteMode="Default"
    SelectionUnit="Cell"
    BeginningEdit="radgvActivity_BeginningEdit"
    RowEditEnded="radgvActivity_RowEditEnded"
  <telerik:RadGridView.Resources>
   <Style TargetType="{x:Type telerik:GridViewRow}">
    <Setter Property="BorderThickness" Value="1"></Setter>
    <Style.Triggers>
        <DataTrigger Binding="{Binding Path=ActType}" Value="4">
            <DataTrigger.Setters>
                <Setter Property="BorderBrush" Value="Red" />
            </DataTrigger.Setters>
        </DataTrigger>
    </Style.Triggers>
   </Style>
  </telerik:RadGridView.Resources>
  <telerik:RadGridView.Columns
    <telerik:GridViewDataColumn DataMemberBinding="{Binding ActId}" Header="ACTID" IsReadOnly="True"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding ActivityTitle}" Header="ACTIVITYTITLE" /> 
    <telerik:GridViewDataColumn DataMemberBinding="{Binding ActType}" Header="ACTTYPE" TextWrapping= "Wrap" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding PME}" Header="PME" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding PROJ}" Header="PROJ" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Sched}" Header="SCHED" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Cust}" Header="CUST" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Grp}" Header="GRP" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Subg}" Header="SUBG" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Resp}" Header="RESP" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Focal}" Header="FOCL" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding TES}" Header="TES" DataFormatString="{}{0:MM-dd-yyyy}"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding TEF}" Header="TEF" DataFormatString="{}{0:MM-dd-yyyy}" />
  </telerik:RadGridView.Columns>
</telerik:RadGridView>


Regards,
Thanks,
Mausami
0
Milan
Telerik team
answered on 21 Jun 2011, 07:49 AM
Hello Mausami,

Could you please download our latest internal build which should resolve this problem. 

Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Mausami
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Mausami
Top achievements
Rank 1
Milan
Telerik team
Share this question
or