This is possibly the most developer-friendly spreadsheet library ever. Get version 3.4 now!
SpreadsheetLight is also on NuGet. Bug fixed versions will be released promptly via NuGet, but stable releases with source code will still only be available here.
You might also want to check the release notes.
Within your download, you will find:
- The pre-compiled SpreadsheetLight class library DLL
- Class, function and property documentation (in an XML file)
- Source code (in C#) of the SpreadsheetLight library (complete with relevant comments for nasty code sections)
With the documentation (in the XML file), you can also generate MSDN-like documentation for your own use. Or you can use this one.
The C# source code is provided under the MIT License (see within downloadable zip file). Basically it means you’re allowed to use the source code in commercial projects.
I was in a total bind. I had a development requirement to generate 1,600+ Excel reports within a one day period. We typically do this by automating Excel via a c# console app. This process is fraught with danger: any user-facing pop-up dialog from Excel will stall the process, and they tend to happen randomly during lengthy runs. Running unattended as an overnight scheduled job, this is obviously not a useful or acceptable behavior. The reports are fairly complicated, what with being heavy on charts and formatting, so it was no surprise that when the draft report was complete, we were looking at a 100+ hour run time, which was far outside acceptable boundaries. In search of a better way, I happened upon SpreadsheetLight. Three days later, the 1,600+ batch of reports generates in less than an hour. The learning curve was light; the SpreadsheetLight library closely mimics the Excel interface. There are differences, of course, but they quickly become habit. If this library did nothing more than relieve me of the complexity of working with Style Sheets, it would be a tremendous help. It does so much more than that! Without exaggeration, I can say that I will remember the day I discovered this fantastic tool as one of the highlights of my thirty-five year career in IT.
Director of IT Systems for AccessHealth
I’m really impressed by the product. I just forklifted a bunch of my own Excel Interop code and replaced it with SpreadsheetLight; not only did I get the job done in fewer lines of code, but the time savings were several orders of magnitude. A 30+ second process now completes in less than 5 seconds. I’ll definitely be recommending this product and using it in the future.
After spending countless hours trying to get Open XML to do exactly what I want, and wrangling commercial solutions, I stumbled across SpreadsheetLight. An hour later, I’ve solved my problem and can get back to working on actual solutions for my customers instead of conforming to arcane XML requirements.
The fact that this is open source and MIT license is icing on the cake. Thank you thank you thank you, you’ve made this developer’s life a lot happier.
I have to make a proof of concept application with reporting and eventually export the reports into Excel (and the charts). Working with OpenXML was fine for setting cell values but when it came to add charts and set the series of data for them it got extremely complicated and there is not much documentation on the internet about manipulating charts with OpenXML. Lucky for me I found your library which is awesome! I managed to implement my method for charting in like 10 minutes.
You will need to download and install the Open XML SDK
2.0 2.5 (version 3.4.5 onwards work with SDK 2.5) from Microsoft (it’s freely available). SpreadsheetLight runs on the SDK internally. Then just add SpreadsheetLight to your project just like any other library as a reference. Remember to also add the DocumentFormat.OpenXml.dll (from Open XML SDK) as a project reference too (SpreadsheetLight runs internally on that. Yes, I mentioned that. Thought it warrants a second mention). For convenience, you can download the Open XML SDK DLL 2.0 (DocumentFormat.OpenXml.dll) here too. This is because the SDK 2.5 has incompatibilities (namely the SmartTags tag/class is deprecated). This means if you use the SDK 2.5 version, SpreadsheetLight will complain.
Source code compilation
You do not need to compile the source code to use SpreadsheetLight. Just use the pre-compiled DLL. Add it as a project reference.
But in case you’re hard-core and really want to compile the horseradish out of the source code, just create your own (Visual Studio?) solution/project and add these references:
- DocumentFormat.OpenXml (from the Open XML SDK)
Then drag and drop everything in the source code folder into your project. Compile. Have tea.
You need at least the .NET Framework
3.5 4.0 (version 3.4.5 onwards work with SDK 2.5 which runs on .NET Framework 4.0) and above installed on your target machines (either your developer’s machines or more typically, your web server machine).
Also, if you’re recompiling the source code (you don’t have to because there’s already a precompiled DLL in the download, but just in case), make sure to target the .NET Framework 3.5. Microsoft introduced the System.Tuple class in .NET Framework 4.0, so compiling the source code for .NET Framework 4.0 (this is getting very long to type) will throw out errors.
Easy to use
If you know how to use Microsoft Excel, you will know how to use SpreadsheetLight. SpreadsheetLight mimics many of Excel’s user interface and translates them into programming interfaces. This means you don’t have to learn yet another library’s quirks and coding convention and function names. Almost every function will feel familiar (or at least intuitive to use).
And if you hit any problems, just check out the example code to get started.
Light as a feather. Fast as a cheetah.
SpreadsheetLight is designed to consume as little of your memory resources as possible. This means your web server can serve more requests (and probably earn you more money. Huzzah!).
Your spreadsheet with millions of cells can be generated faster than a cheetah can catch an antelope (those cats can run!). This means your users won’t have to wait very long.
Simple and generous licensing
SpreadsheetLight uses the MIT License. Basically, it’s royalty free. You get unlimited developer/site/client/machine licenses. You can use it in a commercial product. You can integrate the included source code in your own projects (subject to the MIT License).
You don’t have to worry about renewing licenses or copyright. Isn’t that a relief?
Not sure if SpreadsheetLight suits your needs? Download the MSDN-style documentation* (right-click and choose the “save as” option if you hit trouble) of all the available classes and functions and enumerations and whatnots. (Did you know the SLDocument class does most of your tasks? This means you don’t need to learn about too many new classes before getting started.)
As you’re writing your code, SpreadsheetLight provides you with extensive documentation on its functions and parameters (via intelli-sense if your IDE supports it), so it’s easy for you. The idea is so you don’t have to trawl through tons of documentation if you don’t want to.
* The documentation is in a CHM file. You might have to go to the file properties and choose Unblock under the General tab (in Windows) so you can view it.
I know you’re a busy developer with tons of projects and mounting deadlines. You do not want to figure out how to create spreadsheets or modify existing spreadsheets. It’s a pain in the Adam’s apple, it’s not fun, but you have to do it anyway.
Are you in the spreadsheet business? I’m guessing most probably not.
Your company makes widgets and your clients need that sales report in a spreadsheet. Your marketing director wants to know how much of a budget he can allocate. Your CFO wants to know how much revenue the company made.
You probably like writing code to generate spreadsheets almost as much as you like to actually start up Microsoft Excel and enter some data that upper management wants (timesheets anyone? I’ve been there…).
You don’t want fancy coding constructs. You just want to get that spreadsheet done so you can get on with your life and that your clients can start paying you money.
Thank you for considering SpreadsheetLight and I wish you smooth sailing for your software projects!