Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

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

$
0
0
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.

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>