按日按月按季度导出数据(Excel)

该博客介绍了如何使用JavaScript和JSP实现自动化导出按日、按月、按季度的数据到Excel。用户点击按钮,根据选择的时间范围,系统通过连接数据库并执行SQL查询来获取相应时间段的订单信息,然后将数据写入Excel表格中供用户下载。
摘要由CSDN通过智能技术生成

<input type="button" onClick="AutomateExcel()" value="导&nbsp;出">
<input type="button" value="按日" οnclick="ExportExcel('1');">
<input type="button" value="按月" οnclick="ExportExcel('2');">
<input type="button" value="按季度" οnclick="ExportExcel('3');">

<script language="javascript" type="text/javascript">
 var ExportExcel=function(flag)
   {
      window.location.href="ExportExcel.jsp?flag="+flag;
   }
</script>

 

处理的jsp页面:

<%
//连接数据库
Connection con = null;
Statement stm = null;
ResultSet rs2 = null;
FileInputStream fis=null;
String path= new java.io.File(application.getRealPath("config")).getParent()+"\\";
      fis = new FileInputStream(new File(path+"config.properties"));
      Properties prop = new Properties(); 
      prop.load(fis);
      String driverName=prop.getProperty("driverName");
   String url=prop.getProperty("url");
   String user = prop.getProperty("user");
      String pasword = prop.getProperty("pasword");
     
       Class.forName(driverName).newInstance();
       con =  DriverManager.getConnection(url, user, pasword);
       stm = con.createStatement();
   

 

//日期
        int eyear,emonth,eday;   
  Calendar cal=Calendar.getInstance();   
  eyear=cal.get(Calendar.YEAR);   
  emonth=cal.get(Calendar.MONTH);   
  eday=cal.get(Calendar.DATE);   
  
  
       int flag=

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值