Excel Data Reader - reading .xlsx

Dec 5, 2012 at 2:04 PM
Edited Dec 5, 2012 at 2:17 PM

Using Windows XP, RS2005 and Winform/C# I just downloaded the Excel Data reader v.2.0.1.0.  Using the code I can read a .xls excel file just fine but I cannot get it to read a .xlsx file.

I am getting an index out of range message.  I created a excel file (2003) and saved it as a .xls and then again as .xlsx.

System.ArgumentOutOfRangeException was unhandled
  Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Excel.ExcelOpenXmlReader.InitializeSheetRead()
       at Excel.ExcelOpenXmlReader.Read()
       at Test.Form1.btnPopulate_Click(Object sender, EventArgs e) in C:\Documents and Settings\haberej\My Documents\Visual Studio 2005\Projects_C\Test\Test\Form1.cs:line 40
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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 Test.Program.Main() in C:\Documents and Settings\haberej\My Documents\Visual Studio 2005\Projects_C\Test\Test\Program.cs:line 17
       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()

 

Will this work with Excel 2010 (Win-7) as XP CPU are slowly being replaced with these

 

Developer
Dec 12, 2012 at 3:11 PM

Are you able to supply and example xlsx where this happens?