none
How to check if word/excel file is valid RRS feed

  • Question

  • Hi All,

         I need to check if the file is a valid doc/docx/xls/xlsx/pdf/jpg/jpeg/png file.

    This will help me detect if the file is a valid file or if its extension has been renamed . 

    Is there any way to do validate if the file is valid?

    Any help/guidance would be greatly appreciated.

    regards,

    Pradeep

    Thursday, October 16, 2014 1:05 PM

Answers

  • Hi Pradeep,

    >>  I need to check if the file is a valid doc/docx/xls/xlsx/pdf/jpg/jpeg/png file. <<

    Based on my understanding to check the whether a file is a specific file format, we need to familar with the specfic file format.

    For example, if we want to check whether a file is a real doc or xls, we need to check whether the file fits the Office file formats. And here is an article about Office file formats for your reference:

    Office File Formats Technical Documents

    And I also found an same topic thread:
    Developing a tool to recognise MS Office file types ( .doc, .xls, .mdb, .ppt )

    And as far as I know, xlsx and docx are Office Open XML format. We can use Open XML SDK to check whether we can open the files. If the file can be used Open XML manuplate successfully, then the file format is valid. You can get started about Open XML from link below:
    Welcome to the Open XML SDK 2.5 for Office

    If you have any issues about Office file format, I suggest that you get more effective response from link below:

    Office XML, ODF, and Binary File Formats

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 17, 2014 2:17 AM
    Moderator