Impossible to read Excel 2003 XML file with NPOI for .Net Framework 3.5

Apr 30, 2014 at 3:45 PM
Edited Apr 30, 2014 at 3:47 PM
When I use the following code to open the an Excel 2003 XML file I have the "Invalid header signature; read 0x6C6D783F3CBFBBEF, expected 0xE11AB1A1E011CFD0" Exception :

using (StreamReader input = new StreamReader(fileName))
{
IWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(input.BaseStream));
if (null == workbook)
{
    Console.WriteLine(string.Format("Excel Workbook '{0}' could not be opened.", fileName));
}
else
{
    // calculates/updates the formulas on the given workbook
    IFormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator(workbook);
    DataFormatter dataFormatter = new HSSFDataFormatter(new CultureInfo("en-US"));

    Console.WriteLine();
    foreach (ISheet sheet in workbook)
    {
        Console.WriteLine("\n\n***   Worksheet " + sheet.SheetName + "   ***");
        foreach (IRow row in sheet)
        {
            if (0 == row.RowNum % 10) { Console.WriteLine(); }
            Console.Write(string.Format("Row {0,2}: ", row.RowNum + 1));
            foreach (ICell cell in row)
            {
                //string value = GetValue(cell, dataFormatter, formulaEvaluator);
                //string commentText = GetComment(cell);
                //Console.Write(string.Format("{0}{1};",
                //    string.IsNullOrEmpty(value) ? "" : value,
                //    string.IsNullOrEmpty(commentText) ? "" : " [" + commentText + "]"));
            }
            Console.WriteLine();
        }
    }
}
}

Could y please give me a solution ?

If you give me an email address I can send you my Excel file.

Best regards.
Coordinator
May 12, 2014 at 3:46 PM
NPOI never supports Excel XML format. only xls and xlsx are supported.
Marked as answer by tonyqus on 5/13/2014 at 3:41 PM