如何检查Excel文件是否是2007年或2010年的办公室 [英] how to check whether excel file is of 2007 or 2010 office

查看:163
本文介绍了如何检查Excel文件是否是2007年或2010年的办公室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code区分2003年和2007年的Excel文件的办公室。

i am using following code to differentiate excel file of 2003 and 2007 office.

if (Extension == ".xls" || Extension == ".xlsx")
 {
 }

但现在我还需要确定2010 excel文件。请提出了一些解决方案。

but now i also need to identify 2010 excel file. please suggest some solution.

推荐答案

你可能知道的.xlsx文件(如所有的Office Open XML文件)是包含了一组描述的内容在内的文件实际上是.zip文件。因此,这里就是你去发现,保存该文件的程序版本号:

You're probably aware that .xlsx files (like all Office Open XML files) are actually .zip files that contain a set of inner files that describe the content. So here's where you go to find the version number of the program that saved the file:

重命名的.xlsx扩展为.zip(当你做这个编程,你可以跳过这一步,但它是有帮助的演示)。打开该文件中包含压缩的结构。

Rename the .xlsx extension to .zip (when you're doing this programatically, you can skip that step, but it's helpful for demonstration). Open up the zipped structure contained in the file.

您会发现一个 docProps 目录中,其中包含一个名为程序app.xml (打开) 。你会发现一些看起来是这样的:

You'll find a docProps directory inside, which contains a file called app.xml (open it). You'll find something that looks like this:

<Properties>
  <Application>Microsoft Excel</Application>
  <DocSecurity>0</DocSecurity>
  <ScaleCrop>false</ScaleCrop>
  <HeadingPairs>
    <vt:vector size="2" baseType="variant">
      <vt:variant>
        <vt:lpstr>Worksheets</vt:lpstr>
      </vt:variant>
      <vt:variant>
        <vt:i4>3</vt:i4>
      </vt:variant>
    </vt:vector>
  </HeadingPairs>
  <TitlesOfParts>
    <vt:vector size="3" baseType="lpstr">
      <vt:lpstr>Sheet1</vt:lpstr>
      <vt:lpstr>Sheet2</vt:lpstr>
      <vt:lpstr>Sheet3</vt:lpstr>
    </vt:vector>
  </TitlesOfParts>
  <LinksUpToDate>false</LinksUpToDate>
  <SharedDoc>false</SharedDoc>
  <HyperlinksChanged>false</HyperlinksChanged>
  <AppVersion>14.0300</AppVersion>
</Properties>

&lt;应用&GT; 标签?这告诉你,它保存在Excel中(而不是,说开放式办公)。请参阅&LT; AppVersion&GT; 标签?那人有你要找的版本号。 Excel 2007是12版的,和Excel 2010是14(因为使用版本号13将太不幸了整个操作)。的Excel 2013预期为15版

See the <Application> tag? That tells you that it was saved in Excel (as opposed to, say Open Office). See the <AppVersion> tag? That one has the version number you're looking for. Excel 2007 is version 12, and Excel 2010 is 14 (because using version number 13 would have jinxed the whole operation). Excel 2013 is expected to be version 15.

这篇关于如何检查Excel文件是否是2007年或2010年的办公室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆