POI does not limit the length of the entered constraints, all values
are written as a comma-separated list.

You can help us to research the problem.

Create two simple files: one created programmatically with POI and the
other manually in Excel . Then unzip the files and compare sheet data
( /xl/worksheets/sheet1.xml relative to the package root). You should
see the data validation entries and figure out why POI does it wrong.
It looked at the code and at first glance everything is good on the
POI side: there are no hardcoded limits, etc. Comparison with a valid
.xlsx file should shed a light on what's wrong.

Yegor

On Wed, Jan 18, 2012 at 5:00 PM, jamshid <[email protected]> wrote:
> After that I have tried with XSSFWorkBook with this code:
>
> XSSFWorkbook wb = new XSSFWorkbook();
> XSSFSheet sheet = wb.createSheet("new sheet");
> DataValidationHelper validationHelper = new XSSFDataValidationHelper(sheet);
> DataValidationConstraint constraint =
> validationHelper.createExplicitListConstraint(getCountries());
> CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
> DataValidation dataValidation =
> validationHelper.createValidation(constraint, addressList);
> dataValidation.setErrorStyle(DataValidation.ErrorStyle.STOP);
> dataValidation.setSuppressDropDownArrow(true);
> sheet.addValidationData(dataValidation);
> FileOutputStream fileOut = new FileOutputStream("c:\\test.xlsx");
>
> Unfortunately, no success with such result which is comma delimenated long
> string in one cell:
>
> [image: enter image description here]
>
> But manually in excel, I can create dropdown cells with long this country
> list.
> Is there any way generate dropdown with long strings, or API does not
> support?
>
> On Wed, Jan 18, 2012 at 3:25 AM, jamshid [via Apache POI] <
> [email protected]> wrote:
>
>> Hi, thank you for quick reply
>> Sorry I confused giving explanation because I've done with XSSF in that
>> time I got comma deliminated String but when I do it with HSSF I'm getting
>> *String literals in formulas can't be bigger than 255 characters ASCII*
>> for this code:
>>
>> try {
>>     HSSFWorkbook wb = new HSSFWorkbook();
>>     HSSFSheet sheet = wb.createSheet("new sheet");
>>     HSSFRow row = sheet.createRow((short) 0);
>>     //CellRangeAddressList from org.apache.poi.ss.util package
>>     CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0,
>> 0);
>>     DVConstraint dvConstraint =
>> DVConstraint.createExplicitListConstraint(getCountries());
>>     DataValidation dataValidation = new HSSFDataValidation(addressList,
>> dvConstraint);
>>     dataValidation.setSuppressDropDownArrow(false);
>>     sheet.addValidationData(dataValidation);
>>     FileOutputStream fileOut = new FileOutputStream("c:\\test.xls");
>>     wb.write(fileOut);
>>     fileOut.close();
>>     } catch (IOException e) {
>>        e.printStackTrace();
>>   }
>>
>>
>> http://stackoverflow.com/questions/8655185/limitation-while-generating-excel-drop-down-list-with-apache-poi
>>
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://apache-poi.1045710.n5.nabble.com/Problem-creating-an-excel-cell-with-Drop-Down-Lists-tp5151878p5153136.html
>>  To unsubscribe from Problem creating an excel cell with Drop Down Lists, 
>> click
>> here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5151878&code=amFtc2hpZC5hc2F0aWxsYXlldkBnbWFpbC5jb218NTE1MTg3OHwxODU3MDg5MTI2>
>> .
>> NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
> --
> View this message in context: 
> http://apache-poi.1045710.n5.nabble.com/Problem-creating-an-excel-cell-with-Drop-Down-Lists-tp5151878p5154747.html
> Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to