net.sf.jasperreports.engine.export.JRCsvExporter exporter = new JRCsvExporter();
JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, dataSource);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path);
exporter.exportReport();
82 ireport 导出 Pdf
方法一:
JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, dataSource);
return JasperExportManager.exportReportToPdf(jasperPrint);
方法二:
net.sf.jasperreports.engine.export.JRPdfExporter exporter = new JRPdfExporter();
JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, dataSource);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path);
exporter.exportReport();
83 ireport 导出多种格式
1) 参考网址 月之骑士博客【利用Ireport和JasperReport实现导出RTF文件 转载】
本文出自优快云博客,http://blog.youkuaiyun.com/rachael1001/archive/2007/03/02/1519492.aspx
2) ireport导出excel,html,pdf等格式完整实例 优快云博客 zhuaikunkun
3) ireport导出工具类
4) ireport导出各种格式(pdf,excel,word,html,print)
84 省市级联
选择省,调用后台Ajax,产生市
<td class="blove3" id="province"> 户籍省<span class="red">*</span></td>
<td class="blove">
<html:select styleId="householdProvinceCode" property="householdProvinceCode"
οnchange='sel(this.value);' style="width:130px;height:22px">
<option value=""></option>
<c:if test="${not empty householdList }">
<c:forEach items="${householdList}" var="household">
<html:option value="${household.code}">${household.name}</html:option>
</c:forEach>
</c:if>
</html:select>
</td>
<td class="blove3" id="city"> 户籍市<span class="red">*</span></td>
<td id="selHouseholdCity" class="blove">
<select name="householdCityCode" id="householdCityCode" style="width:130px;height:22px">
<option value=""> </option>
</select>
</td>
// 获取所在市
function sel(householdId){
if(householdId.length==0)
{
$("#householdCityCode").html("<option value=''> </option>");
return;
}
var url = "<%=path%>/appbatch/getHouseholdCity.do";
var ajaxRequest = new AjaxRequest(url);
ajaxRequest.appendValue('transID','appsingle-01-01');
ajaxRequest.appendValue('householdId',householdId);
var result = ajaxRequest.postAjax();
if(result!=null && result.returnResult =="success")
{
if(result.returnData != null)
{
var options = "<option value=''> </option>";
var ops = result.returnData;
for(var i in ops){
options += "<option value='"+ ops[i].code +"'>" + ops[i].name + "</option>";
}
$("#householdCityCode").html(options);
$("#householdCityCode").focus();
}
else
{
return null;
}
}
else
{
alert(" 获取服务器信息时出错! ");
return null;
}
}
/**
* 获取所在市
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public List<SysInfoBean> getHouseholdCityAjax(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception
85 行转列【动态SQL】 只要传个8月日期就生成8个月的,传4月日期就生产4个月的
方法一:
SELECT SEQ_NO
, sum(case when substr(data_date,1,6) = '201501'
then AMOUNT
else 0
end) as "1月"
, sum(case when substr(data_date,1,6) = '201502'
then AMOUNT
else 0
end) as "2月"
, sum(case when substr(data_date,1,6) = '201503'
then AMOUNT
else 0
end) as "3月"
, sum(case when substr(data_date,1,6) = '201504'
then AMOUNT
else 0
end) as "4月"
from test_2015723
group by SEQ_NO
方法二:
select *
from (
select SEQ_NO,AMOUNT,SUBSTR(DATA_DATE,1,6) AS MONT from test_2015723 )
pivot (sum(amount)for MONT IN ('201501','201502'))
-- pivot 要求oracle11g
SELECT t.*,ROWID FROM temp_1 t ;
select t.name,"'1'" as type1_amt,"'2'" as type2_amt from (
select * from temp_1
pivot(
sum(amt)
for seqno
IN('1', '2')
)) t
86 like 语句
select * from temp t.id like '%aa%'
等价于
select * from temp '%aa%' like t.id
87 mysql字符串连接
88 ireport 增加行栏位显示
1)<rowGroup name="bocFeeRate" width="70">
<bucket>
<bucketExpression class="java.lang.String"><![CDATA[$F{bocFeeRate}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$V{bocFeeRate}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents/>
</crosstabTotalRowHeader>
</rowGroup>
2) <cellContents backcolor="#005FB3" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25" forecolor="#FFFFFF"/>
<textElement/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{totalAmountMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="25" rowTotalGroup="bocFeeRate">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
<textElement/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{totalAmountMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell rowTotalGroup="bocFeeRate" columnTotalGroup="timeArea">
89 oracle 返回结果集
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐编写1 直接使用SQL
CREATE OR REPLACE FUNCTION f_TestReturnTableSet1(p_grp varchar2 default NULL)
RETURN SYS_REFCURSOR is
type_cur SYS_REFCURSOR;
BEGIN
OPEN type_cur FOR
select grp, value from test_def_fun;
RETURN type_cur;
END;
declare
v_rows SYS_REFCURSOR;
v_row test_def_fun%rowType;
begin
v_rows:=f_testreturntableset1();
loop
fetch v_rows into v_row;
exit when v_rows%NOTFOUND;
Dbms_output.put_line(v_row.GRP||' '||v_row.VALUE);
end loop;
close v_rows;
end;
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐读取:不能直接使用SELECT读取,需要从游标中获取数值
2、返回Table类型的结果集
a、定义行类型
b、按照a定义的行类型定义表类型
c、在函数/存储过程中使用b定义的类型,并返回
d、可通过select * from table (...) 读取
example :
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐代码编写
create or replace type TestofTableRow as object
(
grp varchar2(1),
value number
);
create or replace type TestofTableSet as table of TestofTableRow;
create or replace function f_testreturntableset2(p_grp varchar2 default null)
return TestofTableSet as
v_table TestofTableSet := TestofTableSet();
v_str_sql varchar(2000):='';
begin
v_str_sql :='select TestofTableRow(grp, value) from test_def_fun where 1=1 ';
if p_grp is not null then
v_str_sql := v_str_sql|| ' and grp ='''||p_grp||'''';
end if;
dbms_output.put_line(v_str_sql);
execute immediate v_str_sql bulk collect into v_table;
return v_table;
end;
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 数据读取‐
select * from table(f_testreturntableset2());
90 js 获取当前时间
var time = new Date();
var nowDate = time.getYear()+"-"
+((time.getMonth()+1) > 9 ? (time.getMonth()+1) : "0"+(time.getMonth()+1))+"-"
+(time.getDate()<= 9 ? "0"+time.getDate() : time.getDate());
var today = new Date;
var todayStr = today.getYear()+"-"+(today.getMonth()+1) +"-"+today.getDate();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowDate = sdf.format(date);
var date = new Date();
var today = date.getFullYear()+'-'+appendZero(date.getMonth()+1)+'-'+appendZero(date.getDate());
var today = new Date();
var year = today.getFullYear() - 16;
var month = today.getMonth()+1;
var day = today.getDate();
var temp = year + "-"+month+"-"+day;
91 Ctrl+t 查看那个类实现了该接口
92 平台里面有反射的工具类 MethodUtils.invokeMethod
93 FOR UPDATE NOWAIT 锁表
SELECT * FROM tableName WHERE 1<>1 FOR UPDATE NOWAIT
94 上送的报文都不会带小数点,组报文的时候2位小数的就放大100倍。
另外s是符号位。打个比方
9(14)V99 : 100.25 -> 0000000000010025
9(14)V999S : 100.25 -> 00000000000100250+
9(8)V9(6)S 这个是8位整数6位小数加符号位,所以组报文时是15位。
95 反射 获取某一对象的get方法的返回值
public static Object executeMehtod(Object obj, String executeMethod)
throws Exception {
Class tmp = obj.getClass();
Method methods[] = tmp.getMethods();
Object tobj = null;
for (int i = 0; i < methods.length; i++) {
String methodName = methods[i].getName();
if (methodName.indexOf("get") == 0) {
if (methodName.substring(3, methodName.length())
.equalsIgnoreCase(executeMethod)) {
tobj = methods[i].invoke(obj, null);
break;
}
}
}
return tobj;
}
96 js 返回由字符串转换得到的整数
parseInt
97 怎么停掉线程池
98 页面栏位内容过长处理
方法一:【tips 属性 提示】 <td align="left" class="blove3" style="background: #f8fdff;" tips="深圳市罗湖区城市管理局本级">
tip.js
/**
* 功能说明:相对原生的title,样式较为丰富的tips提示。可显示任何HTML内容。<br>
* 使用方法:1、首先将该js文件包含至页面中;<br>
* 2、在原来使用title属性的地方,使用tips属性相应替换即可,如:
* <span tips="提示内容<br><b>粗体内容</b>"></span>
* wengyy 2008-12-30
*/
if(!document.attachEvent)
{
document.attachEvent = function(){document.addEventListener(arguments[0].substr(2),arguments[1],arguments[2])}
}
/**
*捕获onmouseover事件,负责显示TIPS
*/
document.attachEvent("onmouseover",function(e)
{
var tip = "";
var parentElement = null;
if(window.event)
{
e = window.event;
parentElement = e.srcElement;
}
else
{
parentElement = e.target;
}
if(parentElement)
{
tip = parentElement.getAttribute("tips");
}
if(tip != null && typeof(tip) != "undefined" && tip.length>0)
{
var _tips = document.getElementById("globalCustomizeTipDiv");
if(_tips)
{
document.body.removeChild(_tips);
}
//if(typeof(_tips)=="undefined"||_tips == null)
//{
_tips = document.createElement("div");
document.body.appendChild(_tips);
//_tips.style.display = "none";
_tips.id = "globalCustomizeTipDiv";
_tips.style.position = "absolute";
_tips.style.zIndex = 999;
//_tips.style.width = "180px";
_tips.style.borderWidth = "1px";
_tips.style.borderStyle = "solid";
_tips.style.borderColor = "gray";
_tips.style.fontSize = "9pt";
_tips.style.background = "#ffffff";
_tips.style.color = "#2B85C4";
_tips.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3)";
_tips.style.padding = "5px 8px 3px 8px";
//}
//_tips.innerHTML = '<img border="0" src="/itsm/images/theme/green/icon/bulb.gif">【提示】 ' + tip;
_tips.innerHTML = tip;
//var _left = document.body.scrollLeft + e.clientX + 10;
var _left = e.clientX + 10;
_left = (_left > document.body.clientWidth - _tips.clientWidth) ? (_left - _tips.clientWidth) : _left;
_left = _left < 0 ? 30 : _left;
_tips.style.left = _left;
//var _top = document.body.scrollTop+e.clientY+10;
var _top = e.clientY + 10;
_top = (_top > document.body.clientHeight - _tips.clientHeight) ? (_top - _tips.clientHeight) : _top;
_top = _top < 0 ? 80 : _top;
_tips.style.top = _top;
//显示TIPS
_tips.style.display = "";
//如果同时手动指定了TIPS的最大宽度,则满足条件时启动该宽度
var tipsMaxWidth = parentElement.tipsMaxWidth;
if(_tips.offsetWidth > tipsMaxWidth)
{
_tips.style.width = tipsMaxWidth + 'px';
}
var tipsMaxHeight = parentElement.tipsMaxHeight;
//如果同时手动指定了TIPS的最大高度,则满足条件时启动该高度
if(_tips.offsetHeight > tipsMaxHeight)
{
_tips.style.height = tipsMaxHeight + 'px';
}
}
});
/**
*捕获onmouseout事件,负责TIPS清理工作
*/
document.attachEvent('onmouseout',function(e)
{
var _tips = document.getElementById("globalCustomizeTipDiv");
if(_tips)
{
//_tips.innerHTML = '';
//_tips.style.display="none";
document.body.removeChild(_tips);
}
});
方法二:点击弹出DIV
<input width="30" height="22"
style="border-bottom: 0px; border-left: 0px; border-top: 0px; cursor: default; border-right: 0px;"
οnmοuseοut="closeDiv();" οnclick="showDive('Event.MOUSEMOVE',this);"
type="text" readOnly="readonly" value="特急!注册e线通企业注册信息推送项目"/>
<script type="text/javascript">
var kong = /^\s*$/;
function showDive(evnt,input) { ypos = (document.layers)?evnt.pageY:event.y; xpos = (document.layers)?evnt.pageX:event.x; document.getElementById
('showDiv').style.display=""; document.getElementById('showDiv').style.left=xpos+"px"; document.getElementById('showDiv').style.top=ypos+"px";
document.getElementById('showText').innerText=input.value; }
function closeDiv(){ document.getElementById('showDiv').style.display="none"; }
</script>
<div id="showDiv" style="z-index: 1000; border-bottom: #edeef0 2px solid; position: absolute; border-left: #edeef0 2px solid; padding-bottom: 20px;
background-color: #ffffff; padding-left: 20px; padding-right: 20px; border-top: #edeef0 2px solid; top: 425px; border-right: #edeef0 2px solid; padding-top: 20px;
left: 221px;">
<span id="showText">
99 html 页面加虚线
方法一:<div style="border-bottom: 1px dashed #000000;"></div>
方法二:<hr style="border-bottom: 1px dashed #000000;"/>
100 html 之间的参数传递
方法1:
/**
* htmla 参数传递测试
*/
//进入明细
function goDetail(){
var data = {
name:'参数1',
value:'1',
sex:'男'
};
location.href='qzyjfqdetail1.html' + params(data);
}
var params = function(args){
var p =[];
for(var n in args){
p.push( n + '=' + args[n]);
}
return encodeURI('?' + p.join('&'));
}
/**
* htmlB 参数传递测试
*/
var args = function(params){
var a = {};
params = params || location.search;
if(!params){
return{};
}
params = decodeURI(params);
params.replace(/(?:^\?|&)([^=&]+)(?:\=)([^=&]+)(?=&|$)/g, function(m,k,v){a[k] = v; });
return a;
}
window.onload = function(){
var argsfrompageA = args();
}