Utilize Sheet.SheetId property of OpenXml using Aspose.Cells
Contents
[
Hide
]
Possible Usage Scenarios
Sheet.SheetId property is found inside the DocumentFormat.OpenXml.Spreadsheet namespace and is part of OpenXml. You can see this property and its value inside workbook.xml as shown in the following screenshot. Aspose.Cells provides the equivalent property as Worksheet.TabId.
Utilize Sheet.SheetId property of OpenXml using Aspose.Cells
The following sample code loads the sample Excel file, reads its Sheet or Tab Id, then assigns it new Tab Id and saves it as output Excel file. Please also see the console output of the code given below for a reference.
Sample Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load source Excel file | |
Workbook wb = new Workbook("sampleSheetId.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Print its Sheet or Tab Id on console | |
Console.WriteLine("Sheet or Tab Id: " + ws.TabId); | |
//Change Sheet or Tab Id | |
ws.TabId = 358; | |
//Save the workbook | |
wb.Save("outputSheetId.xlsx"); |
Console Output
Sheet or Tab Id: 1297