Announcement

Collapse

A friendly reminder...

Please be sure that you are familiar with the forum rules and guidelines. These are in place to try to maintain a place that we all want to come back to. One specifically I would like to mention is keeping threads on topic. As much as is possible, please do not be afraid to start a new thread if you have a question that shifts even just a little bit in meaning. This will help users searching for solutions, and this will also help a conversation not become confusing to follow.
See more
See less

Anyone have an example of using LIBXL to read cells from .XLSX file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone have an example of using LIBXL to read cells from .XLSX file?

    Anyone have an example of using LIBXL to read cells from .XLS or .XLSX file?

    If you use LIBXL do you like it?
    Last edited by David Clarke; 30 Oct 2019, 08:55 PM.

  • #2
    hello David
    about a year ago or so I translated a couple C examples to FreeBasic, but not a reading example, however, you might figure out how to read a cell by looking at the sample and the sheet functions http://www.libxl.com/spreadsheet.html?lang=c
    my translated example can be found here https://www.freebasic.net/forum/viewtopic.php?t=25763

    perhaps something like this, not tested
    Code:
    function PbMain
        dim as BookHandle book = xlCreateBook()
        if book then
            if xlBookLoad(book, "example.xls") then
                dim as SheetHandle sheet = xlBookGetSheet(book, 0)
                if sheet then
                    dim d as double
                    dim s as const zstring ptr = xlSheetReadStr(sheet, 2, 1, 0) 'FB code, sorry
                    if s then
                        print s
                    end if
                    d = xlSheetReadNum(sheet, 3, 1, 0)
                    print d
                end if
            end if
            xlBookRelease(book)
        end if
    end function
    as the salmon fish is compelled to go back to it's birthplace to spawn, so comes a day when man is compelled to go back to it's source.. GOD

    Comment


    • #3
      Do a search in the forum on LibXl and you will find some goodies.
      Fim Wästberg

      Comment


      • #4
        Hi Fim!

        I have seen lots of examples of writing to excel but none of read from when file is xlsx.

        Comment


        • #5
          ADO also allows you to read Excel files.

          Comment


          • #6
            Hi Knuth, LibEx looks amazing. You don't need to have excel installed to use it! Totally stand alone.

            Comment


            • #7
              It's always something simple - book = xlCreateXMLBook()

              Comment


              • #8
                Originally posted by David Clarke View Post
                Hi Knuth, LibEx looks amazing. You don't need to have excel installed to use it! Totally stand alone.
                So does ADO. But if LibEx fits your needs - all power to you.

                Comment


                • #9
                  The nice thing about LIBXL is you don't need to have excel installed on the computer.

                  Comment


                  • #10
                    Again: so does ADO. No need for a local installation of Excel.

                    Comment


                    • #11
                      Didn't know that Knuth!

                      Comment


                      • #12

                        Complete source code for anyone who can plain c and want to create eg a dll. https://libxlsxwriter.github.io/index.html libxlsxwriter

                        Libxlsxwriter is a C library that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file. It supports features such as:
                        • 100% compatible Excel XLSX files.
                        • Full Excel formatting.
                        • Merged cells.
                        • Defined names.
                        • Autofilters.
                        • Charts.
                        • Data validation and drop down lists.
                        • Worksheet PNG/JPEG images.
                        • Support for adding Macros.
                        • Memory optimization mode for writing large files.
                        • Source code available on GitHub.
                        • FreeBSD License.
                        • ANSI C.
                        • Works with GCC, Clang, Xcode, MSVC 2015, ICC, TCC, MinGW, MingGW-w64/32.
                        • Works on Linux, FreeBSD, OpenBSD, OS X, iOS and Windows. Also works on MSYS/MSYS2 and Cygwin.
                        • Compiles for 32 and 64 bit.
                        • Compiles and works on big and little endian systems.
                        • The only dependency is on zlib.

                        Comment


                        • #13
                          From the libxlswriter Introduction page...
                          It can only create new files. It cannot read or modify existing files.
                          David's original post was for reading excel files. Too bad, it looked promising.

                          Comment


                          • #14

                            Excuse me, don't pay attention to the real issue. Thought this sounded good. Maybe you can combine other possibilities with reading and making change and then save a new version with this?

                            Comment

                            Working...
                            X