The One With

Introducing Spreadsheet Document API – Part 1

The Spreadsheet Document Server is a powerful non visual .NET library, engineered to create and manage Spreadsheet documents natively, without the need for Microsoft Excel to be installed. With intuitive Spreadsheet API, you can produce: invoices, reports, payment schedules and a multitude of other documents, fast, avoiding the slow and very costly Microsoft Office automation.


To get started we will need to include four (4) assembly references to the project. They could be found in the GAC, or in the default installation, in C:\Program Files (x86)\DevExpress\DXperience 13.1\Bin\Framework folder.

Assembly References

Fig 1. Assembly References

The main object that represents a document is DevExpress.Spreadsheet.Workbook. Workbook gives access to the top level document from which we can apply document Options and Styles, access the Worksheets, as well as handy routines to Load a document from file or to Save it.

Each Workbook consists of multiple Worksheets, and in turn, Worksheets consist of Cells.

Fig 2. Workbook Structure

The following example demonstrates how to create the most basic XLSX file.

Workbook book = new Workbook();
book.Worksheets[0].Cells["B2"].Value = "Hello World";

Produced .xlsx File

Fig 3. “Hello World” document previewed in Microsoft Excel.

Working with Cells

From the example above, you might have noticed how intuitive it is to access or update a cell. A Worksheet Cell, may be referenced either via its named coordinates A1, B1, C1 etc… or alternatively via its direct coordinates:

Workbook book = new Workbook();
book.Worksheets[0].Cells[0, 0].Value = 42;

Nota bene: Direct coordinates are zero based.

Cell values accept all the default primitive types: Boolean, Text and Numeric. The built-in implicit operators will ensure the value is of the correct type when set from a .NET type.

book.Worksheets[0].Cells["B2"].Value = DateTime.Now;
book.Worksheets[0].Cells["B2"].NumberFormat = "m/d/yy";
book.Worksheets[0].Cells["B3"].Value = Math.PI;
book.Worksheets[0].Cells["B4"].Value = "Text value...";
book.Worksheets[0].Cells["B5"].Value = true;
book.Worksheets[0].Cells["B6"].Value = float.MaxValue;
book.Worksheets[0].Cells["B7"].Value = 'a';
book.Worksheets[0].Cells["B8"].Value = Int32.MaxValue;

Cell Values

Fig 4. Cell values

Cell Formatting

Each Worksheet Cell, exposes its formatting via the Formatting interface.

public interface Formatting {
    Alignment Alignment { get; }
    Borders Borders { get; }
    Fill Fill { get; }
    Font Font { get; }

The following example shows how to set various cell options.

book.Worksheets[0].Cells["B2"].Value = "...Text value";
book.Worksheets[0].Cells["B2"].Alignment.Horizontal = HorizontalAlignment.Right;
book.Worksheets[0].Cells["B2"].Borders.SetAllBorders(Color.Orange, BorderLineStyle.Thick);
book.Worksheets[0].Cells["B2"].Fill.BackgroundColor = Color.WhiteSmoke;
book.Worksheets[0].Cells["B2"].Font.Name = "Vivaldi";
book.Worksheets[0].Cells["B2"].Font.Color = Color.Navy;

Cell Formatting

Fig 5. Formatted Cell

Now, let's see how to work with Ranges, Formulas



Published May 29 2013, 03:28 PM by
Bookmark and Share


Mervin Katjouanga - BWK


May 29, 2013 7:00 PM

Bradley Uffner

Does it support pivot tables without jumping through hoops of fire?  Every excel library I've dealt with before always made the developer jump though hoops to get pivot tables to work.  If you've managed to make a library that can do pivot tables without having to create things like document templates with AutoUpdate settings set a specific way you will have made me very happy.

May 29, 2013 7:50 PM

Rajko Bogdanovic

not just nice - NIIIIIIICE :)

Next thing: better sharepoint and a true reporting server that supports XtraReports


May 29, 2013 8:54 PM

Juan Betancourt

Small complaint (well, I know i know thx very much before): the syntax to refer cells is not friendly, Cells[i, j] much better that Cells["B2] (in order to can iterate dynamically).

May 29, 2013 8:59 PM

isaac khazi


Well you guys already have a great Visual and non visual document processing engine. Now your coming out with the spread sheet engine and PDF viewer. Some component vendors are gonna have some stiff competition from here on and your customers are gonna save thousands of dollars! Thanks for your continuous support for the Winforms platform. :)  

May 30, 2013 3:05 AM


the file format is compatible with excel 2003, 2000, 1997 and so on?

May 30, 2013 3:27 AM

Fernando Hoshino

When I tried to compile a sample I noticed that DevExpress.Spreadsheet.v13.1.Core is compiled with .NET 4.0 target.

¿Is it unintended or will the final version not work with .NET 3.5?

May 30, 2013 5:35 AM


Which subscription(s) will include this?

May 30, 2013 12:02 PM

Denis Chiseliov


May 30, 2013 12:11 PM

Azret Botash (DevExpress)

@listar: Yes all those formats are supported

@FloridaDevs: It will be in the Universal if you already have it. A separate option will be available as well.

@Fernando: It will need .NET 4.0+

@Juan Betancourt: We will support both Cells[i, j] and Cells["A1"]

@Everyone thank you so much for the nice comments. Really means a lot

May 30, 2013 12:15 PM

Azret Botash (DevExpress)

@Bradley Uffner: Pivots is of course something we will be working on for the upcoming releases of the product :)

May 30, 2013 1:18 PM

c Pitt

Very Nice! Right now we use a third party dll to perform this, and I would love to phase it out and use only DevExpress! There is always risk involved in using free third party dlls as part of your line of business software. Well Done!

May 31, 2013 6:50 AM

Vassilios Pallis

Hi !!

Do you have plans for an excel viewer control for WPF so to represent the data that this api will create ?

BTW : Nice work !

June 4, 2013 4:56 AM

Vassilios Pallis

Hi !

Nice work !

Could you please answer whether you are planning to build a spreadsheet control viewer for WPF / WinForms / ASP.NET to represent data of this framework?

Thanks !

June 5, 2013 7:44 AM

James Foye

I'm currently using another vendor's product to do this, so it might be nice to phase that out and go with more of a pure DevExpress solution. Look forward to this.

June 5, 2013 12:37 PM

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at or call us at +1 (818) 844-3383


DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2016 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners