为什么dsofile.dll仍需要Office安装? [英] Why dsofile.dll still need Office Installation?

查看:91
本文介绍了为什么dsofile.dll仍需要Office安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用dsofile.dll组件编写了一小段代码,以在将文件上传到Web服务器之后修改文档属性(以设置将文件链接到数据库记录的GUID). 我从此处获取了组件和说明: http://support.microsoft.com/kb/224351

I wrote a small piece of code using the dsofile.dll component to modify document properties after upload a file to a web server (to set a guid to link the file to a database record). I took the component and intructions from here: http://support.microsoft.com/kb/224351

据我了解,它不使用Office来修改属性. 我实现了它,并在32位和64位计算机(网络服务器以32位模式运行)上对其进行了测试,并且一切正常.当时我很开心. 但是在将其部署到生命机器之后,它并没有将属性保留在我的值上,但是也不会抛出任何错误!

As far as I understanded it don't use Office to modify the properties. I implemented it and tested it on my 32 and 64 bit machine (webserver runs on 32bit mode) and all worked fine. I was happy. But after deploy it to a life machine it didn't persist the properties on my values, but don't throw any errors as well!

这里有一些代码可以查看我的工作:

Here is some code to see what I did:

public void SetProperty(string filename, string property, string value)
{
  m_oDocument.Open(filename);

  var oProp = m_oDocument.CustomProperties;
  try
  {
    oProp.Add(property, value);
  } catch(Exception)
  {
    foreach (CustomProperty cProp in oProp.Cast<CustomProperty>().Where(cProp => cProp.Name == property))
    {
      cProp.set_Value(value);
    }
  }
  if ( Debug)
  {
    m_spy.Spy("filename: " + filename);
    m_spy.Spy("filename modified: " + m_oDocument.IsDirty);
  }

  if ( m_oDocument.IsDirty ) m_oDocument.Save();
  m_oDocument.Close();

  if ( Debug ) m_spy.Spy(GetProperty(filename, property));

}

因此,我开始实施调试代码,全天阅读网络上的文章. 我最终在服务器上安装了32位Office 2010.

So I started implement debug code, read articles on the web whole day long. I ended up installing Office 2010 32bit on the server.

然后在出现新错误后:

The document is not an OLE file, and does not support extended document properties

奇怪的是,错误仅针对dotxxlsx,ff,而不是针对docxls,ff.

Strange thing the error was only for dotx, xlsx, ff, but not for doc, xls, ff.

在安装Office 2010的所有可用更新并重试之后. 然后,它可以按我希望的方式工作,并将在上载页面上设置的属性保留在所有文件上.

After I installed all available updates for Office 2010 and retried. Then it worked as I wanted and persist the properties I set with the upload page on all files.

因此,在服务器上必须安装Office 2010并不是我所期望的:)

So installing Office 2010 as a must on a server isn't what I expected todo :)

  • 有人知道dsofile.dll在不执行填充安装的情况下需要Office安装的哪些组件吗?
  • 换句话说:我可以复制一堆文件并手动在服务器上注册"它们吗?
  • 还是我误会了某些东西,这是我的代码?!

推荐答案

奇怪的是,错误仅适用于dotx,xlsx,ff,而不适用于doc,xls

Strange thing the error was only for dotx, xlsx, ff, but not for doc, xls

这是设计使然. dsofile示例仅允许访问使用OLE结构化存储容器格式的文件. OLE通常是一种过时的技术,Office是仍支持该技术的最后一批Microsoft产品之一.但是自2007年以来,这种支持已迅速消失. .dotx和.xlsx文件格式也已不复存在,它们是遵循 OpenXML规范.您无法使用dsofile访问它们.

This is by design. The dsofile sample only allows accessing files that use the OLE Structured Storage container format. OLE is a dead technology in general, Office was one of the last Microsoft products that still supported it. But that support has been disappearing quickly since the 2007 edition. It is gone for .dotx and .xlsx file formats as well, those are zipped XML files that follow the OpenXML specification. You can't access them with dsofile.

您需要去购物,以获得更好的解决方案,

You'll need to go shopping for a better solution, there are many.

这篇关于为什么dsofile.dll仍需要Office安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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