我正在尝试使用asp.net创建新的Word文档 [英] I am trying to create new word doc using asp.net

查看:68
本文介绍了我正在尝试使用asp.net创建新的Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用asp.net创建新的词文档.

我添加了Microsoft Office库12.0和名称空间

Hi all,

I am using asp.net to create new word doc.

I have added microsoft office library 12.0 and namespace

using Microsoft.Office.Core;
using Microsoft.Win32.SafeHandles;
using Microsoft.Office.Tools.Word;
using Microsoft.Office.Tools.Word.Controls;
using Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office;



但仍然发现一些错误.

我在代码中使用Word/word创建对象,并且在错误显示后的其他地方..


找不到类型或名称空间名称"word"(您是否缺少using指令或程序集引用?)

告诉我是否有人知道错误是什么...



but still finding some errors.

I use Word/word in my code to create object and somewhere else following error shows..


The type or namespace name ''word'' could not be found (are you missing a using directive or an assembly reference?)

Tell me if anyone knows what''s the error is...

推荐答案

为什么要在网站中创建Word文档?是什么让您认为这是一个ASP.NET问题?这是一个C#问题,一个Office互操作问题.该代码与在网站上运行的b/c没什么不同.

在我看来,您的错误就像您键入"word"而不是"Word"一样,C#区分大小写.由于您未发布任何代码,因此很难再说了.您的using语句列表不是您的错误出处,因此无关紧要.

您正在网站中使用IO,Reflection,Office和Win32吗?听起来对我来说根本是个坏主意....
Why would you create a word doc in a website ? What makes you think this is an ASP.NET question ? It''s a C# question, and an Office interop question. The code is no different b/c it runs in a website.

Your error looks to me like you typed ''word'' instead of ''Word'', C# is case sensitive. As you posted no code, it''s hard to say any more. Your list of using statements is not where your error comes from, so it is irrelevant.

You''re using IO, Reflection, Office and Win32 in a website ? This sounds like a fundamentally bad idea to me....


首先-您需要下载Office Primary Interop程序集
Office 2003 PIA可以在这里找到


http://www.microsoft.com/downloads/details.aspx?familyid = 3c9a983a-ac14-4125-8ba0-d36d67e0f4ad& displaylang = zh_CN [
First of all - You need to download Office Primary Interop Assemblies
Office 2003 PIA can be found here


http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en[^]


But before you start with interop you might want to know that due to security issues, you won''t be able to access Office Interop when running on IIS server due to security issues with asp.net user (usually IIS_USER or something like that) Which runs using Network Permissions and doesn''t have access to office interop.

You might search google for an alternative to create doc.
I think I saw an open-xml SDK from microsoft to generate docx files from code.


这篇关于我正在尝试使用asp.net创建新的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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