求B/S结构的程序中嵌入Word文档的解决方案

Godshow 2004-09-14 10:12:59
看了几个OA,可以把Word格式的公文做成这样:点一下就下载打开,编辑后关闭,自动上传,不知道怎么做的。求教。
...全文
245 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Godshow 2004-09-15
  • 打赏
  • 举报
回复
minutes up
yingshis 2004-09-15
  • 打赏
  • 举报
回复
up
Godshow 2004-09-15
  • 打赏
  • 举报
回复
T一下
Godshow 2004-09-14
  • 打赏
  • 举报
回复
up 1
Godshow 2004-09-14
  • 打赏
  • 举报
回复
我现在是在服务器端有个连接,点击后打开word文档,用户关闭时文档上传,看上去就像直接在本地编辑服务器上的word文档一样。
主要问题是:客户一关闭word就保存。如何捕捉客户关闭了word文档这一事件?
love040309 2004-09-14
  • 打赏
  • 举报
回复
//版权所有 2001, Microsoft Corporation
//保留所有权利
//
// 使用 csc /r:word.dll example3.cs 生成此示例
//
//
//

using System;
using System.IO;
using System.Threading;
using System.Reflection;
using Word;

public class MainClass
{
public static int Main (string[] argv)
{
//这相当于 CoCreateInstance
Application app = new Application();
//确保 Word 可见
app.Visible=true;
// 打开现有文档“example3.doc”
// 将这些变量设置为 Missing.Value 可视为向
// 函数中传递空。这一点很有必要,因为引用不能
// 传递 C# 空。
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
FileInfo[] fi = di.GetFiles("example3.doc");
if (fi.Length <= 0)
{
di = new DirectoryInfo(Environment.CurrentDirectory+@"\..\..");
fi = di.GetFiles("example3.doc");
}
object fileName = fi[0].FullName;
object optional=Missing.Value;
object visible=true;
#if OFFICEXP
_Document doc = app.Documents.Open2000( ref fileName,
#else
_Document doc = app.Documents.Open( ref fileName,
#endif
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref optional,
ref visible);

Thread.Sleep (2000); //显示打开的文档五秒钟
object first=0;
object last=doc.Characters.Count;
//选择文档中的所有字符
doc.Range(ref first, ref last).Select();
Thread.Sleep (2000); //显示此选择五秒钟
//现在剪切选定的文本
doc.Range(ref first, ref last).Cut();
Thread.Sleep (3000); //再等待五秒钟

//保存文件,并使用默认值(文件名除外)
fileName += "_new";
#if OFFICEXP
doc.SaveAs2000( ref fileName,
#else
doc.SaveAs ( ref fileName,
#endif
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional);

// 现在像好用户一样,使用 Quit 方法进行清理
object saveChanges = true;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
return 0;
}
}
love040309 2004-09-14
  • 打赏
  • 举报
回复
//版权所有 2001, Microsoft Corporation
//保留所有权利
//
// 使用
//
// csc /r:word.dll example2.cs 生成此示例
//

using System;
using System.Threading;
using System.Reflection;
using Word;

public class MainClass
{
public static int Main (string[] argv)
{
//这相当于 CoCreateInstance
Application app = new Application();
//确保 Word 可见
app.Visible=true;
//设置以创建一个空的纯文本文档
// 将这些变量设置为 Missing.Value 可视为向
// 函数中传递空。这一点很有必要,因为引用不能
// 传递 C# 空。
object template=Missing.Value;
object newTemplate=Missing.Value;
object documentType=Missing.Value;
object visible=true;
_Document doc = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);

Thread.Sleep (5000); //显示空文档五秒钟
doc.Words.First.InsertBefore ("This document is no longer empty!");
Thread.Sleep (5000); //再等待五秒钟

//保存文件,并使用默认值(文件名除外)
object fileName = Environment.CurrentDirectory+"\\example2";
object optional = Missing.Value;
#if OFFICEXP
doc.SaveAs2000( ref fileName,
#else
doc.SaveAs ( ref fileName,
#endif
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional);

// 现在像好用户一样,使用 Quit 方法进行清理
object saveChanges = true;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
return 0;
}
}
love040309 2004-09-14
  • 打赏
  • 举报
回复
//版权所有 2001, Microsoft Corporation
//保留所有权利
//
// 使用
//
// csc /r:word.dll example1.cs 生成此示例
//

using System;
using System.Threading;
using System.Reflection;
using Word;

public class MainClass
{
public static int Main (string[] argv)
{
//这相当于 CoCreateInstance
Application app = new Application();
//确保 Word 可见
app.Visible=true;
Thread.Sleep (3000); //等待三秒钟
// 现在像好用户一样,使用 Quit 方法来进行清理
// 设置这些变量可视为向函数中传递空。
// 这一点是必要的,因为引用不能传递 C# 空。
object saveChanges = Missing.Value;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
return 0;
}
}
liujuanwh 2004-09-14
  • 打赏
  • 举报
回复
up

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧