网站有个OA系统,运行的蛮稳定的就是作为用户操作的时候不太方便,页面也不太美观啊。我是想干掉它,自己重新来过。我看到不好的东西都想重新做过,不知道这种想法对不对。而自己往往也在想这个问题,所以时间都花在想问题上了根本就没有去为我的想法去执行过什么。
这个OA系统一直是网站内部用的,经常会收到群发的邮件(一般都是带了附件,而且自己又不用去存档)。诶,每次看邮件就很纠结,我把附件下载到桌面搞得桌面好乱,也有好多人和我一样的问题。于是就想到要搞个在线查看Word的功能。
到网上搜索的结果竟是word转换成pdf、网页转换成word,哎!不过最后还是找到些东西,和大家分享:
记住一定要在项目里添加引用:
主要代码:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
//
word引用程序
Application word = new Application();
// 打开一个文档
Document doc = word.Documents.Open( ref filePath,
ref confirmConversion, ref readOnly, ref addToRecentFiles, ref missing, ref missing, ref revert, ref missing, ref missing, ref missing, ref missing,
ref visible, ref missing, ref missing, ref missing, ref missing);
// 另存为网页格式
doc.SaveAs( ref savePath, ref formate, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
word.Quit( ref saveChanges, ref missing, ref missing);
Application word = new Application();
// 打开一个文档
Document doc = word.Documents.Open( ref filePath,
ref confirmConversion, ref readOnly, ref addToRecentFiles, ref missing, ref missing, ref revert, ref missing, ref missing, ref missing, ref missing,
ref visible, ref missing, ref missing, ref missing, ref missing);
// 另存为网页格式
doc.SaveAs( ref savePath, ref formate, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
word.Quit( ref saveChanges, ref missing, ref missing);