rav*_*avi 2 .net c# asp.net excel
我正在使用以下代码来区分2003和2007办公室的excel文件.
if (Extension == ".xls" || Extension == ".xlsx")
{
}
Run Code Online (Sandbox Code Playgroud)
但现在我还需要识别2010 excel文件.请提出一些解决方案.
您可能知道.xlsx文件(与所有Office Open XML文件一样)实际上是.zip文件,其中包含一组描述内容的内部文件.那么您可以在这里找到保存文件的程序的版本号:
将.xlsx扩展名重命名为.zip(当您以编程方式执行此操作时,可以跳过该步骤,但它对演示有帮助).打开文件中包含的压缩结构.
你会docProps在里面找到一个目录,其中包含一个名为app.xml(打开它)的文件.你会发现这样的东西:
<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>
Run Code Online (Sandbox Code Playgroud)
看<Application>标签?这告诉你它已保存在Excel中(而不是Open Office).看<AppVersion>标签?那个有您正在寻找的版本号.Excel 2007是版本12,Excel 2010是14(因为使用版本号13将对整个操作进行jinxed).Excel 2013预计将是15版.
| 归档时间: |
|
| 查看次数: |
5605 次 |
| 最近记录: |