ASP.NET读取word到页面
JavaScript实现:
<mce:script type ="text/javascript" ><!--
function readWord()
{
var div1=document .getElementById ("div1");
var WordApp,WordDoc,Str;
WordApp =new ActiveXObject ("Word.application");
WordDoc =WordApp.Documents.Open("F:\\工作日志.doc");
Str =WordDoc .content.text;
WordDoc .close();
WordApp .quit();
div1.innerHTML =Str ;
}
// --></mce:script>
<div id="div1">
</div>
<input id="Button2" type="button" value="button" OnClick ="readWord();"/>
C#实现:(添加office引用)
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
protected void Page_Load(object sender, EventArgs e)
{
this .Literal1 .Text =GetTest ("F:\\工作日志.doc");
}
public string GetTest(string FileName)
{
Microsoft.Office.Interop.Word.ApplicationClass WordApi = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileObject = FileName;
object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = WordApi.Documents.Open(ref fileObject, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
string StrText = doc.Content.Text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
WordApi.Quit(ref nullobj, ref nullobj, ref nullobj);
return StrText;
}
相关文档:
在Web编程过程中,存在着很多安全隐患。比如在以前的ASP版本中,Cookie为访问者和编程者都提供了方便,并没有提供加密的功能。打开IE浏览器,选择“工具”菜单里的“Internet选项”,然后在弹出的对话框里单击“设置”按钮,选择“查看文件”按钮,在弹出的窗口中,就会显示硬盘里 ......
分页这个也是最多人问的,也是很基础很实用的。
网上有很多分页代码,要不是有前台就没后台,要不是有后台没前台,要不是就是控件,要不就是一大堆SQL代码,让人不知道怎样用。
力求最简单最易懂.三层架构那些就不搞了。自己下载一个
如果是access 就用这个SQLHELPER [URL=http://hi.csdn.net/link.php?url=http://blo ......
为什么要去了解ASP.NET运行时模型(HTTPRuntime)
在学习ASP.NET之前,最好先学习一下ASP.NET的运行时模型,其实ASP.NET的编程模型分为ASP.NET的运行时模型和页面变成模型。许多的参考书只是直接的介绍ASP.NET的页面编程模型,而忽略了运行时模型,页面编程模型是ASP.NET程序员主要做的事情,但在做这些工作之前,充分的 ......
ASP.NET页面刷新方法总结
先看看ASP.NET页面刷新的实现方法:
第一:
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } 第二:
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script langua ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
/// <summary>
/// 一些常用的Js调用
/// 添加新版说明:由于旧版普遍采用Response.Write(string msg)的方式输出js脚本,这种
/// 方式输出的js脚本会在html元素的<html>&a ......