Search code examples
c#.netexcelimport-from-excel

Excel import automation


I've come to a complete standstill: I need to import data from Excel to a Microsoft SQL Server 2008 database. Certain columns, starting at specific rows, contains data information that I need to extract and properly insert into the database, and the file itself is provided as a stream.

I've been looking into Microsoft's solution Excel 12.0 Object Library, but it seems dependant on Office being installed in the production environment? Or is it possible to deploy an application to an environment where Office is not installed?

I've also cast a glance upon Excel Data Reader, but it doesn't seem to function for xlsx or Office 2010-documents, complaining about a 'bad file signature'.

What are your recommendations?


Solution

  • Excel Data Reader should be fine. Have you used:

    //2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
    IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
    

    to open your xlsx file?