|
|
@@ -39,7 +39,7 @@ public class StyleUtil {
|
|
|
* @return {@link CellStyle}
|
|
|
*/
|
|
|
public static CellStyle cloneCellStyle(Workbook workbook, CellStyle cellStyle) {
|
|
|
- final CellStyle newCellStyle = workbook.createCellStyle();
|
|
|
+ final CellStyle newCellStyle = createCellStyle(workbook);
|
|
|
newCellStyle.cloneStyleFrom(cellStyle);
|
|
|
return newCellStyle;
|
|
|
}
|
|
|
@@ -145,6 +145,21 @@ public class StyleUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 创建单元格样式
|
|
|
+ *
|
|
|
+ * @param workbook {@link Workbook} 工作簿
|
|
|
+ * @return {@link CellStyle}
|
|
|
+ * @see Workbook#createCellStyle()
|
|
|
+ * @since 5.4.0
|
|
|
+ */
|
|
|
+ public static CellStyle createCellStyle(Workbook workbook) {
|
|
|
+ if(null == workbook){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return workbook.createCellStyle();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 创建默认普通单元格样式
|
|
|
*
|
|
|
* <pre>
|
|
|
@@ -156,7 +171,7 @@ public class StyleUtil {
|
|
|
* @return {@link CellStyle}
|
|
|
*/
|
|
|
public static CellStyle createDefaultCellStyle(Workbook workbook) {
|
|
|
- final CellStyle cellStyle = workbook.createCellStyle();
|
|
|
+ final CellStyle cellStyle = createCellStyle(workbook);
|
|
|
setAlign(cellStyle, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
|
|
setBorder(cellStyle, BorderStyle.THIN, IndexedColors.BLACK);
|
|
|
return cellStyle;
|
|
|
@@ -169,7 +184,7 @@ public class StyleUtil {
|
|
|
* @return {@link CellStyle}
|
|
|
*/
|
|
|
public static CellStyle createHeadCellStyle(Workbook workbook) {
|
|
|
- final CellStyle cellStyle = workbook.createCellStyle();
|
|
|
+ final CellStyle cellStyle = createCellStyle(workbook);
|
|
|
setAlign(cellStyle, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
|
|
setBorder(cellStyle, BorderStyle.THIN, IndexedColors.BLACK);
|
|
|
setColor(cellStyle, IndexedColors.GREY_25_PERCENT, FillPatternType.SOLID_FOREGROUND);
|