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. C# and Excel

C# and Excel

Scheduled Pinned Locked Moved C#
csharpvisual-studiocomquestion
9 Posts 3 Posters 16 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.
  • I Offline
    I Offline
    Ismael_1999
    wrote on last edited by
    #1

    Hi. I'm working with Visual Studio 2022 and I have an application that uses excel. I'd like to know your opinion on the interfaces available: Interop, ClosedXML or any other. Which one is the best? Thank you.

    D OriginalGriffO 2 Replies Last reply
    0
    • I Ismael_1999

      Hi. I'm working with Visual Studio 2022 and I have an application that uses excel. I'd like to know your opinion on the interfaces available: Interop, ClosedXML or any other. Which one is the best? Thank you.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There is no "best", only most appropriate, and what's most appropriate depends on your application type and what exactly you're going to be doing with either Excel or an Excel sheet.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

      I 1 Reply Last reply
      0
      • I Ismael_1999

        Hi. I'm working with Visual Studio 2022 and I have an application that uses excel. I'd like to know your opinion on the interfaces available: Interop, ClosedXML or any other. Which one is the best? Thank you.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Dave is exactly right - it depends on what you are trying to do with the Excel file. But ... if you are trying to use an Excel file as a database, then one word applies: "DON'T!" Excel is a spreadsheet, and while it can work quite well as a database for single user small scale projects, as soon as the data size becomes in any way significant performance drops off a cliff. Part of this is the way .XLSX files work: they are a zip file containing a bunch of XML files. And XML files are text based - human readable if you are patient. So making any change to an XLSX file means opening the zip, decompressing it, reading the whole XML file, making changes, writing the XML back, then zip compressing it all back to an XLSX. That's fine for a small dataset, but once it grows ... life is too short. Then there ios the fun if two or more users want to work with the same data: Excel won't allow that, so you have to open the Excel connection in your code, wait for the file to be free, make your changes, and close the connection. If you want a DB, use a DB: SQLite, Access, MSSQL, MYSQL, ... depending on what exactly you have available, and are doing. But don't use a spreadsheet - it will just cause you massive problems later on!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        I 1 Reply Last reply
        0
        • D Dave Kreskowiak

          There is no "best", only most appropriate, and what's most appropriate depends on your application type and what exactly you're going to be doing with either Excel or an Excel sheet.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

          I Offline
          I Offline
          Ismael_1999
          wrote on last edited by
          #4

          Hi, Dave. I search for an easy to use interface with a relation of the available commands. I know Excel reasonably well and want to create visually good sheets. Do you have any suggestion?

          D 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Dave is exactly right - it depends on what you are trying to do with the Excel file. But ... if you are trying to use an Excel file as a database, then one word applies: "DON'T!" Excel is a spreadsheet, and while it can work quite well as a database for single user small scale projects, as soon as the data size becomes in any way significant performance drops off a cliff. Part of this is the way .XLSX files work: they are a zip file containing a bunch of XML files. And XML files are text based - human readable if you are patient. So making any change to an XLSX file means opening the zip, decompressing it, reading the whole XML file, making changes, writing the XML back, then zip compressing it all back to an XLSX. That's fine for a small dataset, but once it grows ... life is too short. Then there ios the fun if two or more users want to work with the same data: Excel won't allow that, so you have to open the Excel connection in your code, wait for the file to be free, make your changes, and close the connection. If you want a DB, use a DB: SQLite, Access, MSSQL, MYSQL, ... depending on what exactly you have available, and are doing. But don't use a spreadsheet - it will just cause you massive problems later on!

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            I Offline
            I Offline
            Ismael_1999
            wrote on last edited by
            #5

            Hi, OriginalGriff. I don't have the intention of using Excel as a DB. In fact I use SQL Server. Excel is only a way of showing results in a pleasant way. At this time I use Interop Excel interface, but it's very difficult to find the commands and its variations. If you know a way of getting the library of these commands, I'd appreciate to know it. Thanks.

            OriginalGriffO 1 Reply Last reply
            0
            • I Ismael_1999

              Hi, OriginalGriff. I don't have the intention of using Excel as a DB. In fact I use SQL Server. Excel is only a way of showing results in a pleasant way. At this time I use Interop Excel interface, but it's very difficult to find the commands and its variations. If you know a way of getting the library of these commands, I'd appreciate to know it. Thanks.

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Excel as a display control seems somewhat overkill - especially as it requires Excel to be fully installed (and licenced) on the target machine. What does it do for your "pleasant display" that a standard DataGridView doesn't?

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              I 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Excel as a display control seems somewhat overkill - especially as it requires Excel to be fully installed (and licenced) on the target machine. What does it do for your "pleasant display" that a standard DataGridView doesn't?

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                I Offline
                I Offline
                Ismael_1999
                wrote on last edited by
                #7

                I know Excel reasonably well, but I know only the basic of DataGridView. Excel is installed, and also, if I want other people to see the data, Excel is more appropriate.

                1 Reply Last reply
                0
                • I Ismael_1999

                  Hi, Dave. I search for an easy to use interface with a relation of the available commands. I know Excel reasonably well and want to create visually good sheets. Do you have any suggestion?

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  The OpenXML SDK can create workbooks and sheets and do it a lot faster than Excel Interop. The ClosedXML SDK can do the same thing, but it's a third-party library. The problem with using either is the learning curve. You're going to have to learn how workbooks and sheets are built and rewrite your code to do the same thing.

                  Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

                  I 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    The OpenXML SDK can create workbooks and sheets and do it a lot faster than Excel Interop. The ClosedXML SDK can do the same thing, but it's a third-party library. The problem with using either is the learning curve. You're going to have to learn how workbooks and sheets are built and rewrite your code to do the same thing.

                    Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

                    I Offline
                    I Offline
                    Ismael_1999
                    wrote on last edited by
                    #9

                    Thanks, Dave. I'll consider it.

                    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