|
时 间 记 忆 |
<< < 2018 - 3 > >>
日 |
一 |
二 |
三 |
四 |
五 |
六 |
|
|
|
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 |
|
|
|
|
|
|
java读写Excel自定义行高 |
[ 2017-3-12 21:11:00 | By: 我家超超会发光 ] |
XLSTransformer transformer = new XLSTransformer(); // 将内容写入模板 Workbook workBook = transformer.transformXLS(is, context); // 获取内容 Map<String,Object> rowOther = (Map<String, Object>) context.get("rowOther"); if(!rowOther.isEmpty()){ ExportExcelUtil.setRowHeight(rowOther, workBook); } // 根据内容自定义Excel行高 // 16 行的像素 18 行的高度 public static void setRowHeight(Map<String, Object> context, Workbook workBook) { int defRowHeigth = 16 * 18; Sheet sheet = workBook.getSheetAt(0); for (String key : context.keySet()) { String rows = context.get(key).toString(); List<Cell> cells = getImgCell(sheet, key); int rowIndex = Integer.valueOf(rows); for (Cell cell : cells) { Row row = cell.getRow(); // 设置行高 row.setHeight(Double.valueOf((rowIndex + 1) * defRowHeigth).shortValue()); } } } |
|
|
|
|