I am just creating a validation dropdown in a spreadsheet, from a database query, using ColdFusion. But I am getting the following error
\"string literals
The error message is pretty clear. Some of the values you are trying to add to the validation list are longer than the maximum length allowed by Excel, 255 characters. Either shorten the values or maybe try this suggestion of using hidden ranges to work around the limitation.
Not sure if this is any help. This will give you a very basic yes or no dropdown list in a cell
Please Note...this is for xssf NOT hssf (.xlsx file format)
<!--- Create an instance of a new spreadsheet --->
<cfset local.spreadsheet = spreadsheetNew("My Spreadsheet", true)>
<!--- we need all this so we can have dropdowns --->
<cfset local.workbook = local.spreadsheet.getWorkBook()>
<cfset local.worksheet = local.workbook.getSheet("My Spreadsheet")>
<cfset local.dataValidationConstraint = createObject("java","org.apache.poi.xssf.usermodel.XSSFDataValidationConstraint")>
<cfset local.cellRangeList = createObject("java","org.apache.poi.ss.util.CellRangeAddressList")>
<cfset local.dataValidationHelper = createObject("java","org.apache.poi.xssf.usermodel.XSSFDataValidationHelper").init(local.worksheet)>
<!--- Define cell list rowstart, rowend, column start, column end --->
<cfset local.list = local.cellRangeList.init(0, 1, 1, 1)>
<cfset local.dvconstraint = local.dataValidationHelper.createExplicitListConstraint(["YES","NO"])>
<cfset local.dataValidation = local.dataValidationHelper.createValidation(local.dvconstraint, local.list)>
<cfset local.dataValidation.setSuppressDropDownArrow(true)>
<!--- add it to the spreadsheet --->
<cfset local.worksheet.addValidationData(dataValidation)>