Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.98 KB

how-to-get-worksheet-information-from-a-package.md

File metadata and controls

56 lines (39 loc) · 1.98 KB
api_name api_type ms.assetid title ms.suite ms.author author ms.topic ms.date ms.localizationpriority
Microsoft.Office.DocumentFormat.OpenXML.Packaging
schema
124cb0a0-cc47-433f-bad0-06b793890650
How to: Get worksheet information from an Open XML package
office
o365devx
o365devx
conceptual
01/03/2024
high

Get worksheet information from an Open XML package

This topic shows how to use the classes in the Open XML SDK for Office to programmatically retrieve information from a worksheet in a Spreadsheet document.

[!includeStructure]

How the Sample Code Works

After you have opened the file for read-only access, you instantiate the Sheets class.

[!code-csharp]

[!code-vb]


You then you iterate through the Sheets collection and display OpenXmlElement and the OpenXmlAttribute in each element.

[!code-csharp]

[!code-vb]


By displaying the attribute information you get the name and ID for each worksheet in the spreadsheet file.

Sample code

The following is the complete code sample in both C# and Visual Basic.

[!code-csharp]

[!code-vb]

See also

Open XML SDK class library reference