2

I have this code:

CellRangeAddressList addressListTax = new CellRangeAddressList(rowCount, rowCount, labelRowCnt, labelRowCnt);

DVConstraint dvConstraintTax = DVConstraint.createExplicitListConstraint(new String[]  { 

    "I0-Input Tax 0%", "I1-Input Tax 10% ", "I2-Input Tax 12%","IE-Input Tax Exempt",
    "J0-0% Input Tax,China ","J1-17% Input Tax,China ","J2-13% Input Tax,China  ",
    "J3-6% Input Tax,China","J4-4% Input Tax,China ","J5-3% Input Tax,China",
    "J6-7% Input Tax,China", "L1-5% Luxury Tax,China ", "O0-Zero-rated Sales ",
    "O1-Output Tax 10%  ","O2-Output Tax 12% ","OE-Output Tax Exempt ",
    "P0-Purchase Tax 0%  ","P1-Tax on Purchase 0%","P2-Tax on Purchases 5% ",
    "P3-Tax on Purchases 7%", "P4-Out of Scope purchase 0% ", "P5-Imported Purchase 0% ",
    "S0-Exempted Tax on Sales  ","S1-Tax on Sales 0% ","S2-Tax on Sales 5% ",
    "S3-7% GST  ","S3-Tax on Sales 7%","X0-0% Output Tax,China ","X0-China Output Tax 0%",
    "X1-17% Output Tax,China","X2-13% Output Tax,China"
});

HSSFDataValidation dataValidationTax = new HSSFDataValidation(addressListTax,dvConstraintTax);

dataValidationTax.setSuppressDropDownArrow(false);
sheet.addValidationData(dataValidationTax);

This throw error in Linux:

java.lang.IllegalArgumentException: String literals in formulas can't be bigger than 255 characters ASCII
11/08/03 13:36:58 java.lang.IllegalArgumentException: String literals in formulas can't be bigger than 255 characters ASCII
11/08/03 13:36:58    at myorg.apache.poi.hssf.record.formula.StringPtg.<init>(StringPtg.java:65)
11/08/03 13:36:58    at myorg.apache.poi.hssf.usermodel.DVConstraint.createListFormula(DVConstraint.java:413)
11/08/03 13:36:58    at myorg.apache.poi.hssf.usermodel.DVConstraint.createFormulas(DVConstraint.java:386)
11/08/03 13:36:58    at myorg.apache.poi.hssf.usermodel.HSSFDataValidation.createDVRecord(HSSFDataValidation.java:197)
11/08/03 13:36:58    at myorg.apache.poi.hssf.usermodel.HSSFSheet.addValidationData(HSSFSheet.java:378)
11/08/03 13:36:58    at com.DemoPxExcel.doAction(DemoPxExcel.java:217)
11/08/03 13:36:58    at com.ListRFQ.doAction(ListRFQ.java:198)
Danilo Piazzalunga
  • 7,590
  • 5
  • 49
  • 75
Raj
  • 255
  • 2
  • 6
  • 17

1 Answers1

2

I will assume you're actually looking for a solution to your issue, rather than having the obvious stated to you...

The workaround I figured out was to add the list of constrained items to a secondary sheet, protect the sheet, then refer to the range to pull the items: See the documentation on "Creating Data Validations From Spreadsheet Cells" at http://poi.apache.org/spreadsheet/quick-guide.html

I did this solution, added my list to a secondary sheet, then protected the sheet. Not sure what the limitation in Excel verions of pull-down size/items is, but it worked with a list size/content similar to yours.

Worked fine with poi3.7.

DaleD
  • 21
  • 1