|
@@ -231,7 +231,7 @@ public class ExcelHelper {
|
|
|
}
|
|
|
rowIndex = writeColspanTitlesToExcel(wb, sheet, data.getColspanTitles(), data.getTitles());
|
|
|
writeRowsToExcel(wb, sheet, data.getRows(), rowIndex, data.getStyleList());
|
|
|
- autoSizeColumns(sheet, data.getTitles().size() + 1);
|
|
|
+ autoSizeColumns(sheet, data.getTitles());
|
|
|
|
|
|
//合并行
|
|
|
if (data.getCellRangeList() != null && data.getCellRangeList().size() > 0) {
|
|
@@ -331,11 +331,12 @@ public class ExcelHelper {
|
|
|
// dataFont.setFontHeightInPoints((short) 14);
|
|
|
dataFont.setColor(IndexedColors.BLACK.index);
|
|
|
|
|
|
- XSSFCellStyle defaultStyle = wb.createCellStyle();
|
|
|
- defaultStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
- defaultStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
- defaultStyle.setFont(dataFont);
|
|
|
- setBorder(defaultStyle, BorderStyle.THIN, new XSSFColor(new java.awt.Color(188, 188, 188), new DefaultIndexedColorMap()));
|
|
|
+ XSSFCellStyle dataStyle = wb.createCellStyle();
|
|
|
+ //dataStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ //dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ dataStyle.setFont(dataFont);
|
|
|
+ dataStyle.setWrapText(true);
|
|
|
+ setBorder(dataStyle, BorderStyle.THIN, new XSSFColor(new java.awt.Color(188, 188, 188), new DefaultIndexedColorMap()));
|
|
|
|
|
|
for (List<Object> rowData : rows) {
|
|
|
Row dataRow = sheet.createRow(rowIndex);
|
|
@@ -354,7 +355,7 @@ public class ExcelHelper {
|
|
|
if (styleList != null && styleList.size() > index && styleList.get(index).size() > colIndex) {
|
|
|
cell.setCellStyle(styleList.get(index).get(colIndex));
|
|
|
} else {
|
|
|
- cell.setCellStyle(defaultStyle);
|
|
|
+ cell.setCellStyle(dataStyle);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -366,15 +367,19 @@ public class ExcelHelper {
|
|
|
return rowIndex;
|
|
|
}
|
|
|
|
|
|
- private void autoSizeColumns(Sheet sheet, int columnNumber) {
|
|
|
- for (int i = 0; i < columnNumber; i++) {
|
|
|
+ private void autoSizeColumns(Sheet sheet,List<String> titles) {
|
|
|
+ for (int i = 0; i < titles.size(); i++) {
|
|
|
int orgWidth = sheet.getColumnWidth(i);
|
|
|
sheet.autoSizeColumn(i, true);
|
|
|
int newWidth = (int) (sheet.getColumnWidth(i) + 100);
|
|
|
- if (newWidth > orgWidth) {
|
|
|
- sheet.setColumnWidth(i, newWidth);
|
|
|
- } else {
|
|
|
- sheet.setColumnWidth(i, orgWidth);
|
|
|
+ if(titles.get(i).equals("其他要求")||titles.get(i).equals("工作情况")){
|
|
|
+ sheet.setColumnWidth(i, 65280);
|
|
|
+ }else{
|
|
|
+ if (newWidth > orgWidth) {
|
|
|
+ sheet.setColumnWidth(i, newWidth);
|
|
|
+ } else {
|
|
|
+ sheet.setColumnWidth(i, orgWidth);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|