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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
public static DataValidation getDataValidationByFormula(XSSFSheet xssfSheet,String formulaString, int row, int col) { XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(xssfSheet); XSSFDataValidationConstraint dvConstraint =(XSSFDataValidationConstraint) dvHelper.createFormulaListConstraint(formulaString);
CellRangeAddressList regions = new CellRangeAddressList(1,65535, col, col); XSSFDataValidation data_validation_list =(XSSFDataValidation) dvHelper.createValidation(dvConstraint, regions); data_validation_list.setSuppressDropDownArrow(true); data_validation_list.setShowErrorBox(true); return data_validation_list; }
private static String getcellColumnFlag(int num) { String columFiled = ""; int chuNum = 0; int yuNum = 0; if (num >= 0 && num <= 25) { columFiled = doHandle(num); } else { chuNum = (num / 26)-1; yuNum = num % 26;
columFiled += doHandle(chuNum); columFiled += doHandle(yuNum); } return columFiled; } private static String doHandle(final int num) { String[] charArr = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; return charArr[num]; }
private static XSSFSheet setXSSFPrompt(XSSFSheet sheet, String textlist, XSSFCell cell) { XSSFDrawing patr = sheet.createDrawingPatriarch(); XSSFComment comment = patr.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short)4, 2, (short) 6, 5)); comment.setString(new XSSFRichTextString(textlist)); cell.setCellComment(comment);
return sheet; }
|