[Excel Package] New action - Cell_AddListValidationRange

Forge Component
Published on 2018-08-02 by Carlos Alfaro
5 votes
Published on 2018-08-02 by Carlos Alfaro

Add a drop down to cell range with data source from dataset range

/// <param name="ssWorksheet"></param>

/// <param name="ssCellRange">Examples: A2, B1, D3, I2:I6...</param>

/// <param name="ssDataSetRange">Other sheet formula example: "'Credores Hipotecários'!$F$2:$F$902"</param>

/// <param name="ssErrorTitle"></param>

/// <param name="ssErrorMessage"></param>

        /// <param name="ssShowErrorMessage"></param>

public void MssCell_AddListValidationRange(object ssWorksheet, string ssCellRange, string ssDataSetRange, string ssErrorTitle, string ssErrorMessage, bool ssShowErrorMessage) {

            ExcelWorksheet ws = (ExcelWorksheet)ssWorksheet;

            var validation = ws.DataValidations.AddListValidation(ssCellRange);

            validation.ShowErrorMessage = ssShowErrorMessage;

            validation.ErrorTitle = ssErrorTitle;

            validation.Error = ssErrorMessage;

            validation.Formula.ExcelFormula = ssDataSetRange;

} // MssCell_AddListValidationRange