jsp页面数据导入word
一、把jsp页面数据复制到word文档
var table=document.getElementById('printTable');
row=table.rows.length;
column=table.rows(1).cells.length;
var word = new ActiveXObject("Word.Application");
word.Application.Visible = true;
word.Selection.Text ="<%=reportTitle%>";
var mydoc=word.Documents.Add('',0,0);
myRange =mydoc.Range(0,1);
var sel=document.body.createTextRange();
sel.moveToElementText(table);
sel.select();
sel.execCommand('Copy');
myRange.Paste();
二、把jsp页面数据写入word文档
var table=document.getElementById('printTable');
row=table.rows.length;
column=table.rows(1).cells.length;
var wdapp=new ActiveXObject("Word.Application");
wdapp.visible=true;
wddoc=wdapp.Documents.Add(); //添加新的文档
thearray=new Array();
//将页面中表格的内容存放在数组中
for(i=0;i<row;i++){
thearray[i]=new Array();
for(j=0;j<column;j++){
thearray[i][j]=table.rows(i).cells(j).innerHTML;
}
}
var range = wddoc.Range(0,0);
range.Text="<%=reportTitle%>"+"\n";
wdapp.Application.Activedocument.Paragraphs.Add(range);
wdapp.Application.Activedocument.Paragraphs.Add();
rngcurrent=wdapp.Application.Activedocument.Paragraphs(3).Range;
var objTable=wddoc.Tables.Add(rngcurrent,row,column) //插入表格
for(i=0;i<row;i++){
for(j=0;j<column;j++){
objTable.Cell(i+1,j+1).Range.Text = thearray[i][j].replace(" ","");
}
}
相关文档:
Ajax和jsp的怪现象
如果用Ajax去请求一个jsp页面,该jsp页面返回的是xml(response.setContentType("text/xml; charset=GB2312");),并且该jsp包含下面这些头@page指令的话,则在客户端xml=XMLHttpRequest.responseXML得到的是一个不包含任务东西的xml对象,即xml.childNodes.length将会是0.
......
如果在自订标签库时,并不需要对标签本体作处理,则您可以继承TagSupport类别,TagSupport类别实作了Tag与 IterationTag介面,IterationTag介面则是Tag介面的子介面,TagSupport类别替您预先实作了这两个介面中的方法,在继承TagSupport之后,您视需要来改写当中的一些方法(这是 Default Adapter模式)。
Tag介面中与标签 ......
简单介绍JSP数据库操作的3个小技巧:数据排序,主/从表处理,事务处理。
1 数据排序
在数据库技术中,可以使用ORDER子句对查询结果进行排序
[ ORDER BY { order_by_exdivssion[ ASC | DESC]} [ ¸…n ] ]
其中,order_by_exdivssion用来指定要排序的列;ASC指定按递增顺序排列;DESC指定按递减顺序排序 ......
http://www.egzcn.com/article/webbc/JSP/2006-03-22/2003.html 来源
摘要:虽然session机制在web应用程序中被采用已经很长时间了,但是仍然有很多人不清楚session机制的本质,以至不能正确的应用这一技术。本文将详细讨论session的工作机制并且对在Java web application中应用session机制时常见的问题作 ......