目录
[TOC]
参考
https://www.bilibili.com/video/BV1mG4y1f7jr/
导入依赖
1 2 3 4 5 6
| <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>3.3.2</version> </dependency>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `nickname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户昵称', `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户头像链接', `username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户名', `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码,加密存储', `salt` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '密码盐值', `gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别,0表示未知,1表示男性,2表示女性', `birthday` date DEFAULT NULL COMMENT '生日', `email` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '邮箱', `phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '手机号', `qq` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'QQ号码', `wechat` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '微信号', `weibo` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '微博账号', `github` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'GitHub账号', `linkedin` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'LinkedIn账号', `country_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '国家代码', `province` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '省份', `city` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '城市', `address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '地址', `post_code` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '邮编', `last_login_time` datetime DEFAULT NULL COMMENT '最近一次登录时间', `last_login_ip` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '最近一次登录IP地址', `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户状态,0表示禁用,1表示启用', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `remark1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '自定义字段1', `remark2` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '自定义字段2', `remark3` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '自定义字段3', PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `idx_username` (`username`) USING BTREE COMMENT '唯一索引,保证用户名唯一' ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='用户表'
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data;
@Data public class UserExcelEntity {
@ExcelProperty(value = "编号") private Long id;
@ExcelProperty(value = "昵称") private String nickname;
@ExcelProperty(value = "用户名") private String username;
@ExcelProperty(value = "密码") private String password; }
|
文件导入
基本方式导入
基本方式导入,程序中获取到的数据为Map
类型
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import com.alibaba.excel.EasyExcel;
import java.io.File; import java.util.List;
public class BaseImport { public static void main(String[] args) { File file = new File("C:\\Users\\19030\\Desktop\\tmp\\user.xlsx");
List<Object> list = EasyExcel.read(file).sheet(0).doReadSync();
list.forEach(System.out::println); } }
|
模型映射导入
基本语法
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import com.alibaba.excel.EasyExcel; import com.xiaofei.excel.entity.excel.UserExcelEntity; import org.junit.jupiter.api.Test;
import java.io.File; import java.util.List;
public class FileImport {
@Test void modelMapImport() {
File file = new File("C:\\Users\\19030\\Desktop\\tmp\\user.xlsx");
List<UserExcelEntity> list = EasyExcel.read(file).head(UserExcelEntity.class).sheet(0).doReadSync();
list.forEach(System.out::println); } }
|
导入的监昕器
使用EasyExcel自带监听器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import com.alibaba.excel.EasyExcel; import com.alibaba.excel.read.listener.PageReadListener; import com.xiaofei.excel.entity.excel.UserExcelEntity; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List;
public class FileImport {
@Test void listenerImport() throws FileNotFoundException {
InputStream inputStream = new FileInputStream("C:\\Users\\19030\\Desktop\\tmp\\user.xlsx");
EasyExcel.read(inputStream, UserExcelEntity.class, new PageReadListener<>(this::consumerMethod)).sheet(0).doRead(); }
private void consumerMethod(List<UserExcelEntity> list) { list.forEach(System.out::println); } }
|
使用自定义监听器
创建一个类,实现ReadListener
接口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.ReadListener; import com.xiaofei.excel.entity.excel.UserExcelEntity;
public class UserListener implements ReadListener<UserExcelEntity> {
@Override public void invoke(UserExcelEntity userExcelEntity, AnalysisContext analysisContext) { System.out.println(userExcelEntity); }
@Override public void doAfterAllAnalysed(AnalysisContext analysisContext) {
} }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import com.alibaba.excel.EasyExcel; import com.xiaofei.excel.entity.excel.UserExcelEntity; import com.xiaofei.excel.listener.UserListener; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List;
public class FileImport {
@Test void listenerImport() throws FileNotFoundException {
InputStream inputStream = new FileInputStream("C:\\Users\\19030\\Desktop\\tmp\\user.xlsx");
EasyExcel.read(inputStream, UserExcelEntity.class, new UserListener()).sheet(0).doRead(); } }
|
指定表头导入
如图所示,由于表头所在行数不是第一行,EasyExcel默认是指定第一行为表头,这个时候需要EasyExcel.read().headRowNumber(表头所在行数)
指定表头所在行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import com.alibaba.excel.EasyExcel; import com.alibaba.excel.read.listener.PageReadListener; import com.xiaofei.excel.entity.excel.UserExcelEntity; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List;
public class FileImport {
@Test void listenerImport() throws FileNotFoundException {
InputStream inputStream = new FileInputStream("C:\\Users\\19030\\Desktop\\tmp\\user.xlsx");
EasyExcel.read(inputStream, UserExcelEntity.class, new PageReadListener<>(this::consumerMethod)) .headRowNumber(3) .sheet(0).doRead(); }
private void consumerMethod(List<UserExcelEntity> list) { list.forEach(System.out::println); } }
|
导入异常处理
ReadListener
接口中的onException
为出现异常时会执行的方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.ReadListener; import com.xiaofei.excel.entity.excel.UserExcelEntity; import lombok.extern.slf4j.Slf4j;
@Slf4j public class UserListener implements ReadListener<UserExcelEntity> { @Override public void invoke(UserExcelEntity userExcelEntity, AnalysisContext analysisContext) { System.out.println(userExcelEntity); }
@Override public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
@Override public void onException(Exception exception, AnalysisContext context) throws Exception { log.error("Excel导入报错"); ReadListener.super.onException(exception, context); } }
|
文件上传导入
1 2 3 4 5 6 7 8 9 10 11 12
|
@ApiOperation(value = "文件上传", httpMethod = "POST", response = ResponseUtils.class, produces = "application/json") @PostMapping("/upload") public ResponseUtils<Boolean> uploadFile(@RequestParam("file") MultipartFile file) throws IOException { Boolean isSuccess = userService.uploadFile(file); return new ResponseUtils<Boolean>().success(isSuccess ? "上传成功" : "上传失败", isSuccess); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
@Override public Boolean uploadFile(MultipartFile file) throws IOException {
if (file == null) { throw new RuntimeException("上传的文件不能为空"); }
InputStream inputStream = file.getInputStream();
EasyExcel.read(inputStream, UserEntity.class, new PageReadListener<>(this::addBatch)).headRowNumber(3).sheet().doRead();
return true; }
@Override @CacheEvict(cacheNames = RedisConstant.BASE_CACHE_KEY + "user", allEntries = true) public Boolean addBatch(List<UserEntity> userEntityList) { return this.saveBatch(userEntityList); }
|
文件导出
基本方式导出
1 2 3 4 5 6 7
| @Test void baseImport() { String filePath = "C:\\Users\\19030\\Desktop\\tmp\\userExport.xlsx"; List<UserEntity> userEntities = userService.selectList();
EasyExcel.write(filePath).sheet("导出数据").head(UserEntity.class).doWrite(userEntities); }
|
模型映射导出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| import com.alibaba.excel.EasyExcel; import com.xiaofei.excel.entity.UserEntity; import com.xiaofei.excel.service.UserService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest public class EasyExcelApplicationTest {
@Autowired private UserService userService;
@Test void baseImport() {
List<UserEntity> userEntities = userService.selectList();
String filePath = "C:\\Users\\19030\\Desktop\\tmp\\userExport.xlsx"; EasyExcel.write(filePath).sheet("导出数据").head(UserEntity.class).doWrite(userEntities); } }
|
导出行高列宽
在实体类的字段或类上,添加对应的注解
EasyExcel.write(filePath).sheet(“导出数据”).registerWriteHandler对应的策略,也可以写一个类继承AbstractColumnWidthStyleStrategy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.xiaofei.excel.entity.UserEntity; import com.xiaofei.excel.service.UserService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.List;
@SpringBootTest public class EasyExcelApplicationTest {
@Autowired private UserService userService;
@Test void baseImport() {
List<UserEntity> userEntities = userService.selectList();
String filePath = "C:\\Users\\19030\\Desktop\\tmp\\userExport.xlsx"; EasyExcel .write(filePath) .sheet("导出数据").head(UserEntity.class) .registerWriteHandler(new SimpleColumnWidthStyleStrategy(30)) .doWrite(userEntities); } }
|
也可以写一个类,继承AbstractCellStyleStrategy
并且实现CellWriteHandler
,编写一个EasyExcel的自定义拦截器
合并单元格导出
导出动态表头
导出链接批注公式
导出图片内容
填充模板
模板填充对象
模板填充列表
模板组合填充
导出文件下载
工具类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.metadata.Head; import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.util.MapUtils; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.ss.usermodel.Cell; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.List; import java.util.Map;
@Component public class ColumnWidthStyleStrategy extends AbstractColumnWidthStyleStrategy {
private static final int MAX_COLUMN_WIDTH = 255;
private final Map<Integer, Map<Integer, Integer>> cache = MapUtils.newHashMapWithExpectedSize(8);
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
if (needSetWidth) { Map<Integer, Integer> maxColumnWidthMap = this.cache.computeIfAbsent(writeSheetHolder.getSheetNo(), (key) -> new HashMap<>(16)); Integer columnWidth = this.dataLength(cellDataList, cell, isHead); if (columnWidth >= 0) { if (columnWidth > MAX_COLUMN_WIDTH) { columnWidth = MAX_COLUMN_WIDTH; }
Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); if (maxColumnWidth == null || columnWidth > maxColumnWidth) { maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), (columnWidth + 15) * MAX_COLUMN_WIDTH); }
} } }
private Integer dataLength(List<WriteCellData<?>> cellDataList, Cell cell, Boolean isHead) { if (isHead) { return cell.getStringCellValue().getBytes().length; } else { WriteCellData<?> cellData = cellDataList.get(0); CellDataTypeEnum type = cellData.getType(); if (type == null) { return -1; } else { switch (type) { case STRING: return cellData.getStringValue().getBytes().length; case BOOLEAN: return cellData.getBooleanValue().toString().getBytes().length; case NUMBER: return cellData.getNumberValue().toString().getBytes().length; default: return -1; } } } } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
| import com.alibaba.excel.EasyExcel; import com.alibaba.excel.enums.BooleanEnum; import com.alibaba.excel.event.SyncReadListener; import com.alibaba.excel.read.listener.PageReadListener; import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteFont; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy; import com.xiaofei.excel.strategy.ColumnWidthStyleStrategy; import org.apache.poi.ss.usermodel.*; import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer;
@Component public class EasyExcelUtils {
public static <T> void readFile(InputStream inputStream, Class<T> head, Consumer<List<T>> consumer, String sheetName, Integer headRowNumber) { EasyExcel.read(inputStream, head, new PageReadListener<>(consumer)) .autoCloseStream(false) .headRowNumber(headRowNumber == null ? 1 : headRowNumber) .sheet(sheetName) .doReadSync(); }
public static <T> void readFile(InputStream inputStream, Class<T> head, Consumer<List<T>> consumer, Integer headRowNumber) { EasyExcel.read(inputStream, head, new PageReadListener<T>(consumer)) .autoCloseStream(false) .headRowNumber(headRowNumber == null ? 1 : headRowNumber) .doReadAllSync(); }
public static <T> List<T> readFile(InputStream inputStream, Class<T> head, String sheetName, Integer headRowNumber) { SyncReadListener syncReadListener = new SyncReadListener(); EasyExcel.read(inputStream, head, syncReadListener) .autoCloseStream(false) .headRowNumber(headRowNumber == null ? 1 : headRowNumber) .sheet(sheetName) .doReadSync();
if (syncReadListener.getList() != null) { return (List<T>) syncReadListener.getList(); }
return new ArrayList<>(); }
public static <T> List<T> readFile(InputStream inputStream, Class<T> head, Integer headRowNumber) { SyncReadListener syncReadListener = new SyncReadListener();
EasyExcel.read(inputStream, head, syncReadListener) .autoCloseStream(false) .headRowNumber(headRowNumber == null ? 1 : headRowNumber) .doReadAllSync();
if (syncReadListener.getList() != null) { return (List<T>) syncReadListener.getList(); } return new ArrayList<>(); }
public static <T> void writeFile(HttpServletResponse response, String filename, String sheetName, Class<T> head, List<T> data) throws IOException {
response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); filename = URLEncoder.encode(filename, "UTF-8"); response.setHeader("Content-disposition", "attachment;filename=" + filename + "_" + System.currentTimeMillis() + ExcelTypeEnum.XLSX.getValue());
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle(), contentWriteCellStyle());
EasyExcel .write(response.getOutputStream(), head) .autoCloseStream(false) .registerWriteHandler(new ColumnWidthStyleStrategy()) .registerWriteHandler(new SimpleRowHeightStyleStrategy((short) 30, (short) 25)) .registerWriteHandler(horizontalCellStyleStrategy) .sheet(sheetName) .doWrite(data);
}
public static WriteCellStyle headWriteCellStyle() { WriteCellStyle headWriteCellStyle = new WriteCellStyle();
WriteFont headWriteFont = new WriteFont(); headWriteFont.setFontName("仿宋"); headWriteFont.setFontHeightInPoints((short) 16); headWriteFont.setBold(BooleanEnum.TRUE.getBooleanValue());
headWriteCellStyle.setWriteFont(headWriteFont);
headWriteCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.index); headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
headWriteCellStyle.setBorderBottom(BorderStyle.THIN); headWriteCellStyle.setBottomBorderColor((IndexedColors.BLACK1.index)); headWriteCellStyle.setBorderLeft(BorderStyle.THIN); headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK1.index); headWriteCellStyle.setBorderRight(BorderStyle.THIN); headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK1.index); headWriteCellStyle.setBorderTop(BorderStyle.THIN); headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK1.index);
headWriteCellStyle.setWrapped(BooleanEnum.FALSE.getBooleanValue()); headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); headWriteCellStyle.setShrinkToFit(BooleanEnum.FALSE.getBooleanValue());
return headWriteCellStyle; }
public static WriteCellStyle contentWriteCellStyle() { WriteCellStyle headWriteCellStyle = new WriteCellStyle();
WriteFont headWriteFont = new WriteFont(); headWriteFont.setFontName("仿宋"); headWriteFont.setFontHeightInPoints((short) 14); headWriteFont.setBold(BooleanEnum.FALSE.getBooleanValue()); headWriteFont.setColor(IndexedColors.BLACK.index);
headWriteCellStyle.setWriteFont(headWriteFont);
headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.index); headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
headWriteCellStyle.setBorderBottom(BorderStyle.THIN); headWriteCellStyle.setBottomBorderColor((IndexedColors.BLACK1.index)); headWriteCellStyle.setBorderLeft(BorderStyle.THIN); headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK1.index); headWriteCellStyle.setBorderRight(BorderStyle.THIN); headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK1.index); headWriteCellStyle.setBorderTop(BorderStyle.THIN); headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK1.index);
headWriteCellStyle.setWrapped(BooleanEnum.FALSE.getBooleanValue()); headWriteCellStyle.setShrinkToFit(BooleanEnum.FALSE.getBooleanValue()); headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return headWriteCellStyle; } }
|