Error while creating validation dropdown in spreadsheet using ColdFusion

后端 未结 2 579
执笔经年
执笔经年 2021-01-25 09:33

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

相关标签:
2条回答
  • 2021-01-25 10:00

    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.

    0 讨论(0)
  • 2021-01-25 10:08

    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)>
    
    0 讨论(0)
提交回复
热议问题