- 浏览: 768772 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (386)
- Linux (36)
- Tomcat (6)
- windows (8)
- Apache (10)
- Java (25)
- jquery (7)
- Jquery 插件 (3)
- Oracle (5)
- Oracle SQL (68)
- Spring (15)
- 开发工具 (6)
- Struts (20)
- js (14)
- Project Code (2)
- Project Code Tomcat (1)
- libset (1)
- JSP (8)
- arithmetic (2)
- 浏览器 (1)
- extjs (3)
- 学习网站 (5)
- 生活情感 (0)
- 电话号码算法 (3)
- 快捷键 (1)
- 转载 (1)
- Dos命令 (2)
- services (1)
- Resources (1)
- 行业积累 (3)
- 项目积累 (3)
- Web (3)
- 文档 (1)
- JavaEE (2)
- JSF (3)
- http (3)
- JS窗口 (1)
- Html (4)
- Flex (1)
- 资讯 (2)
- 项目规范 (1)
- Struts s:property textarea中默认值用 (1)
- Quartz 2.0.2 (12)
- 1天有多少毫秒 (1)
- 专题 (1)
- intellij idea 10 CD-KEY (1)
- restlet (4)
- Mail (1)
- Excel (3)
- Menu (1)
- Big Data技术综述 (1)
- Quart 1 (1)
- nosql (1)
- linux远程 (1)
- jdk (5)
- wind7 (1)
- 虚拟人 (0)
- 虚拟机 (1)
- 终端 (1)
- Ubuntu (16)
- Myeclipse (2)
- Wmware (1)
- eclipse (2)
- css (2)
- csv (1)
- 开源 (1)
- plsql (2)
- cassandra (4)
- maven (1)
- hadoop (2)
- mysql (1)
- spring security (1)
- tools (1)
- jdbc (2)
- exception (2)
- 硬盘数据备份 (1)
- dwr (1)
- svn (1)
- PowerDesigner15使用时的十五个问题 (1)
- tomcat 项目发部路径 (1)
- js 暂停执行 (1)
- jquery jqgrid 格式化数据显示 (1)
- js 代码模板 (1)
- strutss2 直接跳转到jsp页面 (1)
- servlet (1)
- jdbc spring (1)
- js学习网站 (1)
- 自学考试 (2)
- hibernate (2)
- eos (1)
- c (4)
- 黑马 (2)
- 大数据 (2)
- 实战云大数据案例分享 (0)
- Spark (2)
- Flink (1)
最新评论
-
coosummer:
推荐使用http://buttoncssgenerator.c ...
jquery button 漂亮 -
thinktothings:
Array_06 写道你好,我是一名刚毕业学生,我以后就是做J ...
如何转型架构师 -
thinktothings:
软考,考有职业资格证,有系统的知识体系学习
如何转型架构师 -
Array_06:
你好,我是一名刚毕业学生,我以后就是做Java的架构师,那请问 ...
如何转型架构师 -
beykery:
你这也太复杂了。。。。jsf2不应该是这样的。。。。
JSF2.0的一个简单Demo
package com.tht.common.xls;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.List;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.write.DateTime;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.NumberFormat;
import jxl.write.NumberFormats;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import com.tht.common.date.util.ThtCalendar;
import com.tht.common.db.base.BaseDao;
import com.tht.sendmaill.weak.dao.SBCCDRDAO;
import com.tht.sendmaill.weak.vo.DayOfWeekVO;
import com.tht.sendmaill.weak.vo.SBCCDRVO;
public class WeekXLS extends BaseDao<WeekXLS>{
private static int final_columnNum=0;
private static int total_columnNum=0;
private static int final_titleRow=5;
public Integer addColumn(Integer columnValue,int difference){
columnValue=columnValue+difference;
System.out.println(columnValue);
return columnValue;
}
/**
*
* @param filePath 生成xls的文件路径
* @param sqlQuality 是小时,还是一天的 Hour(小时) Day(天)
* @param sqlPath 执行sql 的路径
* @param strTitle xls文件中的表格标题
* @throws Exception
*/
public boolean writeXLS(String filePath,String sqlQuality,String sqlPath,String strTitle,String strBigTitle,String trunkSmallTitle,String vc2groupinfo,int final_titleRow_) throws Exception{
jxl.format.Colour excelColour=Colour.GREY_25_PERCENT;
WritableWorkbook workbook=null;
WritableSheet sheet=null;
if("1".equals(sqlQuality)){
final_columnNum=0;
final_titleRow=final_titleRow_;
workbook = Workbook.createWorkbook(new File(filePath));
sheet =workbook.createSheet(new ThtCalendar().getSimpleDate(), 0);
}else{
final_columnNum=0;
final_titleRow=final_titleRow_;
Workbook wb=Workbook.getWorkbook(new File(filePath));
workbook = Workbook.createWorkbook(new File(filePath),wb);
sheet=workbook.getSheet(0);
}
//标题 columnNum 行列号 titleRow标题行
//初使值
int columnNum=final_columnNum,titleRow=final_titleRow;//第5行开始
sheet.setColumnView(columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
sheet.setColumnView(++columnNum, 25);//第一列的宽度
//格式
//标题格式 start
WritableFont arial18ptBoldItalicUnderline = new WritableFont
(WritableFont.ARIAL,
9,
WritableFont.BOLD,
false,
UnderlineStyle.NO_UNDERLINE);
WritableCellFormat greyBackground = new WritableCellFormat(arial18ptBoldItalicUnderline);
WritableCellFormat noBackground = new WritableCellFormat(arial18ptBoldItalicUnderline);
noBackground.setWrap(false);
// noBackground.setBackground(Colour.GRAY_50);
//noBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
noBackground.setAlignment(Alignment.CENTRE);
WritableCellFormat noRightBackground = new WritableCellFormat(arial18ptBoldItalicUnderline);
noRightBackground.setWrap(false);
// noBackground.setBackground(Colour.GRAY_50);
noRightBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
noRightBackground.setAlignment(Alignment.RIGHT);
greyBackground.setWrap(false);
greyBackground.setBackground(excelColour);
greyBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
greyBackground.setAlignment(Alignment.CENTRE);
//大标题样式
WritableFont bigTitleFont = new WritableFont
(WritableFont.ARIAL,
12,
WritableFont.BOLD,
false,
UnderlineStyle.NO_UNDERLINE);
WritableFont smallBackground = new WritableFont
(WritableFont.ARIAL,
9,
WritableFont.BOLD,
false,
UnderlineStyle.NO_UNDERLINE);
WritableCellFormat bigGreyBackground = new WritableCellFormat(bigTitleFont);
bigGreyBackground.setWrap(false);
bigGreyBackground.setBackground(excelColour);
bigGreyBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
bigGreyBackground.setAlignment(Alignment.CENTRE);
WritableCellFormat smallTitleBackground = new WritableCellFormat(smallBackground);
smallTitleBackground.setWrap(false);
smallTitleBackground.setBackground(excelColour);
smallTitleBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
smallTitleBackground.setAlignment(Alignment.CENTRE);
WritableCellFormat bigNoBackground = new WritableCellFormat(bigTitleFont);
bigNoBackground.setWrap(false);
//bigGreyBackground.setBackground(excelColour);
// bigGreyBackground.setBorder(Border.ALL, BorderLineStyle.THIN);
bigNoBackground.setAlignment(Alignment.CENTRE);
//日期格式
jxl.write.DateFormat dfsss = new jxl.write.DateFormat("yyyy-MM-dd hh:mm");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm");
WritableCellFormat dataFormat = new WritableCellFormat(dfsss);
dataFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
DateTime dt=null;
//文本样式
WritableFont contentFont = new WritableFont
(WritableFont.ARIAL,
9,
WritableFont.NO_BOLD,
false,
UnderlineStyle.NO_UNDERLINE);
WritableCellFormat contentFormat = new WritableCellFormat (contentFont);
contentFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
//红色字体样式
WritableFont red = new WritableFont(WritableFont.ARIAL,
9,
WritableFont.BOLD,
false,
UnderlineStyle.NO_UNDERLINE,
Colour.RED);
//红色字体样式
WritableFont blue = new WritableFont(WritableFont.ARIAL,
9,
WritableFont.BOLD,
false,
UnderlineStyle.NO_UNDERLINE,
Colour.BLUE);
//WritableCellFormat redContentFormat = new WritableCellFormat(red);
//redContentFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
//数字格式 0.00
NumberFormat doubleFormat=new NumberFormat("0.00");
WritableCellFormat doublewcf=new WritableCellFormat(contentFont,doubleFormat);
doublewcf.setBorder(Border.ALL, BorderLineStyle.THIN);
//红色字体的数字格式 0.00
NumberFormat redDoubleFormat=new NumberFormat("+0.00");
WritableCellFormat redDoublewcf=new WritableCellFormat(red,redDoubleFormat);
redDoublewcf.setBorder(Border.ALL, BorderLineStyle.THIN);
//蓝色字体的数字格式 0.00
NumberFormat blueDoubleFormat=new NumberFormat("0.00");
WritableCellFormat blueDoublewcf=new WritableCellFormat(blue,blueDoubleFormat);
blueDoublewcf.setBorder(Border.ALL, BorderLineStyle.THIN);
//数字格式 0.0000
NumberFormat doubleFormat2=new NumberFormat("0.0000");
WritableCellFormat doublewcf2=new WritableCellFormat(contentFont,doubleFormat2);
doublewcf2.setBorder(Border.ALL, BorderLineStyle.THIN);
//红色字体的数字格式 0.0000
NumberFormat redDoubleFormat2=new NumberFormat("+0.0000");
WritableCellFormat redDoublewcf2=new WritableCellFormat(red,redDoubleFormat2);
redDoublewcf2.setBorder(Border.ALL, BorderLineStyle.THIN);
//蓝色字体的数字格式 0.0000
NumberFormat blueDoubleFormat2=new NumberFormat("0.0000");
WritableCellFormat blueDoublewcf2=new WritableCellFormat(blue,blueDoubleFormat2);
blueDoublewcf2.setBorder(Border.ALL, BorderLineStyle.THIN);
//数字格式 0%
NumberFormat doubleFormat3=new NumberFormat("0%");
WritableCellFormat doublewcf3=new WritableCellFormat(contentFont,doubleFormat3);
doublewcf3.setBorder(Border.ALL, BorderLineStyle.THIN);
//红色字体的数字格式 0.00 %
NumberFormat redDoubleFormat3=new NumberFormat("+0.00%");
WritableCellFormat redDoublewcf3=new WritableCellFormat(red,redDoubleFormat3);
redDoublewcf3.setBorder(Border.ALL, BorderLineStyle.THIN);
//蓝色字体的数字格式 0.00
NumberFormat blueDoubleFormat3=new NumberFormat("0.00%");
WritableCellFormat blueDoublewcf3=new WritableCellFormat(blue,blueDoubleFormat3);
blueDoublewcf3.setBorder(Border.ALL, BorderLineStyle.THIN);
columnNum=final_columnNum;
Label titleLab=new Label(columnNum,titleRow,"FlOW_OUT_SRC_IP",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"FlOW_OUT_DEST_IP",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"CALLED_RTP_PACKETS",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"CALLED_PACKETS",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"PACK_LOSS",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"CALLED_RTP_AVG_JITTER",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"CALLED_R_FACTOR",greyBackground);
sheet.addCell(titleLab);
titleLab=new Label(++columnNum,titleRow,"CALLED_MOS",greyBackground);
sheet.addCell(titleLab);
SBCCDRDAO sbcCDRDAO=new SBCCDRDAO();
List<SBCCDRVO> list=sbcCDRDAO.getList(sqlPath);
columnNum=final_columnNum+1;
//其它
titleLab=new Label(final_columnNum,(final_titleRow-2),strBigTitle,bigGreyBackground);
sheet.addCell(titleLab);
titleLab=new Label(final_columnNum,(final_titleRow-1),trunkSmallTitle,smallTitleBackground);
sheet.addCell(titleLab);
//整数
WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
integerFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
Number number =null;
//字符串
Label label=null;
int conColumn=final_columnNum;
int conRow=final_titleRow+2;
// WeekDao weekDao=new WeekDao();
for(int i=0;i<list.size();i++){
SBCCDRVO vo=list.get(i);
if(vo.getF32_flow_out_src_ip()==null){
titleLab=new Label((conColumn++),conRow,"N/A",contentFormat);
}else{
titleLab=new Label((conColumn++),conRow,vo.getF32_flow_out_src_ip(),contentFormat);
}
sheet.addCell(titleLab);
if(vo.getF34_flow_out_dest_ip()==null){
titleLab=new Label((conColumn++),conRow,"N/A",contentFormat);
}else{
titleLab=new Label((conColumn++),conRow,vo.getF34_flow_out_dest_ip(),contentFormat);
}
sheet.addCell(titleLab);
if(vo.getCalled_rtp_packets()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getCalled_rtp_packets(),integerFormat);
sheet.addCell(number);
}
if(vo.getCalled_packets()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getCalled_packets(),integerFormat);
sheet.addCell(number);
}
//%
if(vo.getPack_loss()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getPack_loss()/100.00,doublewcf3);
sheet.addCell(number);
}
if(vo.getCalled_rtp_avg_jitter()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getCalled_rtp_avg_jitter(),integerFormat);
sheet.addCell(number);
}
if(vo.getCalled_r_factor()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getCalled_r_factor(),integerFormat);
sheet.addCell(number);
}
if(vo.getCalled_mos()==null){
titleLab=new Label((conColumn++),conRow,"N/A",noRightBackground);
sheet.addCell(titleLab);
}else{
number=new Number((conColumn++),conRow,vo.getCalled_mos(),integerFormat);
sheet.addCell(number);
}
total_columnNum= conColumn-1;
conColumn=final_columnNum;
conRow++;
}
sheet.mergeCells(final_columnNum,(final_titleRow-1),total_columnNum,(final_titleRow-1));//合并单元格 先往合并的第一个单元格写数据,再合并
sheet.mergeCells(final_columnNum,(final_titleRow-2),total_columnNum,(final_titleRow-2));//合并单元格 先往合并的第一个单元格写数据,再合并
workbook.write();
if(workbook!=null){
workbook.close();
}
return true;
}
}
发表评论
-
Maven安装与配置
2013-01-31 18:55 1017Maven安装与配置 下载 Maven 安装 j ... -
spring MD5
2012-06-20 09:28 10138import org.springframework.secu ... -
zip 压缩文件 文件夹,压缩代码
2012-03-02 09:45 1190zip 压缩文件 文件夹,压缩代码 -
log4j绝对路path
2012-01-05 15:40 1275log4j绝对路path cbill@ubuntu:/ ... -
apache2启来
2011-05-03 15:02 759/usr/local/apache2/bin apache ... -
ZIP把某一文件进行打包
2011-03-09 15:41 9521:对某文件进行打包 2:对茉文件夹进行打包 -
log4j的应用配置
2010-10-16 17:55 1083优先级 TRACE ,DEBUG ,INFO ,WAR ... -
介绍Log4j?
2010-10-16 17:28 1350log4j的是什么? 是log4j的一 ... -
Ant的安装
2010-10-14 21:50 923下载 apache-ant-1.8.1-bin[1].z ...
相关推荐
jxl数据导入导出jxl数据导入导出jxl数据导入导出 jxl数据导入导出jxl数据导入导出jxl数据导入导出
jxl java excel export jxl数据导出,完整代码附带jar
jxl的api chm格式,喜欢的朋友可以看看
jxl配置.doc讲述了jxl使用前的配置方法
jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档 jxl 源码 jar chm格式API文档
JXL教程 JXL开发文档 JXL学习笔记 JXL示例。
jxl操作 jxl操作 jxl操作 jxl操作 jxl操作 jxl操作
用jxl读写excel数据,输出图片到excel
java语言操纵excel文档。以及jxl的帮助文档
最近刚好用到jxl来读取Excel表格数据,百度上找遍都找不到jxl的jar包,最后通过其他途径找到了,所以分享一下,让接下来的同学不要费劲找jar包了。
NULL 博文链接:https://xurichusheng.iteye.com/blog/1863479
本项目实现了通过jxl包向指定的excel模板中写入数据,并且保留原来的模板,相当于先复制在写入。
java实现数据的导入与导出依赖包 jxl.jar
jxl api说明文档 不包含pai包
jxl对下拉列表的读写操作以及相应的修改功能
jxl读取excel数据(带实例) 里面有一个自己写的实例
Jxl对中文支持非常好,操作简单,方法看名知意。 Jxl是纯javaAPI,在跨平台上表现的非常完美,代码可以再windows或者Linux上运行而无需重新编写 支持Excel 95-2000的所有版本(网上说目前可以支持Excel2007了,还...
下面是我对JXL的使用情况以简单的小程序为例子作一些总结,希望对大家能够有所帮助
java后台jxl将excel数据导入到MYSQL中
jxl操作excel说明以及jxl jar包