「java点击导出」java程序导出
本篇文章给大家谈谈java点击导出,以及java程序导出对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、java用什么方法能在点击“导出”按钮时弹出自定义文件名的弹窗,样式是电脑本身自带的,没看明白的如下图
- 2、用java将数据导出到wps表格中,怎么实现
- 3、Java 大数据量导出,该怎么解决
- 4、求解答JAVA点击导出项目无反应问题
- 5、java项目怎样导出
- 6、Java怎么导出dpb数据包
java用什么方法能在点击“导出”按钮时弹出自定义文件名的弹窗,样式是电脑本身自带的,没看明白的如下图
import javax.swing.*;
import javax.swing.filechooser.*;
import java.awt.*;
import java.awt.event.*;
final class FileChooserDemo extends JFrame {
final static private Dimension SIZE = new Dimension(200, 100);
public String getTitle() {return "FileChooserDemo";}
public Dimension getPreferredSize() {return SIZE;}
public Dimension getMinimumSize() {return SIZE;}
public Dimension getMaximumSize() {return SIZE;}
public Dimension getSize() {return SIZE;}
private JButton saveButton;
FileChooserDemo() throws HeadlessException {
init();
attachListeners();
doLay();
setVisible(true);
}
private void init() {
saveButton=new JButton(new ChooseAction());
}
private void attachListeners() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(1);
}
});
}
private void doLay() {
getContentPane().add(saveButton,BorderLayout.NORTH);
pack();
}
private class ChooseAction extends AbstractAction{
private JFileChooser fileChooser;
public ChooseAction() {
super("Export...");
}
public void actionPerformed(ActionEvent e) {
init();
if(JFileChooser.APPROVE_OPTION==fileChooser.showSaveDialog(null)){
System.err.println(fileChooser.getSelectedFile());
}
}
private void init(){
if (fileChooser==null) {
fileChooser=new JFileChooser(".");
FileFilter xmlFilter = new FileNameExtensionFilter("xml file(*.xml)","xml");
FileFilter txtFilter = new FileNameExtensionFilter("text file(*.txt)","txt");
FileFilter pngFilter = new FileNameExtensionFilter("PNG file(*.png)","png");
fileChooser.addChoosableFileFilter(xmlFilter);
fileChooser.addChoosableFileFilter(txtFilter);
fileChooser.addChoosableFileFilter(pngFilter);
fileChooser.setFileFilter(txtFilter);
}
}
}
public static void main(String... args) {
System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.invokeLater(FileChooserDemo::new);
}
}
用java将数据导出到wps表格中,怎么实现
一:页面图片显示预览:
1)如下图:
2)点击导出按钮后预览:
3)最终生成的excel表格图片预览:
二:代码演示:
说明:执行操作时,请先引进导出excel表格的jar文件包。
找到导出按钮所执行的js方法,在java后天查看该方法的实现即可。
1)jsp代码:
[html] view plaincopyprint?
%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%
%@taglib prefix="s" uri="/struts-tags" %
%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%
html
head
base href="%=basePath%"
title驾校合格率排名/title
link href="jsp/commonstyle/css/tabStyle.css" rel="stylesheet" type="text/css"
link rel="STYLESHEET" type="text/css" href="%=basePath%jsp/hgltj/js/tablesort.css"
script type="text/javascript" src="%=basePath%jsp/system/common/js/publicColor.js"/script
script type="text/javascript" src="jsp/commonstyle/js/js/My97DatePicker/WdatePicker.js" defer="defer"/script
script type="text/javascript" src="%=basePath%jsp/hgltj/js/tablesort.js"/script
script language="JavaScript"
function load()
{
//根据分辨率设置表格大小
maxw=document.getElementById("maintb").offsetWidth;
if(maxw824){//1024分辨率未展开
mainbox.width="98%";
} else if(maxw1013){//1024分辨率展开
mainbox.width="98%";
} else if(maxw1081){//1280分辨率未展开
mainbox.width="95%";
} else if(maxw1270){//1280分辨未展开
mainbox.width="95%";
}else{//1280以上分辨展开
mainbox.width="98%";
}
}
/script
script
function overIt(){
var the_obj = event.srcElement;
if(the_obj.tagName.toLowerCase() == "td"){
the_obj=the_obj.parentElement;
the_obj.oBgc=the_obj.currentStyle.backgroundColor;
the_obj.oFc=the_obj.currentStyle.color;
the_obj.style.backgroundColor='#4073C4';
the_obj.style.color='#ffffff';
the_obj.style.textDecoration='underline';
}
}
function outIt(){
var the_obj = event.srcElement;
if(the_obj.tagName.toLowerCase() == "td"){
the_obj=the_obj.parentElement;
the_obj.style.backgroundColor=the_obj.oBgc;
the_obj.style.color=the_obj.oFc;
the_obj.style.textDecoration='';
}
}
function serch(){
document.getElementById("formName").action="%=basePath %hgltj.action?method=getHglpm";
document.getElementById("formName").submit();
}
function tbbt(){
var jzrq=document.getElementById("jzrqId").value;
//var jxmc=document.getElementById("jxmcId").value;
window.open('%=basePath %hgltj.action?method=getHglpmTbtjjxkshgl.jzrq='+jzrq+'tjjxkshgl.zt='+1,'','height=650,width=1250,top=150,left=200,toobar=no,menubar=no,scrollbars=yes,resizable=no,location=no,');
}
function openwd(){
document.getElementById("formName").action="%=basePath %hgltj.action?method=downJxhglPm";
document.getElementById("formName").submit();
}
/script
/head
BODY onLoad="load()" style="background: url(images/cont_bg.gif); 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_02.gif); background-repeat:repeat-x;"
!--宽度可变内容框--
tr
td width="33" height="27" style=" background:url(jsp/commonstyle/images/usermessage_01.gif); 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_03.gif); 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="tjjxkshgl.jzrq" id="jzrqId" value="s:property value="tjjxkshgl.jzrq"/" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM'})"/
!-- 驾校名称:
s:select id="jxmcId" name="tjjxkshgl.jxxh" value="tjjxkshgl.jxxh" 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"
tds:property value="#st.index+1"//td
tds:property value="#jxhgl.jxmc"//td
tds:property value="#jxhgl.km1hgl"//td
tds:property value="#jxhgl.km2hgl"//td
tds:property value="#jxhgl.km3hgl"//td
tds:property value="#jxhgl.avghgl"/%/td
td
a href="javascript:" onclick="openWin('%=basePath %hgltj.action?method=getTbForJxxhtjjxkshgl.jxxh=s:property value="#jxhgl.jxxh"/tjjxkshgl.zt=1','',1250,750);"图表/a
/td
/tr
/s:iterator
/table
/table
/td
/tr
/table
/body
/html
2)java代码演示:
[java] view plaincopyprint?
/**
* 驾校合格率导出excel图表
*/
//response.getOutputStream();// 取得输出流
response.reset();// 清空输出流
String tmptitle = "驾校合格率排名"; // 标题
response.setHeader("Content-disposition", "attachment; filename="+new String(tmptitle.getBytes(),"iso8859-1")+".xls");// 设定输出文件头
response.setContentType("application/vnd.ms-excel");// 定义输出类型
wbook = Workbook.createWorkbook(os); // 建立excel文件
WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
// 设置excel标题
//cellFormat.setBackground(Colour.AQUA);
cellFormat.setFont(wfont);
label.setCellFormat(cellFormat);
wsheet.addCell(label);
//wsheet.addCell(new Label(0, 0, tmptitle, wcfFC));
wsheet.setRowView(0,500); //第一行高度
wsheet.mergeCells(0, 0, 6, 1); //合并单元格(第一列的第一行和第七列的第二行合并)
//wsheet.mergeCells(0, 1, 9, 1);
// wsheet.mergeCells(0, 2, 0, 4);
// wsheet.mergeCells(1, 2, 3, 2);
// wsheet.mergeCells(4, 2, 6, 2);
// wsheet.mergeCells(7, 2, 9, 2);
wsheet.setColumnView(0,10); //宽度
wsheet.setColumnView(1,25); //宽度
wsheet.setColumnView(2,10); //宽度
wsheet.setColumnView(3,10); //宽度
wsheet.setColumnView(4,10); //宽度
wsheet.setColumnView(5,10); //宽度
// 开始生成主体内容
wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wsheet.addCell(new Label(0, 2, "名次",wcfFC));
wsheet.addCell(new Label(1, 2, "驾校名称",wcfFC));
wsheet.addCell(new Label(2, 2, "科目一",wcfFC));
wsheet.addCell(new Label(3, 2, "科目二",wcfFC));
wsheet.addCell(new Label(4, 2, "科目三",wcfFC));
wsheet.addCell(new Label(5, 2, "合格率",wcfFC));
int count=jxhelpmList.size();
if(count0){ ////判断集合是否不为0
TjJxkshgl tjhgl=null;
for(int i=0;ijxhelpmList.size();i++){
tjhgl=(TjJxkshgl)jxhelpmList.get(i);
wsheet.addCell(new Label(0, i+3, (i+1)+""));
wsheet.addCell(new Label(1, i+3, tjhgl.getJxmc()));
wsheet.addCell(new Label(2, i+3, tjhgl.getKm1hgl()));
wsheet.addCell(new Label(3, i+3, tjhgl.getKm2hgl()));
wsheet.addCell(new Label(4, i+3, tjhgl.getKm3hgl()));
wsheet.addCell(new Label(5, i+3, tjhgl.getAvghgl()));
}
Java 大数据量导出,该怎么解决
对于数据规模太大的,做成任务。
用户点击导出,检查他的数据规模,超过50W的,提示其数据规模过大,可能需要 N 小时完成,请稍候再来查询和下载导出结果。如果用户点击确定,你就提示:“任务已进入队列,点击此连接查询导出进度。”
然后你要做两件事情:
1、给这个用户记录个标识,就是他已经启动某导出任务,不能再启动新的了(或者限制一个人最多同时启动几个导出任务);
2、后台有个调度程序,开始执行导出工作,并将生成的Excel放在某磁盘目录或存在数据库中;这个调度任务可以控制下最大同时并发的导出任务数,以避免任务太多拖垮系统。
另外需要开发界面查询导出进度以及下载导出结果。导出结果可以考虑一个最大保存周期,比如7天。
求解答JAVA点击导出项目无反应问题
编写。bat文件运行导出的项目。? 这句话什么意思。 缺少外部的包,就在项目右键buildPath-Configration 那一项里面,add externJar 添加进去 自己建立的lib文件夹放外部jar文件的话,同上 打开那一项后,点击 在项目内导入(英文忘了咋说了),选择项目打开lib文件夹,选住就行了,这样外部包就是相对路径的了
java项目怎样导出
第一步:选中项目;
第二步:右击鼠标,选中“export”,之后选择需要的导出类型;
第三步:选择“Browse”,选择导出路径;
第四步:选择“Finsh”即可完成导出。
备注:第二步中的导出类型根据实际需要选择即可,如war(web项目,部署到tomcat等容器运行,)、runnable jar(可运行jar包),JarFile(作为单独的jar包,之后放到需要的项目的lib下)等,这个根据实际需要选择即可。
Java怎么导出dpb数据包
在使用的数据包的功能中,进行点击wireshark的菜单中的“file”的菜单选项。
这样就会弹出了下拉菜单中进行选择为“export packet dissections”的选项。
选择完了export packet dissections之后,来进行选择为as “csv” (comma separated values packes)
这样就会弹出了一个保存到电脑中的路径的,进行再输入框中的文件名csv
这样在导出到电脑中的界面中的,为csv的文件中,
在这个的打开了csv的文件中之后,导出的数据保存到了csv中。
关于java点击导出和java程序导出的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
发布于:2022-11-30,除非注明,否则均为
原创文章,转载请注明出处。