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;
}
相关文档:
b/s模式下用程序实现计划任务,一直是个不太好解决和管理的问题,当然可以采用ajax 计时器的方法模拟form端的timer事件。asp.net下实现可以将计划任务的方法放在global里,使用一个统一的任务管理类来管理各种任务的执行,做到并行不悖!
下面是我写的一个方法,希望起个抛砖引玉的作用!大家一起学习下:
第一步定 ......
(1)在WEB页面上加入JS脚本和存放ListBox事件的隐藏输入框,LISTBOX是用来保存时间的名称,在CS页面用到:其JS代码如下:
<script language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so t ......
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 ......
1、由dataset生成
public void CreateExcel(DataSet ds,string typeid,string FileName)
{
HttpResponse resp;
resp = Page.Response;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AppendHeader("Conte ......