
Bootstrap结合BootstrapTable的使用,分为两种模试显示列表。
引用的css:
<link href="@UrlContent("~/Css/bootstrapmincss")" rel="stylesheet" type="text/css" />
<link href="@UrlContent("~/Css/bootstrap-tablecss")" rel="stylesheet" type="text/css" />
引用的JS:
<script src="//Scripts/jqueryjs" type="text/javascript"></script>
<script src="//Scripts/bootstrapminjs" type="text/javascript"></script>
<script src="//Scripts/bootstrap-tablejs" type="text/javascript"></script>
<script src="//Scripts/bootstrap-table-zh-CNjs" type="text/javascript"></script>
常用方法:
刷新表格:$tablebootstrapTable('refresh');
获取选择的行:$tablebootstrapTable('getSelections');
1服务端请求:即当数据量大,千百万条数据的情况下,只获取当页条件下的数据。每点击分页或查询都向服务端重新获取分页数据。
前端代码:
1
2
3
4
5
6
7
function
initTable() {
var
queryUrl = '@UrlContent("~/Welcome/QueryList")'
+ 'rnd='
+ +Mathrandom();
$table = $('#table-javascript')bootstrapTable({
//method: 'get',<br><br>
method: 'post',
contentType: "application/x->
1)如下图:
2)点击导出按钮后预览:
3)最终生成的excel表格预览:
二:代码演示:
说明:执行 *** 作时,请先引进导出excel表格的jar文件包。
找到导出按钮所执行的js方法,在java后天查看该方法的实现即可。
1)jsp代码:
[html] view plaincopyprint
<%@ page language="java" import="javautil" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = requestgetContextPath();
String basePath = requestgetScheme() + "://"
+ requestgetServerName() + ":" + requestgetServerPort()
+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>驾校合格率排名</title>
<link href="jsp/commonstyle/css/tabStylecss" rel="stylesheet" type="text/css">
<link rel="STYLESHEET" type="text/css" href="<%=basePath%>jsp/hgltj/js/tablesortcss">
<script type="text/javascript" src="<%=basePath%>jsp/system/common/js/publicColorjs"></script>
<script type="text/javascript" src="jsp/commonstyle/js/js/My97DatePicker/WdatePickerjs" defer="defer"></script>
<script type="text/javascript" src="<%=basePath%>jsp/hgltj/js/tablesortjs"></script>
<script language="JavaScript">
function load()
{
//根据分辨率设置表格大小
maxw=documentgetElementById("maintb")offsetWidth;
if(maxw<824){//1024分辨率未展开
mainboxwidth="98%";
} else if(maxw<1013){//1024分辨率展开
mainboxwidth="98%";
} else if(maxw<1081){//1280分辨率未展开
mainboxwidth="95%";
} else if(maxw<1270){//1280分辨未展开
mainboxwidth="95%";
}else{//1280以上分辨展开
mainboxwidth="98%";
}
}
</script>
<script>
function overIt(){
var the_obj = eventsrcElement;
if(the_objtagNametoLowerCase() == "td"){
the_obj=the_objparentElement;
the_objoBgc=the_objcurrentStylebackgroundColor;
the_objoFc=the_objcurrentStylecolor;
the_objstylebackgroundColor='#4073C4';
the_objstylecolor='#ffffff';
the_objstyletextDecoration='underline';
}
}
function outIt(){
var the_obj = eventsrcElement;
if(the_objtagNametoLowerCase() == "td"){
the_obj=the_objparentElement;
the_objstylebackgroundColor=the_objoBgc;
the_objstylecolor=the_objoFc;
the_objstyletextDecoration='';
}
}
function serch(){
documentgetElementById("formName")action="<%=basePath %>hgltjactionmethod=getHglpm";
documentgetElementById("formName")submit();
}
function tbbt(){
var jzrq=documentgetElementById("jzrqId")value;
//var jxmc=documentgetElementById("jxmcId")value;
windowopen('<%=basePath %>hgltjactionmethod=getHglpmTb&tjjxkshgljzrq='+jzrq+'&tjjxkshglzt='+1,'','height=650,width=1250,top=150,left=200,toobar=no,menubar=no,scrollbars=yes,resizable=no,location=no,');
}
function openwd(){
documentgetElementById("formName")action="<%=basePath %>hgltjactionmethod=downJxhglPm";
documentgetElementById("formName")submit();
}
</script>
</head>
<BODY onLoad="load()" style="background: url(images/cont_bggif); background-repeat: repeat-y">
<input type="hidden" name="method" value="getDriverInfoList"/>
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="maintb">
<tr>
<td align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0" id="mainbox" style="background:url(jsp/commonstyle/images/usermessage_02gif); background-repeat:repeat-x;" >
<!--宽度可变内容框-->
<tr >
<td width="33" height="27" style=" background:url(jsp/commonstyle/images/usermessage_01gif); background-position:left; background-repeat:no-repeat;" ></td>
<td width="965" class="style1"><font color="black">驾校合格率排名</font></td>
<td width="14" height="27" style=" background:url(jsp/commonstyle/images/usermessage_03gif); background-position:right; background-repeat:no-repeat;"> </td>
</tr>
<tr>
<td colspan="3">
<!--页面主体内容开始-->
<!--查询条件-->
<form action="" name="formName" method="post" style="margin:0px" id="formName" theme="simple">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;" id="tj" align="center">
<tr align="left">
<td class="tjbg1" style="text-align: left">
<!-- <input type="hidden" id="method" name="method" value="getHglpm"/> -->
统计日期:
<input type="text" name="tjjxkshgljzrq" id="jzrqId" value="<s:property value="tjjxkshgljzrq"/>" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM'})"/>
<!-- 驾校名称:
<s:select id="jxmcId" name="tjjxkshgljxxh" value="tjjxkshgljxxh" list="schoolList" listKey="jxxh" listValue="jxmc" headerKey="" headerValue="--请选择--" theme="simple"></s:select> -->
<input name="input" value=" 统 计 " type="button" class="normalbtn" onClick="serch()" style="margin-bottom: 5px" />
<input name="input" type="button" value=" 合格率图表 " onclick="tbbt()" class="normalbtn" style="margin-bottom: 5px" />
<input id="Button1" type="button" value=" 导 出 " onclick="openwd();" class="normalbtn" style="margin-bottom: 5px" />
</td>
</tr>
</table><!--查询结果-->
</form>
<!--查询结果-->
<table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#abcfff" id="cxjg" align="center">
<thead>
<tr class="tbtitle">
<td width="4%" align="center" class="t1">名次</td>
<td width="8%" align="center" class="t1">名称</td>
<td class="t1" width="5%" align="center">科目一</td>
<td class="t1" width="5%" align="center">科目二</td>
<td class="t1" width="5%" align="center">科目三</td>
<td class="t1" width="5%" align="center">平均合格率</td>
<td class="t1" width="5%" align="center"> *** 作</td>
</tr>
</thead>
<s:iterator id="jxhgl" value="jxhelpmList" status="st">
<tr class="changeColor" onMouseOver="overIt()" onMouseOut="outIt()" style="cursor: hand" align="center">
<td><s:property value="#stindex+1"/></td>
<td><s:property value="#jxhgljxmc"/></td>
<td><s:property value="#jxhglkm1hgl"/></td>
<td><s:property value="#jxhglkm2hgl"/></td>
<td><s:property value="#jxhglkm3hgl"/></td>
<td><s:property value="#jxhglavghgl"/>%</td>
<td>
<a href="javascript:" onclick="openWin('<%=basePath %>hgltjactionmethod=getTbForJxxh&tjjxkshgljxxh=<s:property value="#jxhgljxxh"/>&tjjxkshglzt=1','',1250,750);">图表</a>
</td>
</tr>
</s:iterator>
</table>
</table>
</td>
</tr>
</table>
</body>
</html>
2)java代码演示:
[java] view plaincopyprint
/
驾校合格率导出excel图表
/
//responsegetOutputStream();// 取得输出流
responsereset();// 清空输出流
String tmptitle = "驾校合格率排名"; // 标题
responsesetHeader("Content-disposition", "attachment; filename="+new String(tmptitlegetBytes(),"iso8859-1")+"xls");// 设定输出文件头
responsesetContentType("application/vndms-excel");// 定义输出类型
wbook = WorkbookcreateWorkbook(os); // 建立excel文件
WritableSheet wsheet = wbookcreateSheet(tmptitle, 0); // sheet名称
// 设置excel标题
//cellFormatsetBackground(ColourAQUA);
cellFormatsetFont(wfont);
labelsetCellFormat(cellFormat);
wsheetaddCell(label);
//wsheetaddCell(new Label(0, 0, tmptitle, wcfFC));
wsheetsetRowView(0,500); //第一行高度
wsheetmergeCells(0, 0, 6, 1); //合并单元格(第一列的第一行和第七列的第二行合并)
//wsheetmergeCells(0, 1, 9, 1);
// wsheetmergeCells(0, 2, 0, 4);
// wsheetmergeCells(1, 2, 3, 2);
// wsheetmergeCells(4, 2, 6, 2);
// wsheetmergeCells(7, 2, 9, 2);
wsheetsetColumnView(0,10); //宽度
wsheetsetColumnView(1,25); //宽度
wsheetsetColumnView(2,10); //宽度
wsheetsetColumnView(3,10); //宽度
wsheetsetColumnView(4,10); //宽度
wsheetsetColumnView(5,10); //宽度
// 开始生成主体内容
wfont = new jxlwriteWritableFont(WritableFontARIAL, 14,WritableFontBOLD,false, UnderlineStyleNO_UNDERLINE,ColourBLACK);
wcfFC = new WritableCellFormat(wfont);
wsheetaddCell(new Label(0, 2, "名次",wcfFC));
wsheetaddCell(new Label(1, 2, "驾校名称",wcfFC));
wsheetaddCell(new Label(2, 2, "科目一",wcfFC));
wsheetaddCell(new Label(3, 2, "科目二",wcfFC));
wsheetaddCell(new Label(4, 2, "科目三",wcfFC));
wsheetaddCell(new Label(5, 2, "合格率",wcfFC));
int count=jxhelpmListsize();
if(count>0){ ////判断集合是否不为0
TjJxkshgl tjhgl=null;
for(int i=0;i<jxhelpmListsize();i++){
tjhgl=(TjJxkshgl)jxhelpmListget(i);
wsheetaddCell(new Label(0, i+3, (i+1)+""));
wsheetaddCell(new Label(1, i+3, tjhglgetJxmc()));
wsheetaddCell(new Label(2, i+3, tjhglgetKm1hgl()));
wsheetaddCell(new Label(3, i+3, tjhglgetKm2hgl()));
wsheetaddCell(new Label(4, i+3, tjhglgetKm3hgl()));
wsheetaddCell(new Label(5, i+3, tjhglgetAvghgl()));
}
推荐使用querylist
<phpheader("Content-type:text/html;charset=utf-8");
require 'QueryList/QueryListclassphp';
$url = "要抓取的网站";
$reg = array(
"title" => array("a","text"),
"src" => array("a","href"),
);
//$rang = "[id^=post-]";
$hj = QueryList::Query($url,$reg);
print_r($hj->jsonArr);
前台页面只是取数据,和Struts没什么关系吧,基本的标签就可以了
<c:forEach var="item" items="queryList">
<tr>
<td>${itemid}</td>
<td>${itemusername}</td>
<td>${itemxingming}</td>
</tr>
</c:forEach>
BigDecimal表示一个大整数,一般情况下很多整型都有个最大值的,但是有时候我们需要处理一些超过这个最大值的值,这个时候就出现了BigDecimal这样的类用于表达大数值,你这个错误应该是类型转换过程中出现了问题
意思是获得初始化datagird时的option对象。
获取table这个datagrid href的参数(就是获取向后台发送的参数)。
queryParams属性作用其实url请求添加额外参数;
比:url:${ctx}/sys/useractionname=‘明’ 想再附加参数age=18;
比url:${ctx}/sys/useractionname=‘明’&age=18 url利用queryParams属性;
js写
function addParam(){
var param = {age :18};
$("#tt")datagrid("load", param);
}
重新发送新url请求初始化datagrid新数据;(我写态设置请求参数想直接datagird初始化添加参数直接初始化datagird候添加属性queryParams : {参数名:'参数值',})
扩展资料:
实例
对一个函数在±20范围内随机采样100点:
rand('seed',0)
x = rand(100,1)4-2; y = rand(100,1)4-2;
z = xexp(-x^2-y^2);
x, y, 和 z 均为包含非均匀采样数据的矢量。定义一个规范的网格,将数据与网格匹配:
ti = -2:25:2;
[XI,YI] = meshgrid(ti,ti);
ZI = griddata(x,y,z,XI,YI);
Plot the gridded data along with the nonuniform data points used to generate it: mesh(XI,YI,ZI), hold
plot3(x,y,z,'o'), hold
参考资料来源:百度百科-griddata
以上就是关于bootstrap table 导出数据为excel或其他,为什么点击了没反应全部的内容,包括:bootstrap table 导出数据为excel或其他,为什么点击了没反应、用java将数据导出到wps表格中,怎么实现、php用正则获取html标签内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)