From 74e0de2bf76e7cb0fe10a52e1aea12fa271928f1 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Mon, 11 Aug 2025 10:15:25 +0000 Subject: [PATCH 1/4] Added new kb article spreadprocessing-list-data-validation-cell-range --- ...cessing-list-data-validation-cell-range.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 knowledge-base/spreadprocessing-list-data-validation-cell-range.md diff --git a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md new file mode 100644 index 00000000..6dc47182 --- /dev/null +++ b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md @@ -0,0 +1,93 @@ +--- +title: Setting List DataValidation Rule to Reference Cell Range in SpreadProcessing +description: Learn how to set up List Data Validation rules in Telerik Document Processing's SpreadProcessing library to reference a cell range instead of using a comma-delimited list. +type: how-to +page_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing +meta_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing +slug: spreadprocessing-list-data-validation-cell-range +tags: spreadprocessing, datavalidation, listdatavalidationrule, cellrange, telerik-document-processing +res_type: kb +ticketid: 1695747 +--- + +## Environment + + + + + + + + + + + + +
Product SpreadProcessing for Telerik Document Processing
Version 2025.2.521
+ +## Description + +I want to set a List DataValidation rule in the SpreadProcessing library that uses a cell range as the validation source instead of a comma-delimited list of values. This avoids the 256-character limit imposed by Excel for comma-separated values. How can I achieve this? + +This knowledge base article also answers the following questions: +- How to define validation rules with a cell range in SpreadProcessing? +- How to bypass the character limit in validation rules by using cell ranges? +- How to set up list validation using cell ranges in Telerik's SpreadProcessing? + +## Solution + +To set a List DataValidation rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: + +1. Import the workbook using the `XlsxFormatProvider`. +2. Specify the cell where the validation rule will apply using `CellIndex`. +3. Define the validation parameters, including the cell range for allowed values. +4. Create and assign the `ListDataValidationRule` to the target cell. +5. Export the updated workbook. + +Here is an example: + +```csharp +// Import the workbook +Workbook workbook; +IWorkbookFormatProvider xlsxFormatProvider = new XlsxFormatProvider(); + +using (Stream input = new FileStream("input.xlsx", FileMode.Open)) +{ + workbook = xlsxFormatProvider.Import(input, TimeSpan.FromSeconds(10)); +} + +// Access the worksheet +var worksheet = workbook.Worksheets[0]; + +// Define the cell to apply validation +CellIndex dataValidationRuleCellIndex = new CellIndex(4, 4); + +// Configure the validation rule context +ListDataValidationRuleContext context = new ListDataValidationRuleContext(worksheet, dataValidationRuleCellIndex); +context.InputMessageTitle = "Restricted input"; +context.InputMessageContent = "The input is restricted to the week days."; +context.ErrorStyle = ErrorStyle.Stop; +context.ErrorAlertTitle = "Wrong value"; +context.ErrorAlertContent = "The entered value is not valid. Allowed values are the week days!"; +context.InCellDropdown = true; + +// Set the cell range as the validation source +context.Argument1 = "=$A$1:$A$26"; + +// Create and apply the validation rule +ListDataValidationRule rule = new ListDataValidationRule(context); +worksheet.Cells[dataValidationRuleCellIndex].SetDataValidationRule(rule); + +// Export the workbook +string xlsxOutputPath = "output.xlsx"; +using (Stream output = new FileStream(xlsxOutputPath, FileMode.Create)) +{ + xlsxFormatProvider.Export(workbook, output, TimeSpan.FromSeconds(10)); +} +``` + +## See Also + +- [Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#data-validation) +- [List Rule](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) +- [SpreadProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) From ee473df5c9c360f5a014ce668aec21dc8c0c5aee Mon Sep 17 00:00:00 2001 From: "PROGRESS\\ykaraman" Date: Tue, 16 Sep 2025 15:07:51 +0300 Subject: [PATCH 2/4] Polished KB --- ...cessing-list-data-validation-cell-range.md | 50 ++++++++----------- .../features/data-validation.md | 3 +- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md index 6dc47182..a16a2e20 100644 --- a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md +++ b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md @@ -1,33 +1,23 @@ ---- -title: Setting List DataValidation Rule to Reference Cell Range in SpreadProcessing -description: Learn how to set up List Data Validation rules in Telerik Document Processing's SpreadProcessing library to reference a cell range instead of using a comma-delimited list. -type: how-to -page_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing -meta_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing -slug: spreadprocessing-list-data-validation-cell-range -tags: spreadprocessing, datavalidation, listdatavalidationrule, cellrange, telerik-document-processing -res_type: kb -ticketid: 1695747 +--- +title: Setting List DataValidation Rule to Reference Cell Range in SpreadProcessing +description: Learn how to set up List Data Validation rules in Telerik Document Processing's SpreadProcessing library to reference a cell range instead of using a comma-delimited list. +type: how-to +page_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing +meta_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing +slug: spreadprocessing-list-data-validation-cell-range +tags: spreadprocessing, data, validation, list, data,validation, rule, cell, range, telerik, document, processing, libraries +res_type: kb +ticketid: 1695747 --- -## Environment - - - - - - - - - - - - -
Product SpreadProcessing for Telerik Document Processing
Version 2025.2.521
+# Environment +| Version | Product | Author | +| --- | --- | ---- | +| 2025.3.806 | RadSpreadProcessing |[Yoan Karamanov](https://www.telerik.com/blogs/author/yoan-karamanov)| ## Description -I want to set a List DataValidation rule in the SpreadProcessing library that uses a cell range as the validation source instead of a comma-delimited list of values. This avoids the 256-character limit imposed by Excel for comma-separated values. How can I achieve this? +This article describes how to set a [List Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) rule in the [SpreadProcessing](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) library that uses a cell range as the validation source instead of a comma-delimited list of values. This avoids the 256-character limit imposed by Excel for comma-separated values. This knowledge base article also answers the following questions: - How to define validation rules with a cell range in SpreadProcessing? @@ -36,7 +26,7 @@ This knowledge base article also answers the following questions: ## Solution -To set a List DataValidation rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: +To set a [List Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: 1. Import the workbook using the `XlsxFormatProvider`. 2. Specify the cell where the validation rule will apply using `CellIndex`. @@ -86,8 +76,8 @@ using (Stream output = new FileStream(xlsxOutputPath, FileMode.Create)) } ``` -## See Also +# See Also -- [Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#data-validation) -- [List Rule](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) -- [SpreadProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) +* [Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#data-validation) +* [List Rule](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) +* [SpreadProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) diff --git a/libraries/radspreadprocessing/features/data-validation.md b/libraries/radspreadprocessing/features/data-validation.md index abfadacb..220bfca9 100644 --- a/libraries/radspreadprocessing/features/data-validation.md +++ b/libraries/radspreadprocessing/features/data-validation.md @@ -377,4 +377,5 @@ __Example 11__ demonstrates how to evaluate a rule using the __Evaluate()__ meth * [Protection]({%slug radspreadprocessing-features-protection-workbook%}) * [Formulas]({%slug radspreadprocessing-features-formulas-general-information%}) -* [Adding a ComboBox to an Excel File Using RadSpreadProcessing]({%slug adding-combobox-to-excel-file-radspreadprocessing%}) \ No newline at end of file +* [Adding a ComboBox to an Excel File Using RadSpreadProcessing]({%slug adding-combobox-to-excel-file-radspreadprocessing%}) +* [Setting List DataValidation Rule to Reference Cell Range in SpreadProcessing]({%slug spreadprocessing-list-data-validation-cell-range%}) \ No newline at end of file From f62654734d51894b62e88320d5ffbdf1ab64a36c Mon Sep 17 00:00:00 2001 From: "PROGRESS\\ykaraman" Date: Wed, 17 Sep 2025 15:13:50 +0300 Subject: [PATCH 3/4] Adressed comments. --- ...cessing-list-data-validation-cell-range.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md index a16a2e20..7748b0ef 100644 --- a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md +++ b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md @@ -5,7 +5,7 @@ type: how-to page_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing meta_title: Creating List Data Validation Rules Using Cell Ranges in SpreadProcessing slug: spreadprocessing-list-data-validation-cell-range -tags: spreadprocessing, data, validation, list, data,validation, rule, cell, range, telerik, document, processing, libraries +tags: spreadprocessing, list, data, validation, rule, cell, range, telerik, document, processing, libraries res_type: kb ticketid: 1695747 --- @@ -17,7 +17,7 @@ ticketid: 1695747 ## Description -This article describes how to set a [List Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) rule in the [SpreadProcessing](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) library that uses a cell range as the validation source instead of a comma-delimited list of values. This avoids the 256-character limit imposed by Excel for comma-separated values. +This article describes how to set a [List Data Validation]({%slug radspreadprocessing-features-data-validation%}#list-rule) rule in the [SpreadProcessing]({%slug radspreadprocessing-overview%}) library that uses a cell range as the validation source instead of a comma-delimited list of values. This avoids the 256-character limit imposed by Excel for comma-separated values. This knowledge base article also answers the following questions: - How to define validation rules with a cell range in SpreadProcessing? @@ -26,13 +26,13 @@ This knowledge base article also answers the following questions: ## Solution -To set a [List Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: +To set a [List Data Validation]({%slug radspreadprocessing-features-data-validation%}#list-rule) rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: -1. Import the workbook using the `XlsxFormatProvider`. -2. Specify the cell where the validation rule will apply using `CellIndex`. +1. Import the workbook using the [`XlsxFormatProvider`]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). +2. Specify the cell where the validation rule will apply using [`CellIndex`]({%slug radspreadprocessing-working-with-cells-accessing-cells-of-worksheet%}#accessing-cells-of-a-worksheet). 3. Define the validation parameters, including the cell range for allowed values. -4. Create and assign the `ListDataValidationRule` to the target cell. -5. Export the updated workbook. +4. Create and assign the [`ListDataValidationRule`]({%slug radspreadprocessing-features-data-validation%}#list-rule) to the target cell. +5. Export the updated workbook using the [`XlsxFormatProvider`]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). Here is an example: @@ -78,6 +78,6 @@ using (Stream output = new FileStream(xlsxOutputPath, FileMode.Create)) # See Also -* [Data Validation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#data-validation) -* [List Rule](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/data-validation#list-rule) -* [SpreadProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) +* [Data Validation]({%slug radspreadprocessing-features-data-validation%}#data-validation) +* [List Rule]({%slug radspreadprocessing-features-data-validation%}#list-rule) +* [SpreadProcessing Overview]({%slug radspreadprocessing-overview%}) From a21795495854fcdf92b92ba3bcca6543eb77afa3 Mon Sep 17 00:00:00 2001 From: "PROGRESS\\ykaraman" Date: Thu, 18 Sep 2025 16:20:24 +0300 Subject: [PATCH 4/4] Removed formatting from links. --- ...spreadprocessing-list-data-validation-cell-range.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md index 7748b0ef..e522b739 100644 --- a/knowledge-base/spreadprocessing-list-data-validation-cell-range.md +++ b/knowledge-base/spreadprocessing-list-data-validation-cell-range.md @@ -26,13 +26,13 @@ This knowledge base article also answers the following questions: ## Solution -To set a [List Data Validation]({%slug radspreadprocessing-features-data-validation%}#list-rule) rule that references a cell range, use the `ListDataValidationRule` and specify the cell range as the `Argument1`. Follow the steps below: +To set a [List Data Validation]({%slug radspreadprocessing-features-data-validation%}#list-rule) rule that references a cell range, use the **ListDataValidationRule** and specify the cell range as the **Argument1**. Follow the steps below: -1. Import the workbook using the [`XlsxFormatProvider`]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). -2. Specify the cell where the validation rule will apply using [`CellIndex`]({%slug radspreadprocessing-working-with-cells-accessing-cells-of-worksheet%}#accessing-cells-of-a-worksheet). +1. Import the workbook using the [XlsxFormatProvider]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). +2. Specify the cell where the validation rule will apply using [CellIndex]({%slug radspreadprocessing-working-with-cells-accessing-cells-of-worksheet%}#accessing-cells-of-a-worksheet). 3. Define the validation parameters, including the cell range for allowed values. -4. Create and assign the [`ListDataValidationRule`]({%slug radspreadprocessing-features-data-validation%}#list-rule) to the target cell. -5. Export the updated workbook using the [`XlsxFormatProvider`]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). +4. Create and assign the [ListDataValidationRule]({%slug radspreadprocessing-features-data-validation%}#list-rule) to the target cell. +5. Export the updated workbook using the [XlsxFormatProvider]({%slug radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider%}). Here is an example: