News for hackers. Stuff that matters.
Re:Advancing Excel as a programming language [audio] by kumarvvr on Wednesday May 05, 2021 @10:09AM (#27050012)
Why not just provide a way to script Excel with Python / JS?

Is it technically difficult?

Re:Advancing Excel as a programming language [audio] by ww520 on Wednesday May 05, 2021 @12:10PM (#27051763)
Scripting with Excel can be done in two ways: one is Excel as a host calling the scripts inside Excel, and the other is controlling Excel in another hosting language. The first can be done with VBA or Excel Javascript. The second can be done via the COM Automation interface supported by Excel. Any language that can talk to a COM Automation server can start Excel as an embedded COM object and call Excel's COM Automation API to control it. Visual Basic, JScript (Windows' Javascript), C++, C#, Java, Mathlab, Python, and others can talk to the COM Automation servers, and can script against Excel.
Re:Advancing Excel as a programming language [audio] by aarondia on Wednesday May 05, 2021 @12:15PM (#27051860)
One example is https://www.pyxll.com/ which lets you write Excel Add-ins using Python.

I've never used it myself, but I have tried to use the Excel JS API, and it was quite a pain.

Re:Advancing Excel as a programming language [audio] by ww520 on Wednesday May 05, 2021 @12:23PM (#27051954)
Yes. I believe the way Excel hosting other languages inside it as scripting addon is via the COM Automation Server interface again. The other language needs to implement as a COM Automaton Server. Excel then instantiates the other language's Automation Server as an embedded COM object and calls its interface, which can call the functions implemented with the language.
Re:Advancing Excel as a programming language [audio] by tinomaxgalvin on Thursday May 06, 2021 @03:39AM (#27060205)
The approach used by pyxll is higher performance. It uses the Excel C API. Excel add-ons can be written as native DLLs known as XLLs.
Re:Advancing Excel as a programming language [audio] by ww520 on Thursday May 06, 2021 @02:39PM (#27067453)
Good to know.
Re:Advancing Excel as a programming language [audio] by corty on Wednesday May 05, 2021 @10:19AM (#27050159)
There is already VisualBasic for Applications which is just similar to Python, only with begin/end-blocks instead of indentation. And with a little fiddling you can also use JScript/WSH to remote-control some parts of Excel, as well as all the .Net languages.
Re:Advancing Excel as a programming language [audio] by kumarvvr on Wednesday May 05, 2021 @10:59AM (#27050712)
> which is just similar to Python

What? Am I the only one who hates VBA with a burning hatred of a thousand suns?

Re:Advancing Excel as a programming language [audio] by andy81 on Wednesday May 05, 2021 @11:55AM (#27051541)
That's a common opinion.

The object model and IDE are a big part of it though, maybe even more so than syntax horrors like while..wend vs do while..loop.

Re:Advancing Excel as a programming language [audio] by corty on Wednesday May 05, 2021 @12:00PM (#27051615)
The libraries in VisualBasic (before .net) do suck. But syntactically, Python and Basic are very close. I hate both very much, because all the nice features that make programming fun are lacking. Both feel very much like using a childs' toy instead of proper tools.
Re:Advancing Excel as a programming language [audio] by auxym on Wednesday May 05, 2021 @01:10PM (#27052640)
VBA is very 90s. As in, similar to 90s era java, right up to the built-in IDE.
Re:Advancing Excel as a programming language [audio] by Vaslo on Wednesday May 05, 2021 @11:27AM (#27051138)
I code in VBA constantly as a Finance Manager. I also spend a lot of time learning Python and used it throughout a CS Degree. VBA and Python are not alike at all IMO.

You are right that you can use something like C# to manipulate Excel files, but there isn't a ton of tutorials on it, which makes it difficult and prohibitive to learn.

Re:Advancing Excel as a programming language [audio] by selimthegrim on Wednesday May 05, 2021 @10:19AM (#27050167)
Blockpad (https://blockpad.net) is a nice engineering focused alternative that shoots for this (with a JS like DSL)
Re:Advancing Excel as a programming language [audio] by bitwize on Wednesday May 05, 2021 @10:55AM (#27050646)
You can use COM/OLE to script Excel with Python or JS.

I think Microsoft is making JS a first-class scripting language for Excel (and slowly deprecating VBA).

Re:Advancing Excel as a programming language [audio] by andylynch on Thursday May 06, 2021 @12:46PM (#27065940)
It is already; VBA for the desktop versions isn’t going away anytime soon but it also not being developed apart from updates to the object model to reflect added features.
Re:Advancing Excel as a programming language [audio] by goatlover on Wednesday May 05, 2021 @11:34AM (#27051234)
You can generate Excel files in Python with XlsxWriter. It has an API for formatting, charts, merging cells and what not. If you want to automate an open Excel file, you can use xlwings. You can write data to Excel from pandas inside a Jupyter notebook.
Re:Advancing Excel as a programming language [audio] by m16ghost on Wednesday May 05, 2021 @12:30PM (#27052063)
Which version of Python/JS do they implement?

I think part of the problem is that any scripting language rolled directly into Excel will be expected to keep backwards compatibility. Microsoft doesn't have full control over Python/JS, and they would like to avoid issues such as the changeover from Python 2 to 3.

Microsoft could implement its own fork of those languages, but is that what customers actually want?

Re:Advancing Excel as a programming language [audio] by analog31 on Wednesday May 05, 2021 @11:19AM (#27051015)
It's probably difficult. I'm sure Microsoft has no great love for VBA, after all, they effectively orphaned the language when they came out with VB dot net. Adding the scripting language per se would be relatively easy. But a big part of VBA is being able to navigate the Excel / Office object hierarchy. I believe making that easy in Python would be hard.
Re:Advancing Excel as a programming language [audio] by auxym on Wednesday May 05, 2021 @01:13PM (#27052691)
It's pretty easy to use C# (or even F#) to write excel add-ins that can be distributed as standalone XLL files.

The difference is that add-ins is installed at the application level instead of the spreadsheet level (like VBA macros).

Re:Advancing Excel as a programming language [audio] by meibo on Wednesday May 05, 2021 @10:15AM (#27050103)
Scripting in Excel is a complex mess of VBA and COM, it's probably far from trivial to provide (sane) bindings into other languages.

You can do it via .NET, but a lot of people prefer VBA for its "quick and dirty"-ness.

Re:Advancing Excel as a programming language [audio] by ant6n on Wednesday May 05, 2021 @10:18AM (#27050149)
I wish there was a Python excel.
Re:Advancing Excel as a programming language [audio] by fartcannon on Wednesday May 05, 2021 @11:13AM (#27050921)
With the uno library, you can directly script LibreOffice Calc with python. https://help.libreoffice.org/6.3/en-US/text/sbasic/python/ma...

As a demonstration, I ran a ray tracing python script from Calc and it rendered to cells in the spreadsheet.

Re:Advancing Excel as a programming language [audio] by ant6n on Thursday May 06, 2021 @09:58PM (#27071085)
I mean, I'd like a spreadsheet software where the cell formulas are python.
Re:Advancing Excel as a programming language [audio] by olav on Wednesday May 05, 2021 @11:55AM (#27051538)
Just yesterday I stumbled across https://pyspread.gitlab.io/ after finding that coding Excel is a complete desaster from a software engineering point of view - no testing, no debugging, no version control, no structure. It must have costed humanity many billions in vain.
Re:Advancing Excel as a programming language [audio] by Optimal_Persona on Thursday May 06, 2021 @01:18PM (#27066381)
Whaddya mean no version control? What about CTRL + SHIFT + S every few minutes with incremental cryptic filename additions to USE_THIS_ONE_CopyofCopyof_VERY_IMPORTANT_myLatest_Edits_to_Copy_of(3)_DONT_DELETE.xlsx? ;-) But if you use Office 365 for file storage, there is actual version history for Office documents.
Re:Advancing Excel as a programming language [audio] by ant6n on Sunday May 09, 2021 @08:48AM (#27095536)
If the version history isn’t named, then there is no version control, just versioning.
Re:Advancing Excel as a programming language [audio] by 7thaccount on Wednesday May 05, 2021 @08:57PM (#27057922)
There have been some tools before such as DataNitro, but they don't exist anymore.

I think they still have several Python libraries out there, but yeah I wish Excel included Python support along with VBA.

Re:Advancing Excel as a programming language [audio] by saynotobloat on Wednesday May 05, 2021 @10:52AM (#27050600)
Re:Advancing Excel as a programming language [audio] by Vaslo on Wednesday May 05, 2021 @11:29AM (#27051177)
Not that many features are applicable to Excel. I've tried these and eventually have to default back to VBA to do what I need.
Re:Advancing Excel as a programming language [audio] by deepstack on Wednesday May 05, 2021 @10:18AM (#27050150)
there is already exceljs
Re:Advancing Excel as a programming language [audio] by jacobsenscott on Wednesday May 05, 2021 @10:16AM (#27050120)
You script it with VBA
Re:Advancing Excel as a programming language [audio] by mslip on Wednesday May 05, 2021 @10:43AM (#27050452)
Something that isn’t PTSD inducing would be better lol