This example illustrates how you can export a cell range to a System.Data.DataTable object.
Question Comments
Added By:
Juan Capiau - D at:
7/29/2014 6:55:38 AM I'm trying this example and the 'Export Worksheet Table Using Exporter Options' throws an error (Index was out of range) on Sub barButtonItemUseExporterOptions_ItemClick, line 'Dim range As Range = worksheet.Tables(0).Range'. i've tried multiple files, none work. If i select a range and export that (the 'Export Selected Range to Data Table') there is no problem. How can I fix this ?
System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
ParamName=index
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at DevExpress.XtraSpreadsheet.API.Native.Implementation.NativeCollectionBase`3.get_Item(Int32 index)
at ExportToDataTableExample.Form1.barButtonItemUseExporterOptions_ItemClick(Object sender, ItemClickEventArgs e) in C:\Users\JCA\Documents\Samples\XtraSpreadSheet\14.1.5\E4997\ExportToDataTableExample\ExportToDataTableExample\Form1.vb:line 68
at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarItemLink.OnLinkClick()
at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPressItem(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPress(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.RibbonControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
at DevExpress.XtraBars.Ribbon.RibbonControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at DevExpress.Utils.Win.Hook.ControlWndHook.CallWindowProc(IntPtr pPrevProc, IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
at DevExpress.Utils.Win.Hook.ControlWndHook.WindowProc(IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ExportToDataTableExample.Program.Main() in C:\Users\JCA\Documents\Samples\XtraSpreadSheet\14.1.5\E4997\ExportToDataTableExample\ExportToDataTableExample\Program.vb:line 45
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Added By:
Brian (DevExpress) at:
7/29/2014 7:25:34 AM Please make sure that the document loaded in the SpreadsheetControl has a table. If it does not, insert a table using the
Insert Table command in the
Insert ribbon group, or use the Spreadsheet API as described in the
How to: Create a Table document.Added By:
Juan Capiau - D at:
8/1/2014 7:04:15 AM Not sure we're talking about the same thing. there is also no 'insert table' command or an insert ribbon group. Either i'm missing something basic (which is entirely possible) or the example is not complete. i'd like to understand the functionality and since this is an example that is supposed to do just that.... if you can assist, i'd appreciate it.
Added By:
Ted (DevExpress Support) at:
8/4/2014 12:53:39 AM Hello Juan,
I have extracted your original message with an exception description to a separate ticket - T136499: ArgumentOutOfRangeException is raised in the E4997 example. Our team will address it as soon as possible.