none
Invalid file signature - at ExcelDataReader.ExcelReaderFactory.CreateReader(Stream fileStream, ExcelReaderConfiguration configuration)

    Question

  • Hello,

    I am using Excel reader to read .xls..xlsx files and that will return me as Data set, but one of the file having error as Invalid file signature. 

    below is the file data.. and that will open in excel format. Please suggest how to handle this kind of files in excel reader.

    code :

     using (var stream = File.Open(filepath, FileMode.Open, FileAccess.Read))
                    {
                        IExcelDataReader excelReader = ExcelReaderFactory.CreateReader(stream);
                        dsresult = excelReader.AsDataSet();
                        return dsresult;
              }

    File data :

    MIME-Version: 1.0
    X-Document-Type: Worksheet
    Content-Type: multipart/related; boundary="NEXTMIME"


    --NEXTMIME
    Content-Location: file:///C:/abc/Doc.htm
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/html; charset="UTF-8"

    <html xmlns:v=3D"urn:schemas-microsoft-com:vml"
    xmlns:o=3D"urn:schemas-microsoft-com:office:office"
    xmlns:x=3D"urn:schemas-microsoft-com:office:excel"
    xmlns=3D"http://www.w3.org/TR/REC-html40">

    <head>
    <meta name=3D"Excel Workbook Frameset">
    <meta http-equiv=3DContent-Type content=3D"text/html; charset=3DUTF-8">
    <meta name=3DProgId content=3DExcel.Sheet>
    <meta name=3DGenerator content=3D"Microsoft Excel 11">
    <style> br{mso-data-placement:same-cell;}
    .x4 {text-align:right;vertical-align:middle;background:#ffffff;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    .x1 {text-align:right;vertical-align:middle;background:#c6c4c4;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    .x7 {text-align:right;vertical-align:middle;background:#fff843;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    .x2 {text-align:left;vertical-align:middle;background:#c6c4c4;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    .x5 {text-align:right;vertical-align:middle;background:#e9eef4;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    .x0 {text-align:left;vertical-align:middle;background:#c6c4c4;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0;}
    .x3 {text-align:right;vertical-align:middle;background:#c6c4c4;border-bottom:1.0pt solid #aeaeae;border-border-border-right:1.0pt solid #aeaeae;padding-padding-right:3.0pt;padding-padding-bottom:3.0pt;mso-char-indent-count:0;}
    .x6 {text-align:left;vertical-align:middle;background:#fff843;border-bottom:1.0pt solid #aeaeae;border-top:1.0pt solid #aeaeae;border-left:1.0pt solid #aeaeae;border-right:1.0pt solid #aeaeae;padding-left:3.0pt;padding-right:3.0pt;padding-top:3.0pt;padding-bottom:3.0pt;mso-char-indent-count:0; color:#000000; font-size:8.0pt; font-family:Arial;}
    </style>
    </head>
    <body>
    <xml>

    Thanks in advance.

    Guruprasa

    Tuesday, August 7, 2018 5:19 AM