ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:27.41KB ,
资源ID:8658264      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-8658264.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ApachePOIHSSF和XSSF读写EXCEL总结文档格式.docx)为本站会员(b****6)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

ApachePOIHSSF和XSSF读写EXCEL总结文档格式.docx

1、Sheet sheet1 = wb.createSheet(HSSF_Sheet_1);Sheet sheet2 = wb.createSheet(HSSF_Sheet_2/Row表示一行Cell表示一列Row row = null;Cell cell = null;for(int i=0;i60;i=i+2) /获得这个sheet的第i行row = sheet1.createRow(i);/设置行长度自动/row.setHeight(short)500);row.setHeightInPoints(20);/row.setZeroHeight(true);for(int j=0;j25;j+

2、) /设置每个sheet每一行的宽度,自动,根据需求自行确定sheet1.autoSizeColumn(j+1, true);/创建一个基本的样式CellStyle cellStyle = SummaryHSSF.createStyleCell(wb);/获得这一行的每j列cell = row.createCell(j);if(j=0) /设置文字在单元格里面的位置cellStyle = SummaryHSSF.setCellStyleAlignment(cellStyle, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);/先创建字体样式

3、,并把这个样式加到单元格的字体里面cellStyle.setFont(createFonts(wb);/把这个样式加到单元格里面cell.setCellStyle(cellStyle);/给单元格设值cell.setCellValue(true);else if(j=1) /设置这个样式的格式(Format) cellStyle = SummaryHSSF.setCellFormat(helper,cellStyle, #,#0.0000cell.setCellValue(new Double(2008.2008);else if(j=2) cell.setCellValue(helper.c

4、reateRichTextString(RichString+i+j);else if(j=3) MM-yyyy-ddcell.setCellValue(new Date();else if(j=24) /设置公式cell.setCellFormula(SUM(E+(i+1)+:X)else cellStyle = SummaryHSSF.setFillBackgroundColors(cellStyle,IndexedColors.ORANGE.getIndex(),IndexedColors.ORANGE.getIndex(),CellStyle.SOLID_FOREGROUND);cel

5、l.setCellValue(1); /输出OutputStream os = new FileOutputStream(new File(c:/SummaryHSSF.xls);wb.write(os);os.close();/* * 边框* param wb * return */ public static CellStyle createStyleCell(Workbook wb) CellStyle cellStyle = wb.createCellStyle();/设置一个单元格边框颜色cellStyle.setBorderBottom(CellStyle.BORDER_THIN)

6、;cellStyle.setBorderTop(CellStyle.BORDER_THIN);cellStyle.setBorderLeft(CellStyle.BORDER_THIN);cellStyle.setBorderRight(CellStyle.BORDER_THIN);cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex();cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex();cellStyle.setBottomBorderColor(Indexe

7、dColors.BLACK.getIndex();cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex();return cellStyle;* 设置文字在单元格里面的位置* CellStyle.ALIGN_CENTER * CellStyle.VERTICAL_CENTER * param cellStyle * param halign * param valign public static CellStyle setCellStyleAlignment(CellStyle cellStyle,short halign,shor

8、t valign) /设置上下cellStyle.setAlignment(CellStyle.ALIGN_CENTER);/设置左右cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);* 格式化单元格* 如#,#0.00,m/d/yy去HSSFDataFormat或XSSFDataFormat里面找* param fmt public static CellStyle setCellFormat(CreationHelper helper,CellStyle cellStyle,String fmt) /还可以用其它方法创建fo

9、rmat cellStyle.setDataFormat(helper.createDataFormat().getFormat(fmt);* 前景和背景填充的着色* param bg IndexedColors.ORANGE.getIndex();* param fg IndexedColors.ORANGE.getIndex();* param fp CellStyle.SOLID_FOREGROUND public static CellStyle setFillBackgroundColors(CellStyle cellStyle,short bg,short fg,short fp

10、) /cellStyle.setFillBackgroundColor(bg);cellStyle.setFillForegroundColor(fg);cellStyle.setFillPattern(fp);* 设置字体public static Font createFonts(Workbook wb) /创建Font对象Font font = wb.createFont();/设置字体font.setFontName(黑体/着色font.setColor(HSSFColor.BLUE.index);/斜体font.setItalic(true);/字体大小font.setFontHei

11、ght(short)300);return font;public class SummaryHSSF public static void main(String args) throws IOException /创建Sheet并给名字(表示Excel的一个Sheet)i=i+2)if(j=0)else if(j=1)/设置这个样式的格式(Format)else if(j=2)else if(j=3)else if(j=24)/* param wb* return*/public static CellStyle createStyleCell(Workbook wb)* CellStyl

12、e.ALIGN_CENTER* CellStyle.VERTICAL_CENTER* param cellStyle* param halign* param valignpublic static CellStyle setCellStyleAlignment(CellStyle cellStyle,short halign,short valign)* param fmtpublic static CellStyle setCellFormat(CreationHelper helper,CellStyle cellStyle,String fmt)/还可以用其它方法创建format* param fp CellStyle.SOLID_FOREGROUNDpublic static CellStyle setFillBackgroundColors(CellStyle cellStyle,short bg,short fg,short fp)public static Font createFonts(Workbook wb)读取Excel文件public class ReadExcel public static void main(String args) throws Exce

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2