NanoXLSX.Reader 3.1.0
Loading...
Searching...
No Matches
Extensions/WorkbookReader.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2026
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System.IO;
9using System.Threading.Tasks;
11using NanoXLSX.Registry;
12
14{
18 public static class WorkbookReader
19 {
20 static WorkbookReader()
21 {
22 PlugInLoader.Initialize();
23 }
24
32 public static Workbook Load(string filename, ReaderOptions options = null)
33 {
34 using (XlsxReader reader = new XlsxReader(filename, options))
35 {
36 reader.Read();
37 reader.Workbook.Filename = filename;
38 return reader.Workbook;
39 }
40 }
41
49 public static Workbook Load(Stream stream, ReaderOptions options = null)
50 {
51 using (XlsxReader reader = new XlsxReader(stream, options))
52 {
53 reader.Read();
54 return reader.Workbook;
55 }
56 }
57
65 public static async Task<Workbook> LoadAsync(string filename, ReaderOptions options = null)
66 {
67 using (XlsxReader reader = new XlsxReader(filename, options))
68 {
69 await reader.ReadAsync();
70 reader.Workbook.Filename = filename;
71 return reader.Workbook;
72 }
73 }
74
82 public static async Task<Workbook> LoadAsync(Stream stream, ReaderOptions options = null)
83 {
84 using (XlsxReader reader = new XlsxReader(stream, options))
85 {
86 await reader.ReadAsync();
87 return reader.Workbook;
88 }
89 }
90 }
91}
static Workbook Load(Stream stream, ReaderOptions options=null)
Loads a workbook from a stream.
static Workbook Load(string filename, ReaderOptions options=null)
Loads a workbook from a file.
static async Task< Workbook > LoadAsync(string filename, ReaderOptions options=null)
Loads a workbook from a file asynchronously.
static async Task< Workbook > LoadAsync(Stream stream, ReaderOptions options=null)
Loads a workbook from a stream asynchronously.
Class representing a reader to decompile XLSX files.
Definition XlsxReader.cs:27
async Task ReadAsync()
Reads the XLSX file from a file path or a file stream asynchronously.
void Read()
Reads the XLSX file from a file path or a file stream.
Definition XlsxReader.cs:74
Workbook Workbook
Gets the read workbook.
Definition XlsxReader.cs:39