diff --git a/FastExcel/Worksheet.cs b/FastExcel/Worksheet.cs index 38b9a5b..5eac898 100644 --- a/FastExcel/Worksheet.cs +++ b/FastExcel/Worksheet.cs @@ -39,7 +39,7 @@ public class Worksheet /// public int ExistingHeadingRows { get; set; } private int? InsertAfterIndex { get; set; } - + /// /// Template /// @@ -71,6 +71,7 @@ internal static string GetFileName(int index) private const string DEFAULT_HEADERS = ""; private const string DEFAULT_FOOTERS = ""; + private const string SINGLE_SHEET = "worksheets/sheet.xml"; /// /// Constructor @@ -355,7 +356,8 @@ public void Read(int existingHeadingRows = 0) IEnumerable rows = null; var headings = new List(); - using (Stream stream = FastExcel.Archive.GetEntry(FileName).Open()) + string filename = DecideFilename(); + using (Stream stream = FastExcel.Archive.GetEntry(filename).Open()) { var document = XDocument.Load(stream); int skipRows = 0; @@ -379,6 +381,18 @@ public void Read(int existingHeadingRows = 0) Rows = rows; } + /// + /// Check if single sheet exists, and use that name accordingly. + /// + /// Filename + private string DecideFilename() + { + var filename = FastExcel.Archive.Entries.FirstOrDefault(x => x.FullName.Contains(SINGLE_SHEET))?.FullName; + if (filename == null) + filename = FileName; + return filename; + } + /// /// Returns cells using provided range ///