Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. What options do I have for reading data from an excel spreadsheet, and what are the limitations of each?

What options do I have for reading data from an excel spreadsheet, and what are the limitations of each?

Scheduled Pinned Locked Moved C#
databasesql-serversqlitecomsysadmin
7 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agent154
    wrote on last edited by
    #1

    I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

    P S B Richard DeemingR J 5 Replies Last reply
    0
    • A agent154

      I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      agent154 wrote:

      Is this true?

      Yes. So I avoid it.

      agent154 wrote:

      Microsoft.ACE.OLEDB.12.0 OleDB provider

      That's my preference.

      agent154 wrote:

      read from it and dump the data into a SQLite or SQL Server Compact database table.

      That's the sort of thing that SSIS does.

      You'll never get very far if all you do is follow instructions.

      1 Reply Last reply
      0
      • A agent154

        I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

        S Offline
        S Offline
        SledgeHammer01
        wrote on last edited by
        #3

        Just an FYI since the other guy didn't mention it at all... * Your first choice, of course requires that Excel be installed, but is a lot less work and is more platform independent. * Your second choice does not... HOWEVER, and this is a BIG HOWEVER because if you don't know about this, you'll spend **weeks** trying to figure out what's going on... Microsoft ACE is the 64-bit driver. That's for a 64-bit OS and a 64-bit process **ONLY**. Won't run on a 32-bit OS or if your process is 32-bit. No big deal you're thinking, right? Not quite... if the machine happens to have 32-bit Office installed, you can't even install the 64-bit Ace driver, regardless of your OS because you aren't allowed to mix bitage. You have to install a different 32-bit driver and that limits your process to running as 32-bit because you can't use the 32-bit driver from a 64-bit process or vice versa. This causes a lot of issues... you'd have to have a 32-bit build that uses the 32-bit driver if the machine has 32-bit Office installed and a 64-bit build that uses the 64-bit driver if the machine has 64-bit Office installed. Most 64-bit machines I've seen have 32-bit Office installed... just sayin'... so you're limiting yourself to a 32-bit process.

        M 1 Reply Last reply
        0
        • S SledgeHammer01

          Just an FYI since the other guy didn't mention it at all... * Your first choice, of course requires that Excel be installed, but is a lot less work and is more platform independent. * Your second choice does not... HOWEVER, and this is a BIG HOWEVER because if you don't know about this, you'll spend **weeks** trying to figure out what's going on... Microsoft ACE is the 64-bit driver. That's for a 64-bit OS and a 64-bit process **ONLY**. Won't run on a 32-bit OS or if your process is 32-bit. No big deal you're thinking, right? Not quite... if the machine happens to have 32-bit Office installed, you can't even install the 64-bit Ace driver, regardless of your OS because you aren't allowed to mix bitage. You have to install a different 32-bit driver and that limits your process to running as 32-bit because you can't use the 32-bit driver from a 64-bit process or vice versa. This causes a lot of issues... you'd have to have a 32-bit build that uses the 32-bit driver if the machine has 32-bit Office installed and a 64-bit build that uses the 64-bit driver if the machine has 64-bit Office installed. Most 64-bit machines I've seen have 32-bit Office installed... just sayin'... so you're limiting yourself to a 32-bit process.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          AAAHHhhhh and they wonder why I dump on Office from a great height every opportunity I get. I hate having to deal with Office version incompatibilities, now you tell me the processor type may be an issue. Ok so now I can see a benefit to the 32 bit OS policy I have been muttering about for some time.

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          • A agent154

            I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            There are also some libraries for reading (and sometimes also writing) Microsoft Office files which do not need MS Office or OleDB installed. See e.g. here on CP Use Cross-Platform/OSS ExcelDataReader to Read Excel Files with No Dependencies on Office or ACE[^]. Google may find some more libraries.

            1 Reply Last reply
            0
            • A agent154

              I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Both EPPlus[^] and ClosedXml[^] will allow you to read and write Excel 2007+ files (*.xlsx). If you need support for the older format files (*.xls) as well, then NPOI[^] is pretty good.


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              1 Reply Last reply
              0
              • A agent154

                I'm aware of at least two possibilities for reading directly from xls files: - Microsoft.Office.Interop.Excel - Microsoft.ACE.OLEDB.12.0 OleDB provider From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true? Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table. Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need? Thanks.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                agent154 wrote:

                requires that Excel be installed on the system where this will be run.

                What is the Business case where that matters? If this is a client machine and the spread sheet is just a read only data store that comes with the application why not use a different format? If a client machine where a user can modify the file then they would need excel anyways. If a server machine then the situation is similar to the above but there should be less concern about cost.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups