package com.mathlab.action;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import com.mathlab.model.Student;
import com.mathlab.service.StuService;
import com.opensymphony.xwork2.ActionSupport;
public class ModelToExcelAction extends ActionSupport {
StuService stuService;
public StuService getStuService() {
return stuService;
}
public void setStuService(StuService stuService) {
this.stuService = stuService;
}
@Override
public String execute() throws Exception {
JFileChooser jfc = new JFileChooser();
jfc.setAcceptAllFileFilterUsed(false);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//只是针对文件夹有效
jfc.setFileFilter(
new FileFilter(){
public boolean accept(File f) {
// TODO Auto-generated method stub
return f.getName().toLowerCase().endsWith(".xls");
}
public String getDescription() {
// TODO Auto-generated method stub
return "Excel File";
}
}
);
jfc.showSaveDialog(null);
String filePath = jfc.getSelectedFile().getPath();
System.out.println(filePath);
WritableWorkbook wwb;
FileOutputStream fos;
try{
fos = new FileOutputStream(filePath+"\\"+"学生名单"+".xls");
wwb = Workbook.createWorkbook(fos);
WritableSheet ws = wwb.createSheet("sheet1", 0); // 创建一个工作表
// 设置单元格的文字格式
WritableFont wf = new WritableFont(WritableFont.ARIAL,12,WritableFont.NO_BOLD,false,
UnderlineStyle.NO_UNDERLINE,Colour.BLUE);
WritableCellFormat wcf = new WritableCellFormat(wf);
wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
wcf.setAlignment(Alignment.CENTRE);
ws.setRowView(1, 500);
ws.addCell(new Label(0, 0, "记录编号",wcf));
ws.addCell(new Label(1, 0, "用户名", wcf));
ws.addCell(new Label(2, 0, "用户密码", wcf));
ws.addCell(new Label(3, 0, "学生姓名", wcf));
ws.addCell(new Label(4, 0, "学号", wcf));
ws.addCell(new Label(5, 0, "所属班级", wcf));
ws.addCell(new Label(6, 0, "权限", wcf));
//填充数据的内容
Student[] stu = new Student[stuService.listStu().size()];
for (int i = 0; i < stuService.listStu().size(); i++){
stu[i] = (Student)stuService.listStu().get(i);
ws.addCell(new Label(0, i + 1, stu[i].getStuID().toString()));
System.out.println(stu[i].getStuID().toString());
ws.addCell(new Label(1, i + 1, stu[i].getStuName()));
ws.addCell(new Label(2, i + 1, stu[i].getStuPwd()));
ws.addCell(new Label(3, i + 1, stu[i].getRealName()));
ws.addCell(new Label(4, i + 1, stu[i].getStuNum()));
ws.addCell(new Label(5, i + 1, stu[i].getGrade()));
ws.addCell(new Label(6, i + 1, stu[i].getAuthority()));
if(i == 0)
wcf = new WritableCellFormat();
}
wwb.write();
wwb.close();
} catch (IOException e){
} catch (RowsExceededException e){
} catch (WriteException e){}
return "success";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于SSH的在线实验系统源码(在线实验部分用matlab库实现).zip
资源推荐
资源详情
资源评论
收起资源包目录
基于SSH的在线实验系统源码(在线实验部分用matlab库实现).zip (579个子文件)
ModelToExcelAction.class 5KB
QueryUserByNameAction.class 4KB
UploadConfigurationRead.class 4KB
StuDaoImpl.class 4KB
UploadAction.class 3KB
ListExpForStuAction.class 3KB
DrawWebMagicAction.class 3KB
ExcelToModelAction.class 3KB
AddExpAction.class 3KB
LoginAction.class 3KB
TeaDaoImpl.class 3KB
PreAddStuAndCourseAction.class 3KB
EditStuAction.class 3KB
ListGradeAuthAction.class 2KB
PreAddExpAction.class 2KB
AddStuAction.class 2KB
DownloadAction.class 2KB
DisplayFilesAction.class 2KB
ReplyNoteAction.class 2KB
ManDaoImpl.class 2KB
AuthDaoImpl.class 2KB
ExperimentDaoImpl.class 2KB
AddNoteAction.class 2KB
StuAndCourseDaoImpl.class 2KB
Experiment.class 2KB
EditTeaAction.class 2KB
NoteDaoImpl.class 2KB
AddCourseAction.class 2KB
AddStuAndCourseAction.class 2KB
EditAuthAction.class 2KB
StuServiceImpl.class 2KB
Student.class 2KB
AddAuthAction.class 2KB
LoginServiceImpl.class 2KB
AddManagerAction.class 2KB
AddTeacherAction.class 2KB
AddGradeAction.class 2KB
ListTeaAuthAction.class 2KB
ListManAuthAction.class 2KB
ListCourseTeaAction.class 2KB
ListGradeAction.class 2KB
ListAuthAction.class 2KB
TeaServiceImpl.class 2KB
PreReplyNoteAction.class 2KB
ListNoteAction.class 2KB
ListTeaAction.class 2KB
ListStuAction.class 2KB
PreEditStuAction.class 2KB
PreEditTeaAction.class 2KB
PreEditAuthAction.class 1KB
ListExpAction.class 1KB
ExpServiceImpl.class 1KB
DataAccessUtil.class 1KB
AuthServiceImpl.class 1KB
Course.class 1KB
TimeGenerator.class 1KB
ManServiceImpl.class 1KB
LoginOutAction.class 1KB
NoteServiceImpl.class 1KB
StuAndCourseServiceImpl.class 1KB
DeleteNoteAction.class 1KB
DeleteAuthAction.class 1KB
DeleteStuAction.class 1KB
DeleteTeaAction.class 1KB
Manager.class 1KB
Teacher.class 1KB
Grade.class 1KB
Note.class 1KB
CourseServiceImpl.class 1KB
CourseDaoImpl.class 1KB
GradeServiceImpl.class 1KB
GradeDaoImpl.class 1KB
UploadFiles.class 1009B
StuAndCourse.class 999B
ExcelToModelAction$1.class 962B
ModelToExcelAction$1.class 962B
Authority.class 931B
ExportDB.class 761B
StuDao.class 639B
StuService.class 588B
TeaDao.class 569B
TeaService.class 521B
ManDao.class 445B
ExperimentDao.class 403B
ExpService.class 398B
ManService.class 397B
AuthService.class 392B
AuthDao.class 381B
StuAndCourseService.class 364B
StuAndCourseDao.class 357B
NoteService.class 354B
NoteDao.class 345B
CourseService.class 290B
GradeService.class 284B
CourseDao.class 281B
GradeDao.class 275B
LoginService.class 236B
fox.css 7KB
skin.css 4KB
addExp.ftl 2KB
共 579 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
土豆片片
- 粉丝: 1641
- 资源: 5637
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- HUF76419D3ST-VB一种N-Channel沟道TO252封装MOS管
- javascript脚本语言教程ppt
- 基于STM32的指纹签到系统源代码+详细文档
- 级联 H 桥储能变流器 0.3s投入相内控制;0.7s投入相间控制 储能电池SOC不一致问题: 1??相内电池模块 SOC 不一
- comsol仿真,方向为热电制冷 半导体制冷(TEC) 图1为通入的脉冲电流,图2为某一时刻的温度分布,图3为冷段温度随时间的
- Design and Analysis of Coupling Matrix for Microwave Filter App
- HUF76413D3ST-VB一种N-Channel沟道TO252封装MOS管
- 脚本编译器+基于vc++开发+可做游戏脚本引擎
- 扫描网站子域名工具!!
- VID20241007145351.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功