KeyNotNotFoundException when opening a spreadsheet


When creating a new HSSFWorkbook it throws KeyNotFoundException.

Compiled with .net 4 full profile x86 against both 1.2.5 and 2.0alpha.
internal static class Program
    private static void Main (string[] args)
        var stream = File.Open ("Test.xls", FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete);
        var workbook = new HSSFWorkbook (stream);
mscorlib.dll!System.Collections.Generic.Dictionary<string,NPOI.POIFS.FileSystem.Entry>.this[string].get(string key) + 0x56 bytes    
    NPOI.dll!NPOI.POIFS.FileSystem.DirectoryNode.GetEntry(string name = "Workbook") + 0x50 bytes    
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.GetWorkbookDirEntryName(NPOI.POIFS.FileSystem.DirectoryNode directory = {NPOI.POIFS.FileSystem.DirectoryNode}) + 0x76 bytes   
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.HSSFWorkbook(NPOI.POIFS.FileSystem.DirectoryNode directory = {NPOI.POIFS.FileSystem.DirectoryNode}, bool preserveNodes = true) + 0x7c bytes   
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.HSSFWorkbook(NPOI.POIFS.FileSystem.DirectoryNode directory = {NPOI.POIFS.FileSystem.DirectoryNode}, NPOI.POIFS.FileSystem.POIFSFileSystem fs = {NPOI.POIFS.FileSystem.POIFSFileSystem}, bool preserveNodes = true) + 0x2b bytes   
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.HSSFWorkbook(NPOI.POIFS.FileSystem.POIFSFileSystem fs = {NPOI.POIFS.FileSystem.POIFSFileSystem}, bool preserveNodes = true) + 0x41 bytes  
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.HSSFWorkbook(System.IO.Stream s = {System.IO.FileStream}, bool preserveNodes = true) + 0x44 bytes 
    NPOI.dll!NPOI.HSSF.UserModel.HSSFWorkbook.HSSFWorkbook(System.IO.Stream s = {System.IO.FileStream}) + 0x28 bytes    
in DirectoryNode.GetEntry
this = {Root Entry}
name = "Workbook"

file attachments


chilversc wrote Mar 5, 2013 at 11:05 AM

When saving for an older version I'd selected "Microsoft Excel 5.0/95 Workbook (.xls)". It seems this format is not supported, saving the file as "Excel 97-2003 Workbook (.xls)" works correctly.

So either 5.0/95 is an unsupported format and the documentation needs to mention that, or there's a bug somewhere.

wrote Mar 20, 2013 at 9:37 AM