Loads an Excel workbook from the specified file path into a LEADWorkbook instance.
public static LEADWorkbook LoadFromFile(
string fileName,
LoadWorkbookOptions options
)
fileName
A string specifying the complete file path of the Excel workbook to be loaded. The path must be accessible by the application.
options
An instance of LoadWorkbookOptions providing additional settings for loading the workbook.
An instance of the LEADWorkbook class loaded with the content from the specified file.
using Leadtools;
using Leadtools.Document.LEADOffice.Sheet;
public void ReadExcelFileExample()
{
var filePath = Path.Combine(LEAD_VARS.ImagesDir, @"WorkbookTest.xlsx");
// Load an Excel workbook from a file
var workbook = LEADWorkbookFactory.LoadFromFile(filePath, new LoadWorkbookOptions());
Console.WriteLine("Sheets in the workbook:");
// Iterate over sheets
foreach (var sheet in workbook)
{
Console.WriteLine(sheet.Name);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}