question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExcelDataReader - Error: Invalid file signature

See original GitHub issue

So I’m trying to read my excel file that is consist of 8 header titles No. Mchn. EnNo. Name. Mode. IOMd. Date_Time

and a 300+ of data. and the data grid view is not reading all of my data and the error keeps appearing,… what should I do?

` private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = tableCollection[cboSheet.SelectedItem.ToString()]; dataGridView1.DataSource = dt;

    }

    DataTableCollection tableCollection;
    private void btnBrowse_Click(object sender, EventArgs e)
    {
        using (OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "MS Excel 2007 onwards |*xls" })
        // "Excel 97-2003 Workbook | *.xls | Excel Workbook | *.xlsx" })
        {

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                txtFilename.Text = openFileDialog.FileName;
                using (var stream = File.Open(openFileDialog.FileName, FileMode.Open, FileAccess.Read))
                {
                    using (IExcelDataReader reader= ExcelReaderFactory.CreateReader(stream))           
                    {
                        DataSet result = reader.AsDataSet(new ExcelDataSetConfiguration()
                       
                        {
                            ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true }
                        });
                        tableCollection = result.Tables;
                        cboSheet.Items.Clear();
                        foreach (DataTable table in tableCollection)
                        cboSheet.Items.Add(table.TableName); //add sheet to combobox
                    }
                }
            }
        }`

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
maxima120commented, Sep 15, 2021

I am really surprised that the project devs waste so much time investigating dead-end requests … you should not be afraid to be a little rude to time-wasters and fantasists “programmers”… Just close and move on. there are so many things you can spend your time on, that can actually be helpful to real world (this is 3rd ticket i am reading and all 3 are just b/s)

0reactions
andersnmcommented, May 29, 2020

Thanks for the update!

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# error With ExcelDataReader
HeaderException' occurred in ExcelDataReader.dll. Additional information: Invalid file signature." The error is caught on line 38.
Read more >
Unable to load XLS file - "Invalid file signature ...
Now, onto this one: I have this "xls" file I need to parse, whose origin I do not know, that fails whether I...
Read more >
C# error With ExcelDataReader
Additional information: Invalid file signature." The error is caught on line 38. here is a copy of my code using ExcelDataReader; using System;...
Read more >
Tip: ExcelDataReader returns "Invalid File Signature" when ...
Just happen to notice this problem when i am trying to load multiple Excel files from the same directory. The root cause for...
Read more >
ExcelDataReader can t read html-format file - Edureka
But I got an error: ExcelDataReader.Exceptions.HeaderException: Invalid file signature. [2023-04-10T02:43:50.481Z] at ExcelDataReader.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found