How To Get The Custom Format String For An Excel/OpenXml Cell
Getting the custom number format string for an Excel cell using OpenXml is not entirely intuitive. But once you understand how this information is laid out, it starts making sense....
Getting the custom number format string for an Excel cell using OpenXml is not entirely intuitive. But once you understand how this information is laid out, it starts making sense....
A while back I needed a way to extract values from a LocalReport object. I wrote a proof of concept application that rendered the object as Excel/Xml data, then parsed that data using OpenXml. This worked perfectly well within the very limited scope typical of a POC, but when I finally got the chance to put it to real world use there were a few predictable snags. Most were reasonably simple to resolve but one - and only one - of the reports I was rendering resulted in this lovely error:...
How oh how is one to get XML from a local (not server) SSRS report? As it turns out, via Excel. The LocalReport.Render() method only supports Excel, PDF, and Image formats, but since the Excel 2007+ file format is just compressed XML, it didn’t take too much finagling to get what I was really after. The only thing I needed was the Microsoft OpenXml SDK, easily acquired through Nuget. This code snippet shows how to get the rendered values from a LocalReport in memory:...