You are not logged in.
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.
Pages: 1
Topic closed
代码如下:
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
改成
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
感谢 maibo,问题已经确认,将尽快修正。
Offline
This problem has been fixed in version 1.2, which can be downloaded from: https://reogrid.net/cn/download. Thanks for reporting!
Offline
谢谢!
Offline
Pages: 1
Topic closed