6

I was wondering if there's anywhere in Excel, or online, that I can use to see how the Functions in Excel are working.

The idea is that I'm starting to learn how to make UDFs, and do various things in VBA, and thought that if I could see how Excel actually executes Sum() for instance, I can learn how to make my code tighter, take less space, etc.

Basically, where's the repository for how Excel's built-in functions work? Is that even available?

Edit: I understand that the formulas may be written in not-VBA. That's fine - I'm just curious if there's a way to see them, whatever language they're written in.

Edit2: The overall idea is that I'm learning C++/VBA/C#, and would like to see "official" functions just to learn how they work, and see if there are any ways to speed up code. OpenOffice functions are good too!

7
  • 1
    The underlying code for built-in Excel functions is not in VBA. Excel is written in C# and/or C++.
    – Excellll
    Jun 17, 2016 at 20:12
  • @Excellll - Do you know where I can find that code? I'm also learning C++ so it may help too!
    – BruceWayne
    Jun 17, 2016 at 20:18
  • 2
    It's not open source
    – Dave
    Jun 17, 2016 at 20:25
  • 1
    @Dave - I was afraid of that :(
    – BruceWayne
    Jun 17, 2016 at 20:35
  • 2
    Are you interested in viewing source code of some alternative product? For example OpenOfiice Calc?
    – miroxlav
    Jun 17, 2016 at 20:50

2 Answers 2

5

Microsoft Excel is a closed-source product,
but as you indicated, source code of alternative to Excel will suffice, too.

You can examine the source code of OpenOffice Calc which closely resembles Microsoft Excel (see screenshots).

You do not need to install the product. On the download page, focus to section labeled Source and grab the archive with zip extension.

Inside the archive, look into file aoo-4.1.2\main\sc\source\core\tool\interpr4.cxx
and there around line 3500 you can find long case statement showing internal function calls for built-in spreadsheet functions. This is your starting point.

Then you can search source files for implementation of these functions.

Good luck!

4
  • The LibreOffice code base is substantially better nowadays IMHO. See these commits for the implementation of various Excel functions: cgit.freedesktop.org/libreoffice/core/log/…
    – phw
    Jun 23, 2016 at 16:35
  • @phw – I see. Do you think this is also the reason why you voted that "the answer is not useful" (i.e. downvoted)? Or wasn't it you? And were you able to find that implementation of spreadsheet functions in Libre Office is far superior to their implementation in OpenOffice? Maybe you can share your findings in separate answer.
    – miroxlav
    Jun 24, 2016 at 7:50
  • Well, they've refactored the whole way Calc works and moved some parts to an external library (called mdds). Given that OO.o didn't do that, that gives them an advantage in my book. This is a good start to dig into the source code: wiki.documentfoundation.org/Development/Code_Overview
    – phw
    Jun 28, 2016 at 15:58
  • I found some at: cgit.freedesktop.org/libreoffice/core/tree/sc/source/core/tool in the files interpr?.cxx.
    – Marius
    May 17, 2018 at 15:44
2

I would instead, urge you do understand the logic of the functions. You know what a Sum is, that should be easy for you to replicate. The things you don't know - like a vlookup or stdev have some sort of logic - whether purely mathematical or operational (like transpose). Learn how those work and then design your code around the logic.

1
  • Thanks for the advice! I was planning on doing so, starting with the simpler maths then moving into the more "tricky" functions.
    – BruceWayne
    Jun 18, 2016 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .