Error: Invalid file signature

Apr 3, 2009 at 11:18 PM
When I try to open an xls spreadsheet with the Excel stream reader I get the following error:

Excel.Exceptions.InvalidHeaderException was unhandled
  Message="Error: Invalid file signature"
  Source="Excel"
  StackTrace:
       at Excel.Core.XlsHeader.ReadHeader(Stream file) in C:\Documents and Settings\steveh\My Documents\Visual Studio 2008\Projects\ExcelDataReader\Excel\Core\XlsHeader.cs:line 232
       at Excel.ExcelDataReader..ctor(Stream fileStream, Boolean promoteToColumns) in C:\Documents and Settings\steveh\My Documents\Visual Studio 2008\Projects\ExcelDataReader\Excel\ExcelDataReader.cs:line 58
       at Excel.ExcelDataReader..ctor(Stream fileStream) in C:\Documents and Settings\steveh\My Documents\Visual Studio 2008\Projects\ExcelDataReader\Excel\ExcelDataReader.cs:line 42
       at ExcelStreamLibraryTest.Program.Main(String[] args) in C:\Documents and Settings\steveh\My Documents\Visual Studio 2008\Projects\ExcelStreamLibrary\ExcelStreamLibraryTest\Program.cs:line 16
       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()
  InnerException:
May 11, 2009 at 8:43 AM
Edited May 11, 2009 at 8:47 AM

I have the same broplem:

Excel.Exceptions.InvalidHeaderException: Error: Invalid file signature
   at Excel.Core.XlsHeader.ReadHeader(Stream file) in E:\Download\excel\exceldatareader-10542\Excel\Core\XlsHeader.cs:line 232
   at Excel.ExcelDataReader..ctor(Stream fileStream, Boolean promoteToColumns) in E:\Download\excel\exceldatareader-10542\Excel\ExcelDataReader.cs:line 58
   at Excel.ExcelDataReader..ctor(Stream fileStream) in E:\Download\excel\exceldatareader-10542\Excel\ExcelDataReader.cs:line 42
   at MyTest.Form1.button1_Click(Object sender, EventArgs e) in E:\Download\excel\exceldatareader-10542\MyTest\Form1.cs:line 23
   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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

May 11, 2009 at 10:14 AM

Oh, my excel file does not correcly.

Mar 16, 2012 at 2:43 PM

Hi,

I'm getting the same problem. Any suggestion so far?

thanks

PP

Jul 20, 2012 at 2:42 PM

Same problem here I can upload file if needed any idea what can cause this ?

Jul 20, 2012 at 3:12 PM

Ok I think I found my issue,

There are two methods

1) ExcelReaderFactory.CreateBinaryReader(

2) ExcelReaderFactory.CreateOpenXmlReader(

first method is for reading *.xls and second one is for *xlsx file types,

for my case I used 1) method with .xlsx file and thus have been getting exception (Invalid signature)..

hope will help...