服务器报错 下载word文档失败
首先引入类库,MicrosoftOfficeInteropWord,然后进行编程。代码如下:
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemWindowsForms;
using MicrosoftOfficeInteropWord; 数据挖掘研究院
namespace WordTest
{
public partial class Form1 : Form
{
object strFileName;
Object Nothing;
MicrosoftOfficeInteropWordApplication myWordApp = new MicrosoftOfficeInteropWordApplicationClass();
Document myWordDoc;
string strContent = ""; 数据挖掘研究院
public Form1()
{
InitializeComponent();
}
数据挖掘研究院
private void button1_Click(object sender, EventArgs e)
{
createWord();
//openWord();
} 数据挖掘研究院
private void createWord()
{
strFileName = SystemWindowsFormsApplicationStartupPath + "testdoc";
if (SystemIOFileExists((string)strFileName))
SystemIOFileDelete((string)strFileName);
Object Nothing = SystemReflectionMissingValue;
myWordDoc = myWordAppDocumentsAdd(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
数据挖掘研究院
#region 将数据库中读取得数据写入到word文件中 数据挖掘研究院
strContent = "你好 ";
myWordDocParagraphsLastRangeText = strContent;
数据挖掘实验室
strContent = "这是测试程序";
myWordDocParagraphsLastRangeText = strContent; 数据挖掘研究院
#endregion 数据挖掘研究院
//将WordDoc文档对象的内容保存为DOC文档
myWordDocSaveAs(ref strFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//关闭WordDoc文档对象
myWordDocClose(ref Nothing, ref Nothing, ref Nothing);
//关闭WordApp组件对象
myWordAppQuit(ref Nothing, ref Nothing, ref Nothing);
数据挖掘研究院
thisrichTextBox1Text = strFileName + " " + "创建成功";
数据挖掘实验室
}
private void openWord()
{
fontDialog1ShowDialog();
SystemDrawingFont font = fontDialog1Font;
object filepath = "D:\aspdocx";
object oMissing = SystemReflectionMissingValue;
myWordDoc = myWordAppDocumentsOpen(ref filepath, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); 数据挖掘研究院
myWordDocContentFontSize = fontSize;
myWordDocContentFontName = fontName;
myWordDocSave();
richTextBox1Text = myWordDocContentText;
myWordDocClose(ref oMissing, ref oMissing, ref oMissing);
myWordAppQuit(ref oMissing, ref oMissing, ref oMissing);
} 数据挖掘研究院
}
数据挖掘研究院
http://wwwcnblogscom/wrtandy/archive/2006/12/13/andyhtml 数据挖掘研究院
可能是软件出错了吧。建议重新下载安装看看,
office 2013破解教程
1、首先把下载好的office 2013激活工具压缩包解压
2、之后运行“Microsoft Toolkitexe”,可以选择以管理员身份运行
3、打开之后可以看到该程序右下角有office的图标,点击它(在这个过程中,必须运行office 2013中的程序)
4、之后会出现一个新的窗口,选择“Activation”,然后再选择下面的EZ-Activator,稍微等一会
5、然后可以看到下面会出现“Product activation successful”,就激活成功了
6、再打开office 2013就是已经激活好的
office 2013:http://wwwxue51com/soft/800html
0条评论