tanghaihao
1 year ago
2 changed files with 30 additions and 0 deletions
@ -0,0 +1,27 @@
|
||||
package com.hnac.hzims.operational.duty.utils; |
||||
|
||||
import org.apache.poi.ss.SpreadsheetVersion; |
||||
|
||||
import java.lang.reflect.Field; |
||||
|
||||
/** |
||||
* 设置Excel导出的最大字符数 |
||||
* @author tanghaihao |
||||
* @date 2023年08月18日 16:40 |
||||
*/ |
||||
public class ExcelTool { |
||||
|
||||
public static void resetCellMaxTextLength() { |
||||
SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; |
||||
if (Integer.MAX_VALUE != excel2007.getMaxTextLength()) { |
||||
Field field; |
||||
try { |
||||
field = excel2007.getClass().getDeclaredField("_maxTextLength"); |
||||
field.setAccessible(true); |
||||
field.set(excel2007, Integer.MAX_VALUE); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue