window server2008 word转html iis7配置无法转换问题
2013-03-19 09:34
441 查看
问题描述:刚开始在调试模式下可以转换成功,部署到问win2003 iis6下无法转换,后来设置权限可以转换,但部署到win2008 iis7下 无法转换,发现win2008下没有office组件,但是确实安装了(详见1解决);后来是无法访问上传doc文档,设置站点的asp net用户访问权限,后来读取 Document doc = (Document)docsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, (object)docs,
new Object[] { fileName, true, true });doc返回null值(详见2,3)
1.不到 office组件的问题
在运行中 输入 regedit 打开注册表
进行收索“000209FF-0000-0000-C000-000000000046”,你会找到下面这个东东:
将“AppID”修改为“CLSID” 然后保存,如果没有就新建CLSID 值:{00020906-0000-0000-C000-000000000046} 重启服务器
之后查看组件服务应该就会出现了
参考:/article/8892504.html
2.组件服务配置
(1)、 Cmd中输入命令 comexp.msc -32 启动组件服务(启动组件服务 方法 运行 mmc、mmc -32(32) 、DCOMCNFG.exe(64)) 不行一个一个
(2)、 依次双击"组件服务"->"计算机"->"我的电脑"->"DCOM配置";
(3)、 在"DCOM配置"中找到"Microsoft Excel Application",在它上面点击右键,然后点击"属性",弹出"Microsoft Excel应用程序属性"对话框;
(4)、 点击"标识"标签,选择 启动用户(默认选项) ,网上都写修改为交互式(但不知道为什么每次需要用户登录一下才能有效),后来直接指定用户;
(5)、 点击"安全"标签,在以下 三个项目中都选中 “自定义” 添加 ”everyone” 并分配最大权限(全选)
(6) 、设置Web.config文件 在Web.config文件的<system.web>中加入<identity impersonate="true"/> (没有这一步 会报Excel进程无法打开相应的excel文件)。
参考:/article/4888745.html
3.新建个Desktop目录
・Windows 2008 Server x64
Please make this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop
・Windows 2008 Server x86
Please make this folder.
C:\Windows\System32\config\systemprofile\Desktop
并将访问权限设置为net service
4.检查IIS7的设置
最后确定还需要设置应用程序池的标识,把此网站的AppPool的标识要设置为LocalSystem或者NetworkService
详细出处参考:
参考:/article/5295286.html
http://bbs.csdn.net/topics/360262598
附转换代码
string wordPath = Server.MapPath("/word/1.doc");
string htmlPath = Server.MapPath("/html/1.html");
//上传word文件, 由于只是做示例,在这里不多做文件类型、大小、格式以及是否存在的判断
FileUpload1.SaveAs(wordPath);
#region 文件格式转换
//请引用Microsoft.Office.Interop.Word
ApplicationClass word = new ApplicationClass();
Type wordType = word.GetType();
Documents docs = word.Documents;
// 打开文件
Type docsType = docs.GetType();
object fileName = wordPath;
Document doc = (Document)docsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, (object)docs, new Object[] { fileName, true, true });
//判断与文件转换相关的文件是否存在,存在则删除。(这里,最好还判断一下存放文件的目录是否存在,不存在则创建)
if (File.Exists(htmlPath)) { File.Delete(htmlPath); }
//每一个html文件,有一个对应的存放html相关元素的文件夹(html文件名.files)
if (Directory.Exists(htmlPath.Replace(".html", ".files")))
{
Directory.Delete(htmlPath.Replace(".html", ".files"), true);
};
//转换格式,调用word的“另存为”方法
Type docType = doc.GetType();
object saveFileName = htmlPath;
docType.InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, WdSaveFormat.wdFormatHTML });
// 退出 Word
wordType.InvokeMember("Quit", BindingFlags.InvokeMethod, null, word, null);
new Object[] { fileName, true, true });doc返回null值(详见2,3)
1.不到 office组件的问题
在运行中 输入 regedit 打开注册表
进行收索“000209FF-0000-0000-C000-000000000046”,你会找到下面这个东东:
将“AppID”修改为“CLSID” 然后保存,如果没有就新建CLSID 值:{00020906-0000-0000-C000-000000000046} 重启服务器
之后查看组件服务应该就会出现了
参考:/article/8892504.html
2.组件服务配置
(1)、 Cmd中输入命令 comexp.msc -32 启动组件服务(启动组件服务 方法 运行 mmc、mmc -32(32) 、DCOMCNFG.exe(64)) 不行一个一个
(2)、 依次双击"组件服务"->"计算机"->"我的电脑"->"DCOM配置";
(3)、 在"DCOM配置"中找到"Microsoft Excel Application",在它上面点击右键,然后点击"属性",弹出"Microsoft Excel应用程序属性"对话框;
(4)、 点击"标识"标签,选择 启动用户(默认选项) ,网上都写修改为交互式(但不知道为什么每次需要用户登录一下才能有效),后来直接指定用户;
(5)、 点击"安全"标签,在以下 三个项目中都选中 “自定义” 添加 ”everyone” 并分配最大权限(全选)
(6) 、设置Web.config文件 在Web.config文件的<system.web>中加入<identity impersonate="true"/> (没有这一步 会报Excel进程无法打开相应的excel文件)。
参考:/article/4888745.html
3.新建个Desktop目录
・Windows 2008 Server x64
Please make this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop
・Windows 2008 Server x86
Please make this folder.
C:\Windows\System32\config\systemprofile\Desktop
并将访问权限设置为net service
4.检查IIS7的设置
最后确定还需要设置应用程序池的标识,把此网站的AppPool的标识要设置为LocalSystem或者NetworkService
详细出处参考:
参考:/article/5295286.html
http://bbs.csdn.net/topics/360262598
附转换代码
string wordPath = Server.MapPath("/word/1.doc");
string htmlPath = Server.MapPath("/html/1.html");
//上传word文件, 由于只是做示例,在这里不多做文件类型、大小、格式以及是否存在的判断
FileUpload1.SaveAs(wordPath);
#region 文件格式转换
//请引用Microsoft.Office.Interop.Word
ApplicationClass word = new ApplicationClass();
Type wordType = word.GetType();
Documents docs = word.Documents;
// 打开文件
Type docsType = docs.GetType();
object fileName = wordPath;
Document doc = (Document)docsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, (object)docs, new Object[] { fileName, true, true });
//判断与文件转换相关的文件是否存在,存在则删除。(这里,最好还判断一下存放文件的目录是否存在,不存在则创建)
if (File.Exists(htmlPath)) { File.Delete(htmlPath); }
//每一个html文件,有一个对应的存放html相关元素的文件夹(html文件名.files)
if (Directory.Exists(htmlPath.Replace(".html", ".files")))
{
Directory.Delete(htmlPath.Replace(".html", ".files"), true);
};
//转换格式,调用word的“另存为”方法
Type docType = doc.GetType();
object saveFileName = htmlPath;
docType.InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, WdSaveFormat.wdFormatHTML });
// 退出 Word
wordType.InvokeMember("Quit", BindingFlags.InvokeMethod, null, word, null);
相关文章推荐
- SERVER2008IIS服务器不能正常使用(由于扩展配置问题而无法提供您请求的页面,如果该页面是脚本...)
- window Server 2008 R2 配置IIS7 .net网站部署环境
- 2008server 无法读取配置节system.serviceModel
- window server 2008上安装Oracle遇到的问题
- Word-CHM-HTML-WEB傻瓜式转换专家2008
- 阿里云WinServer2008下配置IIS7支持php
- 在window server 2008 64位系统上 发布网站的过程中遇到的问题
- 网站部署到IIS7上出现HTTP 错误 500.19(由于权限不足而无法读取配置文件)的问题
- VC 2008问题: 应用程序无法启动,因为应用程序的并行配置不正确
- IIS7虚拟目录出现HTTP错误500.19(由于权限不足而无法读取配置文件)的问题
- window下Apache HTTP Server 2.2.4 配置代理解决ajax跨域问题
- 请问如何解决WORD转HTML是出现的“内存或磁盘空间不足,无法显示或打印图片”这个问题?
- Window Server 2008上安装Sql Server 2008后不能登录的问题与解决
- Window Server 2008 R2 +IIS7.5 部署WCF Rest问题
- service2008 word 导入导出 配置问题
- IIS中遇到无法预览的问题(HTTP 错误 401.3 - Unauthorized 因为 Web server上此资源的訪问控制列表(ACL)配置或加密设置,您无权查看此文件夹或页面。)
- Server 2008上IIS配置过程中遇到的问题及解决办法
- 安装Window Server 2008的些配置
- server_name配置的随便写的域名,客户机无法访问问题?
- Server 2008上IIS配置过程中遇到的问题及解决办法