public final class ExcelUtils extends Object
| 构造器和说明 |
|---|
ExcelUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addCustomValid(String formula,
org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent)
Add custom validation when export
|
static void |
addDateValid(OperatorType operatorType,
String expr1,
String expr2,
String pattern,
org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent,
boolean showTip,
String tipTitle,
String tipContent)
Add date validation when export
|
static void |
addDropdownBox(String[] combobox,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent,
org.apache.poi.ss.usermodel.Workbook workbook,
org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
String[] values)
Add a dropdown box when export
|
static void |
addNumericValid(ValidType validType,
OperatorType operatorType,
String expr1,
String expr2,
org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent,
boolean showTip,
String tipTitle,
String tipContent)
Add numeric validation when export,
|
static void |
addRepeatValid(org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent)
Add repeat validation when export
|
static String |
createFormula(String suffix,
int firstColIndex,
int firstRowIndex,
int lastColIndex,
int lastRowIndex)
Create a formula
|
static String |
createSumFormula(int firstColIndex,
int firstRowIndex,
int lastColIndex,
int lastRowIndex)
Create a sum formula
|
static void |
mergeX(ExcelOldCellModel oldCellModel,
org.apache.poi.ss.usermodel.Sheet sheet,
org.apache.poi.ss.usermodel.Row row,
boolean allowMergeEmpty,
int colIndex,
Object cellValue,
int colSize,
boolean toMerge)
Horizontal merge
You need to make sure that the ExcelOldCellModel object is a singleton on each line, or is written out at once
|
static void |
mergeY(Map<Integer,ExcelOldRowModel> oldRowModelMap,
org.apache.poi.ss.usermodel.Sheet sheet,
org.apache.poi.ss.usermodel.Row row,
boolean allowMergeEmpty,
int index,
int colIndex,
Object cellValue,
int dataSize,
boolean toMerge)
Vertical merge
OldRowModelMap should be global, with minimum partitioning to each export
|
static void |
setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value)
Set cell value
|
public static void setCellValue(org.apache.poi.ss.usermodel.Cell cell,
Object value)
cell - Current cellvalue - Attribute valuespublic static void addDropdownBox(String[] combobox, boolean showErrorBox, Rank errorBoxRank, String errorTitle, String errorContent, org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.Sheet sheet, int firstRow, int lastRow, int colIndex, String[] values)
combobox - Dropdown box content of 25 or lessshowErrorBox - Whether show error boxerrorBoxRank - Error box rankerrorTitle - Error box titleerrorContent - Error box valueworkbook - Current workbooksheet - Current sheetfirstRow - Start rowlastRow - End rowcolIndex - Column indexvalues - The dropdown box can be large, but if it's version 07, it's limited by the window size in the Excel annotationExcelpublic static void addDateValid(OperatorType operatorType, String expr1, String expr2, String pattern, org.apache.poi.ss.usermodel.Sheet sheet, int firstRow, int lastRow, int colIndex, boolean showErrorBox, Rank errorBoxRank, String errorTitle, String errorContent, boolean showTip, String tipTitle, String tipContent)
operatorType - operatorTypeexpr1 - Date expression 1, such as: 2019-12-12expr2 - Date expression 2(Only operation types between and notBetween are required),such as:2019-12-24pattern - Date patternsheet - Current sheetfirstRow - Start rowlastRow - End rowcolIndex - Column indexshowErrorBox - Whether show error boxerrorBoxRank - Error box rankerrorTitle - Error box titleerrorContent - Error box valueshowTip - Whether show tiptipContent - Tip contenttipTitle - Tip titlepublic static void addNumericValid(ValidType validType, OperatorType operatorType, String expr1, String expr2, org.apache.poi.ss.usermodel.Sheet sheet, int firstRow, int lastRow, int colIndex, boolean showErrorBox, Rank errorBoxRank, String errorTitle, String errorContent, boolean showTip, String tipTitle, String tipContent)
validType - validTypeoperatorType - operatorTypeexpr1 - Expression 1, such as: 1expr2 - Expression 2(Only operation types between and notBetween are required),such as:2sheet - Current sheetfirstRow - Start rowlastRow - End rowcolIndex - Column indexshowErrorBox - Whether show error boxerrorBoxRank - Error box rankerrorTitle - Error box titleerrorContent - Error box valueshowTip - Whether show tiptipContent - Tip contenttipTitle - Tip titlepublic static void addRepeatValid(org.apache.poi.ss.usermodel.Sheet sheet,
int firstRow,
int lastRow,
int colIndex,
boolean showErrorBox,
Rank errorBoxRank,
String errorTitle,
String errorContent)
sheet - Current sheetfirstRow - Start rowlastRow - End rowcolIndex - Column indexshowErrorBox - Whether show error boxerrorBoxRank - Error box rankerrorTitle - Error box titleerrorContent - Error box valuepublic static void addCustomValid(String formula, org.apache.poi.ss.usermodel.Sheet sheet, int firstRow, int lastRow, int colIndex, boolean showErrorBox, Rank errorBoxRank, String errorTitle, String errorContent)
formula - Check formulasheet - Current sheetfirstRow - Start rowlastRow - End rowcolIndex - Column indexshowErrorBox - Whether show error boxerrorBoxRank - Error box rankerrorTitle - Error box titleerrorContent - Error box valuepublic static void mergeY(Map<Integer,ExcelOldRowModel> oldRowModelMap, org.apache.poi.ss.usermodel.Sheet sheet, org.apache.poi.ss.usermodel.Row row, boolean allowMergeEmpty, int index, int colIndex, Object cellValue, int dataSize, boolean toMerge)
oldRowModelMap - oldRowModelMapsheet - Current sheetrow - Current rowindex - The data index, table header, and body all start at 0dataSize - Excel head data size or body data size,colIndex - Current col indexcellValue - Current cell valueallowMergeEmpty - Whether is allow merge emptytoMerge - Whether is to mergepublic static void mergeX(ExcelOldCellModel oldCellModel, org.apache.poi.ss.usermodel.Sheet sheet, org.apache.poi.ss.usermodel.Row row, boolean allowMergeEmpty, int colIndex, Object cellValue, int colSize, boolean toMerge)
oldCellModel - oldCellModelsheet - Current sheetrow - Current rowcolIndex - Current col indexcellValue - Current cell valuecolSize - Total colallowMergeEmpty - Whether is allow merge emptytoMerge - Whether is to mergepublic static String createSumFormula(int firstColIndex, int firstRowIndex, int lastColIndex, int lastRowIndex)
firstColIndex - Which column startfirstRowIndex - Which row startlastColIndex - Which column endlastRowIndex - Which row endpublic static String createFormula(String suffix, int firstColIndex, int firstRowIndex, int lastColIndex, int lastRowIndex)
suffix - Formula suffixfirstColIndex - Which column startfirstRowIndex - Which row startlastColIndex - Which column endlastRowIndex - Which row endCopyright © 2020. All rights reserved.