利用JXL包,对Excel进行操作生成简历模版,

利用提供的JXL包,通过程序生成简历模版,

要求:
1、用程序生成指定的简历模版
2、从键盘输入对应信息,并写入简历对应的位置,用不同的字体区分;

链接: https://pan.baidu.com/s/1eRu4d7zO6KdnxtnOCiXODQ 提取码: t523
Jxl 包 下载地址

package excel;

import java.io.File;

import jxl.Workbook;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableImage;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
 public class Cexcel {
	 public static void main(String args[]) {
	        try {
	            // 打开文件
	            WritableWorkbook book = Workbook.createWorkbook(new File("test.xls"));
	            // 生成名为“Sheet1”的工作表,参数0表示这是第一页
	            WritableSheet sheet = book.createSheet("Sheet1", 0);
	            // 在Label对象的构造子中指名单元格位置是第一列第一行(0,0)
	            // 以及单元格内容为test 
	            WritableFont font1 = new WritableFont(WritableFont.createFont("仿宋"),20);
	            WritableCellFormat format1=new WritableCellFormat(font1);
	            format1.setAlignment(jxl.format.Alignment.CENTRE);// 单元格内容水平居中
	            
	            format1.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK); 
	         // Border.ALL:上下左右都设置边框; BorderLineStyle.THIN: 细边框; jxl.format.Colour.BLACK: 黑颜色
	            sheet.setColumnView(0,20);//设置列宽度
	            sheet.setColumnView(1,20);
	            sheet.setColumnView(2,20);
	            sheet.setColumnView(3,20);
	            sheet.setColumnView(4,20);
	            sheet.setColumnView(5,20);
	            sheet.setColumnView(6,10);
	            sheet.setColumnView(7,10);
	            WritableFont font2 = new WritableFont(WritableFont.createFont("宋体"),11);
	            WritableCellFormat format2=new WritableCellFormat(font2);
	            format2.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK);
	            
	            WritableFont font3 = new WritableFont(WritableFont.createFont("宋体"),11);
	            WritableCellFormat format3=new WritableCellFormat(font3);
	            format3.setAlignment(jxl.format.Alignment.CENTRE);// 单元格内容水平居中
	            format3.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK); 
	            
	            WritableFont font4 = new WritableFont(WritableFont.createFont("宋体"),11);
	            WritableCellFormat format4=new WritableCellFormat(font4);
	            format4.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK);
	            format4.setVerticalAlignment(jxl.format.VerticalAlignment.TOP);
	            format4.setWrap(true);//是否换行 
	            
	            Label label = new Label(0, 0, "求职简历",format1);
	            sheet.addCell(label);
	            sheet.mergeCells(0,0,7,1);
	            sheet.mergeCells(6, 2, 7, 7);
	            
	            label=new Label(6,2,"照片",format3);
		           sheet.addCell(label);
		           
		           File imgFile=new File("11.png");//将该图片和java文件放一起
	            WritableImage imag=new WritableImage(6,2,2,7,imgFile);
	            sheet.addImage(imag);
	            
	           label=new Label(0,2,"姓名",format2);
	           sheet.addCell(label);
	            
	          label = new Label(1, 2, "***",format2);
	          sheet.addCell(label);
	          
	          label = new Label(2, 2, "性别",format2);
	          sheet.addCell(label);
	          
	          label = new Label(3, 2, "男",format2);
	          sheet.addCell(label);
	            
	          label = new Label(4, 2, "籍贯",format2);
	          sheet.addCell(label);
	          
	          label = new Label(5, 2, "***",format2);
	          sheet.addCell(label);
	          
	          label=new Label(0,3,"出生日期",format2);
	           sheet.addCell(label);
	            
	          label = new Label(1, 3, "****",format2);
	          sheet.addCell(label);
	          
	          label = new Label(2, 3, "民族",format2);
	          sheet.addCell(label);
	          
	          label = new Label(3, 3, "汉",format2);
	          sheet.addCell(label);
	            
	          label = new Label(4, 3, "邮箱",format2);
	          sheet.addCell(label);
	          
	          label = new Label(5, 3, "*****",format2);
	          sheet.addCell(label);
	          
	          label = new Label(0, 4, "家庭地址",format2);
	          sheet.addCell(label);
	          
	          sheet.mergeCells(1, 4, 5, 4);
	          label = new Label(1, 4, "*********",format2);
	          sheet.addCell(label);
	          
	          label=new Label(0,5,"政治面貌",format2);
	           sheet.addCell(label);
	            
	          label = new Label(1, 5, "*********",format2);
	          sheet.addCell(label);
	          
	          label = new Label(2, 5, "电话",format2);
	          sheet.addCell(label);
	          
	          label = new Label(3, 5, "**********",format2);
	          sheet.addCell(label);
	            
	          label = new Label(4, 5, "专业",format2);
	          sheet.addCell(label);
	          
	          label = new Label(5, 5, "*******",format2);
	          sheet.addCell(label);
	          
	          label=new Label(0,6,"",format2);
	           sheet.addCell(label);
	            
	          label = new Label(1, 6, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(2, 6, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(3, 6, "",format2);
	          sheet.addCell(label);
	            
	          label = new Label(4, 6, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(5, 6, "",format2);
	          sheet.addCell(label);
	          
	          label=new Label(0,7,"",format2);
	           sheet.addCell(label);
	            
	          label = new Label(1, 7, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(2, 7, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(3, 7, "",format2);
	          sheet.addCell(label);
	            
	          label = new Label(4, 7, "",format2);
	          sheet.addCell(label);
	          
	          label = new Label(5, 7, "",format2);
	          sheet.addCell(label);
	          
	          sheet.mergeCells(0, 8, 7, 8);
	           label = new Label(0, 8, "个人简介",format3);
	            sheet.addCell(label);
	          
	            sheet.mergeCells(0, 9, 7, 18);
	            label = new Label(0, 9, "5岁教导希露菲,使希露菲作为护卫保护皇女促使历史改变、11岁横穿魔大陆平安回到中央大陆、12岁受重伤情况下与龙神对持并轻伤龙神(龙神是世界最强)、13岁单独讨伐离群龙、14岁作为魔法学校顶端般的存在镇压不良生",format4);
	           
	            sheet.addCell(label);
	            
	            
	            sheet.mergeCells(0, 19, 7, 19);
		           label = new Label(0, 19, "专长",format3);
		            sheet.addCell(label);
		          
		            sheet.mergeCells(0, 20, 7, 31);
		            label = new Label(0, 20, "无咏唱攻击法术、普通岩炮弹、混合火魔法压缩岩炮弹(炮弹威力)、压缩型岩炮弹(中空弹)、雷光、霜冻新星、‘半飞行、乱魔、召唤与反召唤物品魔法",format4);
		           
		            sheet.addCell(label);
	      
	            // 写入数据并关闭文件
	            book.write();
	            book.close();

	        } catch (Exception e) {
	            System.out.println(e);
	        }
	                
	   
	    }
	}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值