ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2016-02-27 08:09:52

maibo
Member
Registered: 2016-01-27
Posts: 15

SetRangeDataFormat数字类型,当参数NumberFormatArgs为空时,无法生成excel

代码如下:
var worksheet = grid.CurrentWorksheet;
worksheet[0, 0] = 100;
worksheet.SetRangeDataFormat(0, 0, 1, 1, unvell.ReoGrid.DataFormat.CellDataFormatFlag.Number, null);
生成excel的代码为:
grid.Save(@"r:\\1.xlsx", unvell.ReoGrid.IO.FileFormat.Excel2007);
出错信息如下:
未处理System.NullReferenceException
  HResult=-2147467261
  Message=未将对象引用设置到对象的实例。
  Source=unvell.ReoGrid
  StackTrace:
       在 ay.a(CellDataFormatFlag A_0, Object A_1, Stylesheet A_2)
       在 ay.a(bu A_0, WorksheetRangeStyle A_1, Nullable`1 A_2, Nullable`1 A_3, Nullable`1 A_4, Nullable`1 A_5, CellDataFormatFlag A_6, Object A_7)
       在 ay.a(bu A_0, Worksheet A_1)
       在 ay.a(IWorkbook A_0, Stream A_1)
       在 cu.Save(IWorkbook workbook, Stream stream, Encoding encoding, Object arg)
       在 dv.Save(Stream stream, FileFormat fileFormat, Encoding encoding)
       在 dv.Save(String path, FileFormat fileFormat, Encoding encoding)
       在 unvell.ReoGrid.ReoGridControl.Save(String path, FileFormat fileFormat, Encoding encoding)
       在 unvell.ReoGrid.ReoGridControl.Save(String path, FileFormat fileFormat)
       在 WpfApplication2.MainWindow.Button_Click_2(Object sender, RoutedEventArgs e) 位置 i:\ReoGrid-1.1.0-All-Packages\WpfApplication1\WpfApplication2\MainWindow.xaml.cs:行号 150
       在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       在 System.Windows.Controls.Button.OnClick()
       在 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       在 System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       在 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       在 System.Windows.Input.InputManager.ProcessStagingArea()
       在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       在 System.Windows.Application.RunInternal(Window window)
       在 System.Windows.Application.Run()
       在 WpfApplication2.App.Main() 位置 i:\ReoGrid-1.1.0-All-Packages\WpfApplication1\WpfApplication2\obj\Debug\App.g.cs:行号 0
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Last edited by maibo (2016-02-27 08:28:44)

Offline

#2 2016-02-27 08:11:17

maibo
Member
Registered: 2016-01-27
Posts: 15

Re: SetRangeDataFormat数字类型,当参数NumberFormatArgs为空时,无法生成excel

改成
worksheet.SetRangeDataFormat(worksheet.Ranges[0, 0, 1, 1], unvell.ReoGrid.DataFormat.CellDataFormatFlag.Number, new unvell.ReoGrid.DataFormat.NumberDataFormatter.NumberFormatArgs
                {
                    DecimalPlaces = 1,
                });
就没问题。

Last edited by maibo (2016-02-27 08:28:59)

Offline

#3 2016-02-27 08:41:57

oops
Moderator
Registered: 2015-11-03
Posts: 54

Re: SetRangeDataFormat数字类型,当参数NumberFormatArgs为空时,无法生成excel

感谢 maibo,问题已经确认,将尽快修正。

Offline

#4 2016-02-27 15:13:16

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: SetRangeDataFormat数字类型,当参数NumberFormatArgs为空时,无法生成excel

This problem has been fixed in version 1.2, which can be downloaded from: https://reogrid.net/cn/download. Thanks for reporting!

Offline

#5 2016-02-28 06:14:31

maibo
Member
Registered: 2016-01-27
Posts: 15

Re: SetRangeDataFormat数字类型,当参数NumberFormatArgs为空时,无法生成excel

谢谢!

Offline

Board footer

Powered by FluxBB