class Program
{
static void Main(string[] args)
{
GetSheetInfo(@"..\..\Documents\Sheet4.xlsx");
}
public static void GetSheetInfo(string fileName)
{
// Open file as read-only.
using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(fileName, false))
{
S sheets = mySpreadsheet.WorkbookPart.Workbook.Sheets;
// For each sheet, display the sheet information.
foreach (E sheet in sheets)
{
foreach (A attr in sheet.GetAttributes())
{
Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value);
}
}
}
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
GetSheetInfo(@"..\..\Documents\Sheet4.xlsx");
}
private static void GetSheetInfo(string fileName)
{
//Initialize a new Workboook object
Workbook workbook = new Workbook();
//Load the document
workbook.LoadFromFile(fileName);
//Loop through all Sheets in the workbook
foreach (Worksheet Sheet in workbook.Worksheets)
{
//Get Name,ID and Index of Sheet
Console.WriteLine("Sheet Name: {0}", Sheet.Name);
Console.WriteLine("Sheet Index: {0}", Sheet.Index);
Console.WriteLine("Sheet ID: {0}", Sheet.SheetId);
Console.ReadKey();
}
}
}