- 浏览: 31023 次
- 性别:
- 来自: 沈阳
最新评论
package com.action.frame;
import java.awt.Container;
import java.awt.Font;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import com.action.ExcelUnit.XxlsServices;
import com.action.service.PCBExportService;
import com.action.service.PCBRule;
import com.action.service.PCBRuleService;
public class PCB extends JFrame implements ActionListener {
private static final long serialVersionUID = -4026600690895973169L;
private JButton bottom;
private JButton bottom1;
private JButton bottom2;
private JButton bottom3;
private JPanel contentPane;
private Label label;
private JScrollPane scrollMypane;
public static void main(String[] args) {
PCB example = new PCB();
example.setTitle("PCB");
example.setBounds(250, 100, 900,600);
example.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
example.setVisible(true);
}
/**
* 默认构造器
*/
public PCB() {
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
bottom = new JButton("导入到数据库");
bottom1 = new JButton("导出到Excel");
bottom2 = new JButton("关 闭");
bottom3 = new JButton("计算");
contentPane.add(bottom);
contentPane.add(bottom1);
contentPane.add(bottom2);
contentPane.add(bottom3);
bottom.setBounds(100, 143, 200, 40);
bottom1.setBounds(540, 143, 200, 40);
bottom2.setBounds(360, 443, 100, 40);
bottom3.setBounds(320, 143, 200, 40);
bottom.addActionListener(this);
bottom1.addActionListener(this);
bottom2.addActionListener(this);
bottom3.addActionListener(this);
font();
}
public void font() {
Container container = getContentPane();
container.setLayout(null);
label = new Label("数据导入中...", Label.CENTER);
label.setFont(new Font("Serif",Font.PLAIN,24));
scrollMypane = new JScrollPane(label);
scrollMypane.setBounds(new Rectangle(260, 270, 370, 100));
container.add(scrollMypane);
label.setVisible(false);
}
/**
* 监听事件
*/
public void actionPerformed(ActionEvent e) {
//导入到数据库
if (e.getSource() == bottom) {
readExcelToDatabase();
}
//导出
if (e.getSource() == bottom1) {
String path = null;
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("请选择导出的目录...");
fc.setApproveButtonText("确定");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(this)) {
label.setVisible(true);
label.setText("数据导出中");
path = fc.getSelectedFile().getPath();
new PCBExportService().dealExportCore(path);
label.setText("导出完毕");
}
}
if (e.getSource() == bottom2) {
System.exit(0);
}
//计算
if (e.getSource() == bottom3) {
label.setVisible(true);
label.setText("数据计算中");
new PCBRuleService().dealPCBRuleCore();
try {
PCBRule p = new PCBRule();
p.replaceRule();
p.cabinetSum();
} catch (SQLException ex) {
ex.printStackTrace();
}
label.setText("数据计算完毕");
}
}
/**
* 写数据到数据库
*/
public void readExcelToDatabase() {
//
String path = null;
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("请选择要上传的文件...");
fc.setApproveButtonText("确定");
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(this)) {
path = fc.getSelectedFile().getPath();
// 导入(计算时间);
label.setVisible(true);
System.out.println("数据导入中...");
try {
XxlsServices howto = new XxlsServices();
howto.process(path);
howto.close();
} catch (Exception e) {
label.setText("数据导入出错");
e.printStackTrace();
}
label.setText("导入完毕");
}
}
}
import java.awt.Container;
import java.awt.Font;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import com.action.ExcelUnit.XxlsServices;
import com.action.service.PCBExportService;
import com.action.service.PCBRule;
import com.action.service.PCBRuleService;
public class PCB extends JFrame implements ActionListener {
private static final long serialVersionUID = -4026600690895973169L;
private JButton bottom;
private JButton bottom1;
private JButton bottom2;
private JButton bottom3;
private JPanel contentPane;
private Label label;
private JScrollPane scrollMypane;
public static void main(String[] args) {
PCB example = new PCB();
example.setTitle("PCB");
example.setBounds(250, 100, 900,600);
example.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
example.setVisible(true);
}
/**
* 默认构造器
*/
public PCB() {
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
bottom = new JButton("导入到数据库");
bottom1 = new JButton("导出到Excel");
bottom2 = new JButton("关 闭");
bottom3 = new JButton("计算");
contentPane.add(bottom);
contentPane.add(bottom1);
contentPane.add(bottom2);
contentPane.add(bottom3);
bottom.setBounds(100, 143, 200, 40);
bottom1.setBounds(540, 143, 200, 40);
bottom2.setBounds(360, 443, 100, 40);
bottom3.setBounds(320, 143, 200, 40);
bottom.addActionListener(this);
bottom1.addActionListener(this);
bottom2.addActionListener(this);
bottom3.addActionListener(this);
font();
}
public void font() {
Container container = getContentPane();
container.setLayout(null);
label = new Label("数据导入中...", Label.CENTER);
label.setFont(new Font("Serif",Font.PLAIN,24));
scrollMypane = new JScrollPane(label);
scrollMypane.setBounds(new Rectangle(260, 270, 370, 100));
container.add(scrollMypane);
label.setVisible(false);
}
/**
* 监听事件
*/
public void actionPerformed(ActionEvent e) {
//导入到数据库
if (e.getSource() == bottom) {
readExcelToDatabase();
}
//导出
if (e.getSource() == bottom1) {
String path = null;
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("请选择导出的目录...");
fc.setApproveButtonText("确定");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(this)) {
label.setVisible(true);
label.setText("数据导出中");
path = fc.getSelectedFile().getPath();
new PCBExportService().dealExportCore(path);
label.setText("导出完毕");
}
}
if (e.getSource() == bottom2) {
System.exit(0);
}
//计算
if (e.getSource() == bottom3) {
label.setVisible(true);
label.setText("数据计算中");
new PCBRuleService().dealPCBRuleCore();
try {
PCBRule p = new PCBRule();
p.replaceRule();
p.cabinetSum();
} catch (SQLException ex) {
ex.printStackTrace();
}
label.setText("数据计算完毕");
}
}
/**
* 写数据到数据库
*/
public void readExcelToDatabase() {
//
String path = null;
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("请选择要上传的文件...");
fc.setApproveButtonText("确定");
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(this)) {
path = fc.getSelectedFile().getPath();
// 导入(计算时间);
label.setVisible(true);
System.out.println("数据导入中...");
try {
XxlsServices howto = new XxlsServices();
howto.process(path);
howto.close();
} catch (Exception e) {
label.setText("数据导入出错");
e.printStackTrace();
}
label.setText("导入完毕");
}
}
}
发表评论
-
百度地图和ztree开发电子围栏功能
2016-09-29 09:27 4673jsp <%@ page language=" ... -
Oracle11g Enterprise Manager配置失败
2014-04-29 11:20 2527Win7先安装oracle 11g时,安装检测到系统的主 IP ... -
jsp访问上级窗口元素
2014-04-29 11:22 411opener.document.getElementById( ... -
页面关闭IE触发事件方法
2013-09-30 09:56 544function window.onbeforeunload( ... -
页面右下角消息提示
2013-09-29 14:05 466<%@ page language="java ... -
oracle 日期列表
2013-09-29 12:52 475获取某个时间段之间的月份列表(示例返回2009-03到2010 ... -
倒计时
2013-09-24 10:01 314//提交 function doSubmit(){ ... -
oracle11G 最新驱动包
2013-09-24 10:00 670oracle11G 最新驱动包 解决与Spring冲突问题 ... -
获取第几天后的日期
2013-09-16 09:23 555Calendar cal = Calendar.getInst ... -
web工程下获取properties文件
2013-09-16 09:19 530String propertiesPath = getClas ... -
javamail
2013-09-16 09:15 526final SendMail sendmail = new S ... -
java根据年和周获取当前的日期时间段
2013-09-16 09:10 1240String[] dates = new String[7]; ... -
JSP判断日期间隔天数
2013-07-15 11:14 594var temp_field1 = $("#temp ... -
dtree不选中子节点处理
2013-05-17 10:35 1234//dtree.js 208行(chks[i].checked ... -
IE8下JS插入表格
2013-05-17 10:25 614//IE8下使用JS插入JSP表格 var tbl = do ... -
JSP选项卡显示
2013-05-17 10:22 1988<%@ page language="java ... -
JSP样式实例
2013-05-10 15:59 635<%@ page contentType="t ... -
Oracle表空间和用户创建赋权限
2013-05-10 15:54 631--RLDM CREATE TABLESPACE RLDM D ... -
hibernate oracle 主键递增
2013-05-10 15:47 454<?xml version="1.0" ... -
Spring配置文件,SSH, Oracl数据库
2013-05-10 15:45 698<?xml version="1.0" ...
相关推荐
自定义的一个excel文件导入导出类,支持Excel2003到2010的格式。里面也有简单的配置文件的创建。
这是一个java对xml操作的两个类,xml文件的节点都是已知的,都需要提前指定.
概述:Java poi导入导出EXCEL工具类(兼容各版本) 一、功能说明 允许同时导入或导出多个sheet,同一sheet可同时存在多个数据块,按数据块划分处理数据。 二、配置文件示例及详细说明 1、导入xml配置示例如下(见...
功能简介 execl报表导入导出 基于wab开发 功能简介 execl报表导入导出 基于wab开发 功能简介 execl报表导入导出 基于wab开发 功能简介 execl报表导入导出 基于wab开发
集合了java对excel的操作,批量导入,批量导出等,在本地亲测有效!
Excel源代码,导入导出各种工具类 <groupId>org.apache.poi <artifactId>poi <groupId>org.apache.poi <artifactId>poi-scratchpad 代码实例: String path = ""; byte[] bytes; vo.setCurrentPage(0); vo....
Java实现Excel导入导出是通过Java语言编写的程序,将数据从Excel文件中读取或写入到Excel文件中。这种方式可以实现数据的批量处理和分析,提高工作效率。 Java实现Excel导入导出的应用场景。 Java实现Excel导入导出...
java_poi实现excel导入导出功能,有详细的注解
Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出Java POI EXCEL导入导出...
javaCSV导入导出 ... File file = new File("C:/name.csv"); FileOutputStream out = new FileOutputStream(file); OutputStreamWriter osw = new OutputStreamWriter(out); BufferedWriter bw = new ...
Java数据导入导出Excel Java代码
可以根据表的id导入和导出excell、xml、txt等格式
java实现excel的导入导出(poi详解),经过测试poi效率要比jxl要高很多,特别是数据量大的时候jxl根本无法用肉眼入目,本资源是个可运行项目demo,很有参考价值!
本人工作中自己写的一个excel工具类,可以单独打包成jar,作为公共模块使用。 使用它可以直接不用关心poi的api。导入导出,轻轻松松。 使用方法请关注一下,cn.com.flaginfo.biz.excel.test 包下面的Test类。
java中导入导出Excel文件
java 导入导出excel、xml文件解析工具,减少工作量。
csv的文件的导入导出可能会用的到,需要的可以下一下把
java Excel导入导出
此代码为java运用poi3.8插件实现运用模版导入导出复杂excel