locked
Detect Excel 2007 workbook type RRS feed

  • Question

  • Is it best to best to enumerate all of the file types (XLSM, XLSX, etc) to detect whether a file is an Excel 2007 workbook or an earlier version ?

    Or just detecting "XL" for the file type's first 2 chars with a type length of 4 sufficient ?

    That being said, what's to stop someone from copying an XLS file as XLSX ?
    Is there a way to Open a workbook as BINARY and read some byte values to determine if it's been zip-encoded and therefore XL 2007 format ?

     

    Monday, March 28, 2011 4:42 PM

Answers

  • You can see how to check the file format in the code example on this page
     
     

    Regards Ron de Bruin
    http://www.rondebruin.nl/tips.htm


    "Syswizard" wrote in message news:979017fc-284b-468e-8191-31143f64a34a...

    Is it best to best to enumerate all of the file types (XLSM, XLSX, etc) to detect whether a file is an Excel 2007 workbook or an earlier version ?

    Or just detecting "XL" for the file type's first 2 chars with a type length of 4 sufficient ?

    That being said, what's to stop someone from copying an XLS file as XLSX ?
    Is there a way to Open a workbook as BINARY and read some byte values to determine if it's been zip-encoded and therefore XL 2007 format ?

     

    • Marked as answer by Syswizard Tuesday, March 29, 2011 4:49 PM
    Monday, March 28, 2011 4:45 PM

All replies

  • You can see how to check the file format in the code example on this page
     
     

    Regards Ron de Bruin
    http://www.rondebruin.nl/tips.htm


    "Syswizard" wrote in message news:979017fc-284b-468e-8191-31143f64a34a...

    Is it best to best to enumerate all of the file types (XLSM, XLSX, etc) to detect whether a file is an Excel 2007 workbook or an earlier version ?

    Or just detecting "XL" for the file type's first 2 chars with a type length of 4 sufficient ?

    That being said, what's to stop someone from copying an XLS file as XLSX ?
    Is there a way to Open a workbook as BINARY and read some byte values to determine if it's been zip-encoded and therefore XL 2007 format ?

     

    • Marked as answer by Syswizard Tuesday, March 29, 2011 4:49 PM
    Monday, March 28, 2011 4:45 PM
  • Thanks much Ron - well done indeed !

     

    Tuesday, March 29, 2011 4:50 PM