SharedStringTable Class

Shared String Table. It is the root element of SharedStringTablePart.When the object is serialized out as xml, its qualified name is x:sst.

Namespace:  DocumentFormat.OpenXml.Spreadsheet
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class SharedStringTable : OpenXmlPartRootElement

The following table lists the possible child types:

  • SharedStringItem <x:si>

  • ExtensionList <x:extLst>

[ISO/IEC 29500-1 1st Edition]

18.4.9 sst (Shared String Table)

This element is the root of the Shared String Table, which serves as a collection of individual String Items (si).

Parent Elements

Root element of SpreadsheetML Shared String Table part

Child Elements


extLst (Future Feature Data Storage Area)


si (String Item)




count (String Count)

An integer representing the total count of strings in the workbook. This count does not include any numbers, it counts only the total of text strings in the workbook.

This attribute is optional unless uniqueCount is used, in which case it is required.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

uniqueCount (Unique String Count)

An integer representing the total count of unique strings in the Shared String Table. A string is unique even if it is a copy of another string, but has different formatting applied at the character level.


World, World, and World.

The count would be 3, and the uniqueCount would be 2. Only one entry for "World" would show in the table because it is the same string, just with different formatting applied at the cell level (i.e., applied to the entire string in the cell). The "World" string would get a separate unique entry in the shared string table because it has different formatting applied to specific characters.

end example]

This attribute is optional unless count is used, in which case it is required.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

[Note: The W3C XML Schema definition of this element’s content model (CT_Sst) is located in §A.2. end note]

© ISO/IEC29500: 2008.

The following code example creates a new spreadsheet document and inserts a hyperlink in the cell "A2."

using System;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;

namespace SharedStringTableEx
    class Program
        static void Main(string[] args)
            string fileName = @"C:\Users\Public\Documents\SharedStringTableEx.xlsx";

            // Create a spreadsheet document.
            SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
                Create(fileName, SpreadsheetDocumentType.Workbook);

            // Add a WorkbookPart to the document.
            WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
            workbookpart.Workbook = new Workbook();

            // Add a WorksheetPart to the WorkbookPart.
            WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
            worksheetPart.Worksheet = new Worksheet(new SheetData());

            // Add Sheets to the Workbook.
            Sheets sheets =
                spreadsheetDocument.WorkbookPart.Workbook.AppendChild<Sheets>(new Sheets());

            // Append a new worksheet and associate it with the workbook.
            Sheet sheet = new Sheet()
            { Id = spreadsheetDocument.WorkbookPart.
                SheetId = 1,
                Name = "mySheet"

            Worksheet worksheet = new Worksheet();
            SheetData sheetData = new SheetData();

            Row row =
                new Row()
                { RowIndex = 2U,
                  Spans = new ListValue<StringValue>() { InnerText = "2:2" }
            Cell cell =
                new Cell()
                { CellReference = "A2",
                  DataType = CellValues.String,
                  CellValue = new CellValue("Microsoft")
            worksheetPart.Worksheet = worksheet;


            // Close the document.
            InsertHyperLink(fileName, "", "A2");

            Console.WriteLine("The hyperlink has been inserted.\nPress a key.");

        static public void InsertHyperLink(string fileName, string uri, string cellAddress)
            // Open the document for editing.
            using (SpreadsheetDocument spreadsheetDocument =
                SpreadsheetDocument.Open(fileName, true))
                // Get the first sheet in the workbook.
                Sheet sheet1 = spreadsheetDocument.WorkbookPart.Workbook.
                WorksheetPart worksheetPart = (WorksheetPart)spreadsheetDocument.

                // Create a hyperlink relationship.
                HyperlinkRelationship hyperlinkRelationship =
                    worksheetPart.AddHyperlinkRelationship(new System.Uri
                    (uri, System.UriKind.Absolute), true);

                // Add a new shared string table part.
                SharedStringTablePart sharedStringTablePart1;
                if (spreadsheetDocument.WorkbookPart.GetPartsCountOfType
                    <SharedStringTablePart>() > 0)
                    sharedStringTablePart1 =
                    sharedStringTablePart1 =

                // Add a new shared string table.
                SharedStringTable sharedStringTable1 =
                    new SharedStringTable() { Count = (UInt32Value)1U, UniqueCount =
                        (UInt32Value)1U };
                sharedStringTablePart1.SharedStringTable = sharedStringTable1;

                // Create the hyperlink object.
                Hyperlinks hyperlinks1 = new Hyperlinks();
                Hyperlink hyperlink1 =
                    new Hyperlink() { Reference = cellAddress, Id = 
                        hyperlinkRelationship.Id };

                // Append the hyperlink to the collection. 

                // Append the hyperlink to the worksheet.
// Output:
// The hyperlink has been inserted.
// Press a key.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions