excel导出java代码

上传人:文*** 文档编号:62771808 上传时间:2022-03-16 格式:DOC 页数:6 大小:27.50KB
收藏 版权申诉 举报 下载
excel导出java代码_第1页
第1页 / 共6页
excel导出java代码_第2页
第2页 / 共6页
excel导出java代码_第3页
第3页 / 共6页
资源描述:

《excel导出java代码》由会员分享,可在线阅读,更多相关《excel导出java代码(6页珍藏版)》请在装配图网上搜索。

1、文档供参考,可复制、编制,期待您的好评与关注! /* * 试卷整体情况统计 excel导出 * param request * throws IOException * throws WriteException */public void sjztqktjExcel(HttpServletRequest request) throws IOException, WriteException sjfxEntity entity=new sjfxEntity();HttpSession session = request.getSession(true);String ksq=String.va

2、lueOf(request.getParameter(ksq);/考试期String zydm=String.valueOf(request.getParameter(zydm);/专业String kcdm=String.valueOf(request.getParameter(kcdm);/课程String qxdm=String.valueOf(request.getParameter(qxdm);/区县String zxzzdm=String.valueOf(request.getParameter(zxzzdm);/助学单位String jtdwdm=String.valueOf(r

3、equest.getParameter(jtdwdm);/集体单位String kslbdm = (String)request.getSession().getAttribute(kslbdm);String cd = String.valueOf(request.getParameter(cd);/菜单名boolean ifpage=false;List list = entity.selectSjztqktj(ksq, zydm, kcdm, qxdm,zxzzdm, jtdwdm, kslbdm,request,ifpage);String title = 高等教育自学考试试卷整体情况

4、统计表;String filename = 高等教育自学考试试卷整体情况统计表;title += (+ksq+);filename += _+ksq+.xls;/文件路径 String filepath = request.getRealPath(/) + downloadexceljsxkhzb; File file = new File(filepath); filepath = filepath + filename; if (!file.exists() file.mkdirs(); WritableWorkbook workbook = Workbook.createWorkbook

5、(new File(filepath); try WritableSheet sheet = workbook.createSheet(cd, 0);sheet.setPageSetup(PageOrientation.PORTRAIT,PaperSize.A4,0,0);sheet.getSettings().setLeftMargin(0.5);sheet.getSettings().setRightMargin(0.5);WritableCellFormat style = null;style = new WritableCellFormat();style.setAlignment(

6、Alignment.CENTRE);style.setVerticalAlignment(VerticalAlignment.CENTRE);style.setBorder(Border.ALL, BorderLineStyle.THIN);style.setBackground(Colour.WHITE);style.setWrap(true);WritableCellFormat style_t = null;WritableFont font_t = null;font_t = new WritableFont(WritableFont.ARIAL, 14, WritableFont.B

7、OLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);style_t = new WritableCellFormat(font_t);style_t.setAlignment(Alignment.CENTRE);style_t.setVerticalAlignment(VerticalAlignment.CENTRE);style_t.setBorder(Border.ALL, BorderLineStyle.NONE);style_t.setBackground(Colour.VERY_LIGHT_YELLOW);style_t.set

8、Wrap(true);/合并14列-标题sheet.mergeCells(0, 0, 14, 0);sheet.addCell(new Label(0, 0, title, style_t);Label label_1 = new Label(0, 1, 课程代码, style);sheet.addCell(label_1);Label label_2 = new Label(1, 1, 课程名称, style);sheet.addCell(label_2);Label label_3 = new Label(2, 1, 报考人数, style);sheet.addCell(label_3);

9、Label label_4 = new Label(3, 1, 实考人数, style);sheet.addCell(label_4);Label label_5 = new Label(4, 1, 合格人数, style);sheet.addCell(label_5);Label label_6 = new Label(5, 1, 合格率, style);sheet.addCell(label_6);Label label_7 = new Label(6, 1, 平均分, style);sheet.addCell(label_7);Label label_8 = new Label(7, 1

10、, 主观题平均分, style);sheet.addCell(label_8);Label label_9 = new Label(8, 1, 客观题平均分, style);sheet.addCell(label_9);Label label_10 = new Label(9, 1, 最高分, style);sheet.addCell(label_10);Label label_11 = new Label(10, 1, 最低分, style);sheet.addCell(label_11);Label label_12 = new Label(11, 1, 全距, style);sheet.

11、addCell(label_12);Label label_13 = new Label(12, 1, 标准差, style);sheet.addCell(label_13);if(list!=null & list.size()!=0)for(int i=0;ilist.size();i+)Map map = (Map)list.get(i);int count = i+1;String classno = String.valueOf(map.get()=null?:map.get();String classname = String.valueOf(map.get()=null?:ma

12、p.get();String examperon = String.valueOf(map.get()=null?:map.get();String realityperson = String.valueOf(map.get()=null?:map.get();String qualifiedpersion = String.valueOf(map.get()=null?:map.get();String standardscore = String.valueOf(map.get()=null?:map.get();String avgscore = String.valueOf(map.

13、get()=null?:map.get();String zgtscore = String.valueOf(map.get()=null?:map.get();String kgtscore = String.valueOf(map.get()=null?:map.get();String maxscore = String.valueOf(map.get()=null?:map.get();String minscore = String.valueOf(map.get()=null?:map.get();String allli = String.valueOf(map.get()=nu

14、ll?:map.get();String qualifie = String.valueOf(map.get();String biaozhun=String.valueOf(map.get()=null?:map.get();if(qualifie=null|qualifie.equals()|qualifie.equals(null)qualifie = ;elsequalifie += %;sheet.addCell(new Label(0, i + 2, classno, style);sheet.addCell(new Label(1, i + 2, classname, style

15、);sheet.addCell(new Label(2, i + 2, examperon, style);sheet.addCell(new Label(3, i + 2, realityperson, style);sheet.addCell(new Label(4, i + 2, qualifiedpersion, style);sheet.addCell(new Label(5, i + 2, qualifie, style);sheet.addCell(new Label(6, i + 2, avgscore, style);sheet.addCell(new Label(7, i

16、+ 2, zgtscore, style);sheet.addCell(new Label(8, i + 2, kgtscore, style);sheet.addCell(new Label(9, i + 2, maxscore, style);sheet.addCell(new Label(10, i + 2, minscore, style);sheet.addCell(new Label(11, i + 2, allli, style);sheet.addCell(new Label(12, i + 2, biaozhun, style);/表格宽度设置sheet.setRowView

17、(0,500);sheet.setColumnView(0,10);sheet.setColumnView(1,10);sheet.setColumnView(2,10);sheet.setColumnView(3,10);sheet.setColumnView(4,10);sheet.setColumnView(5,10);sheet.setColumnView(6,10);sheet.setColumnView(7,10);sheet.setColumnView(8,10);sheet.setColumnView(9,10);sheet.setColumnView(10,10);sheet

18、.setColumnView(11,10);sheet.setColumnView(12,10);/设置打印头sheet.getSettings().setPrintTitlesRow(0, 1);/sheet.setPageSetup(PageOrientation.LANDSCAPE,PaperSize.A4,0,0);/横向打印sheet.getSettings().setLeftMargin(0.5);sheet.getSettings().setRightMargin(0.5);sheet.getSettings().setTopMargin(0.5);sheet.getSettin

19、gs().setBottomMargin(0.5);sheet.getSettings().setFooterMargin(0.2);sheet.getSettings().setHorizontalCentre(true);HeaderFooter hf = new HeaderFooter();Contents ct = hf.getRight();ct.append(共 );ct.appendTotalPages();ct.append( 页 第 );ct.appendPageNumber();ct.append( 页);sheet.getSettings().setFooter(hf)

20、;/Iprecord.InsertIprecord(request, 文件导出,文件:+filename+:导出成功);catch (Exception e) /Iprecord.InsertIprecord(request, 文件导出,文件:+filename+:导出失败);e.printStackTrace();finallyworkbook.write();workbook.close();request.setAttribute(FILENAME,filename); request.setAttribute(FILEPATH,request.getRealPath(/) + downloadexcelsjztqktj); 6 / 6

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!