}
int curr_dvRecNo = dvalRec.getDVRecNo();
dvalRec.setDVRecNo(curr_dvRecNo+1);
//create dv record
DVRecord dvRecord = new DVRecord();
//dv record's option flags
dvRecord.setDataType( obj_validation.getDataValidationType() );
dvRecord.setErrorStyle(obj_validation.getErrorStyle());
dvRecord.setEmptyCellAllowed(obj_validation.getEmptyCellAllowed());
dvRecord.setSurppresDropdownArrow(obj_validation.getSurppressDropDownArrow());
dvRecord.setShowPromptOnCellSelected(obj_validation.getShowPromptBox());
dvRecord.setShowErrorOnInvalidValue(obj_validation.getShowErrorBox());
dvRecord.setConditionOperator(obj_validation.getOperator());
//string fields
dvRecord.setStringField( DVRecord.STRING_PROMPT_TITLE,obj_validation.getPromptBoxTitle());
dvRecord.setStringField( DVRecord.STRING_PROMPT_TEXT, obj_validation.getPromptBoxText());
dvRecord.setStringField( DVRecord.STRING_ERROR_TITLE, obj_validation.getErrorBoxTitle());
dvRecord.setStringField( DVRecord.STRING_ERROR_TEXT, obj_validation.getErrorBoxText());
//formula fields ( size and data )
String str_formula = obj_validation.getFirstFormula();
FormulaParser fp = new FormulaParser(str_formula, workbook);
fp.parse();
Stack ptg_arr = new Stack();
Ptg[] ptg = fp.getRPNPtg();
int size = 0;
for (int k = 0; k < ptg.length; k++)
{
if ( ptg[k] instanceof org.apache.poi.hssf.record.formula.AreaPtg )
{
//we should set ptgClass to Ptg.CLASS_REF and explicit formula string to false
ptg[k].setClass(Ptg.CLASS_REF);
obj_validation.setExplicitListFormula(false);
}
size += ptg[k].getSize();
ptg_arr.push(ptg[k]);
}
dvRecord.setFirstFormulaRPN(ptg_arr);
dvRecord.setFirstFormulaSize((short)size);
dvRecord.setListExplicitFormula(obj_validation.getExplicitListFormula());
if ( obj_validation.getSecondFormula() != null )
{
str_formula = obj_validation.getSecondFormula();
fp = new FormulaParser(str_formula, workbook);
fp.parse();
ptg_arr = new Stack();
ptg = fp.getRPNPtg();
size = 0;
for (int k = 0; k < ptg.length; k++)
{
size += ptg[k].getSize();
ptg_arr.push(ptg[k]);
}
dvRecord.setSecFormulaRPN(ptg_arr);
dvRecord.setSecFormulaSize((short)size);
}
//dv records cell range field
HSSFCellRangeAddress cell_range = new HSSFCellRangeAddress();
cell_range.addADDRStructure(obj_validation.getFirstRow(), obj_validation.getFirstColumn(), obj_validation.getLastRow(), obj_validation.getLastColumn());
dvRecord.setCellRangeAddress(cell_range);
//add dv record
eofLoc = sheet.findFirstRecordLocBySid( EOFRecord.sid );
sheet.getRecords().add( eofLoc, dvRecord );
}