/** * Public function which removes any data validation, if present */ public virtual void removeDataValidation() { if (!dataValidation) { return; } // If the data validation is shared, then generate a warning DVParser dvp = getDVParser(); if (dvp.extendedCellsValidation()) { //logger.warn("Cannot remove data validation from " + // CellReferenceHelper.getCellReference(writableCell) + // " as it is part of the shared reference " + // CellReferenceHelper.getCellReference(dvp.getFirstColumn(), // dvp.getFirstRow()) + // "-" + // CellReferenceHelper.getCellReference(dvp.getLastColumn(), // dvp.getLastRow())); return; } // Remove the validation from the WritableSheet object if present writableCell.removeDataValidation(); clearValidationSettings(); }
/** * Clears out any existing validation settings */ private void clearValidationSettings() { validationSettings = null; dvParser = null; dropDown = false; comboBox = null; dataValidation = false; }
/** * Initializes the dvParser */ private void initialize() { if (dvParser == null) { dvParser = new DVParser(data, externalSheet, workbook, workbookSettings); } }
/** * Sets the data validation based upon a named range */ public virtual void setDataValidationRange(string namedRange) { if (dataValidation && getDVParser().extendedCellsValidation()) { //logger.warn("Cannot set data validation on " + // CellReferenceHelper.getCellReference(writableCell) + // " as it is part of a shared data validation"); return; } clearValidationSettings(); dvParser = new DVParser(namedRange); dropDown = true; dataValidation = true; }
/** * Sets the data validation based upon a numerical condition */ public virtual void setNumberValidation(double val, ValidationCondition c) { if (dataValidation && getDVParser().extendedCellsValidation()) { //logger.warn("Cannot set data validation on " + // CellReferenceHelper.getCellReference(writableCell) + // " as it is part of a shared data validation"); return; } clearValidationSettings(); dvParser = new DVParser(val, System.Double.NaN, c.getCondition()); dropDown = false; dataValidation = true; }
/** * Gets the range of cells to which the data validation applies. If the * validation applies to just this cell, this will be reflected in the * returned range * * @return the range to which the same validation extends, or NULL if this * cell doesn't have a validation */ public virtual Range getSharedDataValidationRange() { if (!dataValidation) { return(null); } DVParser dvp = getDVParser(); return(new SheetRangeImpl(writableCell.getSheet(), dvp.getFirstColumn(), dvp.getFirstRow(), dvp.getLastColumn(), dvp.getLastRow())); }
/** * Use the same data validation logic as the specified cell features * * @param cf the data validation to reuse */ public void shareDataValidation(BaseCellFeatures source) { if (dataValidation) { //logger.warn("Attempting to share a data validation on cell " + // CellReferenceHelper.getCellReference(writableCell) + // " which already has a data validation"); return; } clearValidationSettings(); dvParser = source.getDVParser(); validationSettings = null; dataValidation = true; dropDown = source.dropDown; comboBox = source.comboBox; }
/** * Gets the dv parser */ public DVParser getDVParser() { // straightforward - this was created as a writable cell if (dvParser != null) { return(dvParser); } // this was copied from a readable cell, and then copied again if (validationSettings != null) { dvParser = new DVParser(validationSettings.getDVParser()); return(dvParser); } return(null); // keep the compiler happy }
/** * Copy constructor * * @param the cell to copy */ public BaseCellFeatures(BaseCellFeatures cf) { // The comment stuff comment = cf.comment; commentWidth = cf.commentWidth; commentHeight = cf.commentHeight; // The data validation stuff. dropDown = cf.dropDown; dataValidation = cf.dataValidation; validationSettings = cf.validationSettings; // ? if (cf.dvParser != null) { dvParser = new DVParser(cf.dvParser); } }
/** * Constructor called when doing a cell deep copy */ public DVParser(DVParser copy) { wasCopied = true; type = copy.type; errorStyle = copy.errorStyle; condition = copy.condition; stringListGiven = copy.stringListGiven; emptyCellsAllowed = copy.emptyCellsAllowed; suppressArrow = copy.suppressArrow; showPrompt = copy.showPrompt; showError = copy.showError; promptTitle = copy.promptTitle; promptText = copy.promptText; errorTitle = copy.errorTitle; errorText = copy.errorText; hasExtendedCellsValidation = copy.extendedCellsValidation(); row1 = copy.row1; row2 = copy.row2; column1 = copy.column1; column2 = copy.column2; // Don't copy the formula parsers - just take their string equivalents if (copy.formula1String != null) { formula1String = copy.formula1String; formula2String = copy.formula2String; } else { try { formula1String = copy.formula1.getFormula(); formula2String = (copy.formula2 != null) ? copy.formula2.getFormula() : null; } catch (FormulaException e) { //logger.warn("Cannot parse validation formula: " + e.Message); } } // Don't copy the cell references - these will be added later }
internal ValidationCondition(DVParser.Condition c) { condition = c; ValidationCondition[] oldtypes = types; types = new ValidationCondition[oldtypes.Length + 1]; System.Array.Copy(oldtypes,0,types,0,oldtypes.Length); types[oldtypes.Length] = this; }
public virtual void setNumberValidation(double val1, double val2, ValidationCondition c) { if (dataValidation && getDVParser().extendedCellsValidation()) { //logger.warn("Cannot set data validation on " + // CellReferenceHelper.getCellReference(writableCell) + // " as it is part of a shared data validation"); return; } clearValidationSettings(); dvParser = new DVParser(val1,val2,c.getCondition()); dropDown = false; dataValidation = true; }
/** * Gets the dv parser */ public DVParser getDVParser() { // straightforward - this was created as a writable cell if (dvParser != null) { return dvParser; } // this was copied from a readable cell, and then copied again if (validationSettings != null) { dvParser = new DVParser(validationSettings.getDVParser()); return dvParser; } return null; // keep the compiler happy }
/** * Constructor called when the API creates a writable data validation * * @param dvsr the record copied from a writable sheet */ public DataValiditySettingsRecord(DVParser dvp) : base(Type.DV) { dvParser = dvp; }
/** * Initializes the dvParser */ private void initialize() { if (dvParser == null) { dvParser = new DVParser(data,externalSheet, workbook,workbookSettings); } }