Posts
- The Silent Bug: How an AI Agent Can Quietly Blank Out Your Excel Formulas
30 August 2026
Here’s a bug that doesn’t look like a bug. Ask an AI agent to add one line to an existing report. It does. The file opens fine in Excel - Excel recalculates every formula the moment it opens a workbook, so nothing looks wrong. But hand that same file to a second automated system - a PDF export, a dashboard pipeline, another script reading it with
pandas- and a number that used to be there is now blank, or zero, orNone. Nobody touched that cell. - Your AI Probably Can't Build a Pivot Table — Here's What Can
30 August 2026
AI agents get asked to build Excel reports constantly. When a Python-based agent gets that request, it almost always reaches for the same library: openpyxl. So I ran a real test: give the same task to (a) a generic Python/openpyxl session and (b) an agent using Kookerella.FsOpenXmlDsl’s MCP server, and look at what actually landed in the resulting file - not what either session claimed it did.
Everything below is real: real code, run for real, with the resulting
.xlsxfiles inspected by unzipping them (an.xlsxis just a zip of XML parts) to check what’s objectively inside, rather than trusting either tool’s own success message. - Decompiling an Excel template into source - #1 C#
26 August 2026
You don’t have to hand-write Excel styling code. If someone already built the spreadsheet you need to reproduce — a finance person’s invoice template, a report layout a designer signed off on — you can reverse-engineer it into real source code, then wire in your own data. This is the first of four posts walking through the same demo in C#, F#, XSLT, and plain JSON. The full project is on GitHub: Kookerella.Demo.DecompileToSource.
- Decompiling an Excel template into source - #2 F#
27 August 2026
This is the F# counterpart to part one’s C# walkthrough — same demo, same template, same idea: you don’t have to hand-write Excel styling code. If someone already built the spreadsheet you need to reproduce, you can reverse-engineer it into real source code, then wire in your own data. The full project is on GitHub: Kookerella.Demo.DecompileToSource.
What we’re starting from
The same plain Excel file used in the C# demo: a bold, 16pt “INVOICE” title, a white-on-navy header row with a bottom border, and two sample line-item rows with an
Amountcolumn computed asQty * Unit Price. - Decompiling an Excel template into a transform - #3 XSLT
28 August 2026
This is the XML counterpart to the C# and F# walkthroughs, but the pitch is different: there’s no C# or F# code in this one at all. If your data already comes out of a pipeline as XML — an XSLT transform, a database export, whatever — you can go straight from that data to a real Excel file, using the same template-driven idea as the other demos, but with a declarative transform instead of a programming language. The full project is on GitHub: Kookerella.Demo.DecompileToSource.
- Decompiling an Excel template into a script - #4 JSON
29 August 2026
This is the JSON counterpart to the XSLT walkthrough, the last of this four-part series, but the story is slightly different. XML pairs naturally with a declarative transform language (XSLT). JSON doesn’t really have an equivalent standard — there’s no dotnet-tool-shaped “jq for .NET” to lean on. So instead of a transform engine applied to a data file, this demo is just what a JSON pipeline naturally looks like in practice: a plain script that already emits JSON, wired straight into
fsopenxmldsl-mcp build. The full project is on GitHub: Kookerella.Demo.DecompileToSource. - Dependency injection in XSLT...or actually maybe not
8 May 2024
Dependency injection in XSLT…or actually maybe not
Ever written two, three or more stylesheets that are almost the same, but not quite the same, maybe you’ve struggled with #import or #include to separate your core shared code from the bespoke specific code? Maybe you’re an OO programmer steeped in the theology of objects, favouring composition over inheritance and find XSLT innate mechanisms to close to its OO cousins? Or a functional programmer at ease with higher order functions, but dabbling in some XSLT and wondering how to apply you functional skills, well read on, hopefully this blog will help you apply these skills in XSLT but ironically question whether these techniques really are the “state of the art”, many believe and when you return to your Scala/C#/Java/C++ or whatever it is you do most of the time, question whether there is more than one way to skin the cat (ew…I hate that phrase).
- Producing JSON in XSLT, a simple walkthrough.
8 May 2024
Producing JSON in XSLT, a simple walkthrough.
XSLT isnt just for XML, it can, surprisingly transform from and to JSON, but simple tutorials seem thin on the ground, what follows is a walkthough of of how to generate a simple JSON output.
- Functional XSLT/XPath/XQuery - #1 Introduction
3 June 2024
Functional XSLT/XPath/XQuery - #1 Introduction
To the modern programmer these languages appear strange beasts, born when the world was obsessed with XML, it is declarative, almost functional, but somehow missing some of the idioms of later more consciously functional languages. For a functional programmer it misses familiar function and data types that the functional programmer instinctively expect. To be fair their roots predate much of the flowering of functional patterns in language development and whilst the semantics of the languages are quite well suited to this style of development, the foundations are idiosyncratic, and now locked in by their history to be slightly out of step.
- Functional XSLT/XPath/XQuery - #2 Functor pattern
3 June 2024
Functional XSLT/XPath/XQuery - #2 Functor pattern
In the previous blog we introduced some machinery, the id function, and function composition, we talked about function types, and invented an informal notion of parametric types in order to aid our thinking.
We now move onto the functional patterns. These are a bit like OO patterns but have more formal mathematical underpinnings. Knowing what to call the things is problematic in itself, in mathematics these underpinnings are called a category, in functional circles they are often called a typeclass , this is a borrowed term from Haskell that has a particular mechanism for implementing them which may be misleading, other languages have different mechanisms, some languages have no formal mechanism, but have informal mechanisms, or no mechanism at all apart from idiomatic usage, like an OO pattern.
- Functional XSLT/XPath/XQuery - #3 Maybe data type
5 June 2024
Functional XSLT/XPath/XQuery - #3 Maybe data type
We are now in a position to fill in a missing data type.
Lets cover some XPath basics.
Consider the following XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:kooks="http://kookerella.com"> <xsl:output method="xml" indent="yes"/> <xsl:function name="kooks:safeDivision" as="xs:numeric?"> <xsl:param name="numerator" as="xs:numeric"/> <xsl:param name="denominator" as="xs:numeric"/> <xsl:if test="not($denominator eq 0)"> <xsl:sequence select="$denominator div $denominator"/> </xsl:if> </xsl:function> <xsl:template match="/"> <output> <xsl:variable name="calculations" as="xs:numeric*" select="(1 div 1,1 div 2,2 div 3)"/> <xsl:sequence select="$calculations"/> </output> </xsl:template> </xsl:stylesheet>If we execute it against an xml it returns this:
- Functional XSLT/XPath/XQuery - #4 Monoid
9 June 2024
Functional XSLT/XPath/XQuery - #4 Monoid
Usually in these sorts of tutorials Monoid comes first, its the simplest, easiest most familiar sort of thing, we don’t really even need code to describe it, its loosely the theory of having something you can composing two things together and getting another thing of the same type, together with an identity element, so in mathematics the integers form a monoid with
+and the identity element is0or we can use multiplication*and1, the set of booleans, i.e.{ True , False }together with the operatorANDform a monoid, where the identity element isTrue, to be honest, these things are rarely used as monoids in functional code, they could be, there just isn’t much use, the things that are usually used as monoids are collections, so in the XPath world this issequence,array,map(and the recently addedmaybe). - Functional XSLT/XPath/XQuery - #5 Monad pattern
15 June 2024
Functional XSLT/XPath/XQuery - #5 Monad pattern
The monad is probably the most written about functional pattern, it is famous for convoluted and obtuse explanations, but I will steal some of the better explanations and translate them into XSLT/XPath.
(adapted directly from All About Monads - HaskellWiki).
“Suppose that we are writing a program to keep track of sheep cloning experiments. We would certainly want to know the genetic history of all of our sheep, so we would need
motherandfatherfunctions. But since these are cloned sheep, they may not always have both a mother and a father!