How to show spreadsheet column and row headings

Introduction

Excel worksheet columns and rows numeration are described by letters (A, B, C, etc.) for columns and by numbers (1, 2, 3, etc.) for rows, numeration is located in headings of Excel worksheet. The column headings are used to identify the column and row numbers are used to identify the row in the worksheet. The combination of the column letter and the row number (A1, D3, F7, etc.) is called cell reference and used to identify the cell in the worksheet. 

The column and row headings are highlighted in the following screenshot. 

Background

Let’s take a sample workbook and open it with Excel. Then we’ll process the same file with GroupDocs.Viewer and compare results.

The following screenshot shows the default spreadsheet view in Excel.

When processing spreadsheets with GroupDocs.Viewer the row and column headings are not shown by default.

The following screenshot shows the default spreadsheet HTML view in a browser. 

How to show spreadsheet column and row headings

To show of column and row headings in the output document you just need to set HtmlViewOptions (or JpgViewOptions, or PngViewOptions, or PdfViewOptions) object SpreadsheetOptions.RenderHeadings property to true

The following code sample shows how to enable rendering of column and row headings (this example can be also found in our public examples repository.)

            using (Viewer viewer = new Viewer("sample.xlsx"))
            {
                HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
                viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
                viewOptions.SpreadsheetOptions.RenderHeadings = true;
                viewer.View(viewOptions);
            }

When headings rendering is enabled, the spreadsheet HTML view in a browser will contain row and column headings as shown in the screenshot below.

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.