poi excel 设置边框字体行高行宽
final HSSFSheet sheet = wb.createSheet(sheetName + "_" + n);
System.out.println("sheetName" + sheetName + "_" + n);
sheet.setDefaultColumnWidth(12);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
HSSFRow row;
final HSSFCellStyle headerStyle = wb.createCellStyle();
headerStyle.setAlignment(CellStyle.ALIGN_CENTER); // 水平居中
headerStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);// 垂直居中
final Font fontStyle = wb.createFont(); // 字体样式
fontStyle.setBoldweight(Font.BOLDWEIGHT_BOLD); // 加粗
fontStyle.setFontName("黑体"); // 字体
fontStyle.setFontHeightInPoints((short) 11); // 大小
// 将字体样式添加到单元格样式中
headerStyle.setFont(fontStyle);
// 边框
headerStyle.setBorderBottom(CellStyle.BORDER_THIN);
headerStyle.setBorderLeft(CellStyle.BORDER_THIN);
headerStyle.setBorderRight(CellStyle.BORDER_THIN);
headerStyle.setBorderTop(CellStyle.BORDER_THIN); // 普通单元格样式,边框,水平居中
final HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(CellStyle.ALIGN_CENTER); // 水平居中
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
// cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
final HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式
cellStyle.setDataFormat(df.getFormat("#,#0.0")); // 小数点后保留两位,可以写contentStyle.setDataFormat(df.getFormat("#,#0.00"));
// 声明列对象
HSSFCell cell = null;
cell = row.createCell(1);
cell.setCellStyle(headerStyle);
// cell.setCellStyle(cellStyle);
poi excel 设置边框字体行高行宽的更多相关文章
- poi生成excel整理(设置边框/字体/颜色/加粗/居中/)
转: poi生成excel整理(设置边框/字体/颜色/加粗/居中/) 2016年12月02日 11:05:23 吃奶的牛 阅读数:34324 HSSFWorkbook wb = new HSSFW ...
- 27.openpyxl 向指定单元格添加图片并修改图片大小 以及修改单元格行高列宽
openpyxl 向指定单元格添加图片并修改图片大小 以及修改单元格行高列宽 from openpyxl import Workbook,load_workbook from openpyxl.dra ...
- TableLayoutPanel 行高列宽设置
/// <summary> /// 获取TableLayoutPanel指定行的高度 /// </summary> /// <param name="layou ...
- datagridview 行高列宽的自动设置
1) 设定行高和列宽自动调整 [C#]// 设定包括Header和所有单元格的列宽自动调整 DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSi ...
- Datagridview 在基于文本的单元格中启用换行,自动调整行高列宽
将 DataGridViewCellStyle的 WrapMode 属性设置为 DataGridViewTriState 枚举值之一.下面的代码示例使用 System.Windows.Forms.Da ...
- 20170707xlVBA多区域拆分多表保持行高列宽
Public Sub 多个区域拆分到多表() AppSettings On Error GoTo ErrHandler Dim StartTime, UsedTime As Variant Start ...
- C#操作EXCEL常见操作集合(行高,列宽,合并单元格,单元格边框线)
private _Workbook _workBook = null; private Worksheet _workSheet = null; private Excel.Application _ ...
- poi excel设置合并单元格边框格式
版本3.17 //设置合并单元格的边框 public static void setBorderForMergeCell(BorderStyle style,int color, CellRangeA ...
- C# 对Excel 单元格格式, 及行高、 列宽、 单元格边框线、 冻结设置
一.对行高,列宽.单元格边框等的设置 这篇简短的文字对单元格的操作总结的比较全面,特此转载过来. private _Workbook _workBook = null; private Workshe ...
随机推荐
- C++11--右值引用(Perfect Forwarding)
/* * 右值引用 2: Perfect Forwarding */ void foo( boVector arg ); // boVector既有移动构造又有拷贝构造 template< ty ...
- 力奋github:https://github.com/birdstudiocn
我的github地址https://github.com/birdstudiocn
- springmvc学习(五)
这次主要是记录一下 springmvc 关于异常处理 和 拦截的回顾 关于springmvc 异常处理:springmvc 提供了 HandlerExceptionResolver 异常处理解析接 ...
- 定位cpu内存问题
定位cpu内存问题 ps -Hp pid 显示进程的线程,P 按CPU内存排序 jstack pid>pid.log 将线程栈 dump 到日志文件中 线程号 十进制转换为 十六进制 在文件中 ...
- 我优化了一下:jquery点击元素以外任意地方隐藏该元素的方法
我优化了一下 $(document).bind('click', function (event) { var evt = event.srcElement ? event.srcElement : ...
- div+css命名大全
头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:lef ...
- [UE4]Cast to转换数据类型
可以转换纯函数,这样就可以不用加执行线了.
- vue todolist待办事项完整
<template> <div id="app"> <input type="text" v-model='todo' @keyd ...
- FileMaker Server 15 Windows 安装
FileMaker 国外流行,国内研究的人不多.这玩意的好处是: 标准的数据库软件,同时带界面,相当于Access. 手机上安装FileMaker Go,Windows & IOS上安装 Fi ...
- Java基础知识_毕向东_Java基础视频教程笔记(19-21 IO流)
18天-06-IO流 字节流和字符流 字节流两个基类:InputStream,FileInputStream,BufferedInputStream OutputStream,FileOutputSt ...