File tree Expand file tree Collapse file tree 5 files changed +64
-0
lines changed
Data Validation/UserDefinedValidation/.NET/UserDefinedValidation Expand file tree Collapse file tree 5 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ <Solution >
2+ <Project Path =" UserDefinedValidation/UserDefinedValidation.csproj" />
3+ </Solution >
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using Syncfusion . XlsIO ;
3+
4+ namespace UserDefinedValidation
5+ {
6+ class Program
7+ {
8+ static void Main ( string [ ] args )
9+ {
10+ using ( ExcelEngine excelEngine = new ExcelEngine ( ) )
11+ {
12+ IApplication application = excelEngine . Excel ;
13+ application . DefaultVersion = ExcelVersion . Xlsx ;
14+ IWorkbook workbook = application . Workbooks . Open ( Path . GetFullPath ( @"Data/InputTemplate.xlsx" ) ) ;
15+ IWorksheet worksheet = workbook . Worksheets [ 0 ] ;
16+
17+ //Data validation for the user-defined list
18+ IDataValidation validation = worksheet . Range [ "C3" ] . DataValidation ;
19+ validation . AllowType = ExcelDataType . User ;
20+ validation . FirstFormula = "=Sheet1!$B$1:$B$3" ;
21+ worksheet . Range [ "C1" ] . Text = "Data Validation List in C3" ;
22+ worksheet . Range [ "C1" ] . AutofitColumns ( ) ;
23+
24+ //Shows the error message
25+ validation . ErrorBoxText = "Choose the value from the list" ;
26+ validation . ErrorBoxTitle = "ERROR" ;
27+ validation . PromptBoxText = "Data validation for user-defined list" ;
28+ validation . IsPromptBoxVisible = true ;
29+ validation . ShowPromptBox = true ;
30+
31+ #region Save
32+ //Saving the workbook
33+ workbook . SaveAs ( Path . GetFullPath ( @"Output/ListValidation.xlsx" ) ) ;
34+ #endregion
35+ }
36+ }
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net10.0</TargetFramework >
6+ <ImplicitUsings >enable</ImplicitUsings >
7+ <Nullable >enable</Nullable >
8+ </PropertyGroup >
9+
10+ <ItemGroup >
11+ <PackageReference Include =" Syncfusion.XlsIO.Net.Core" Version =" *" />
12+ </ItemGroup >
13+
14+ <ItemGroup >
15+ <None Update =" Output\*" >
16+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
17+ </None >
18+ <None Update =" Data\*" >
19+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
20+ </None >
21+ </ItemGroup >
22+
23+ </Project >
You can’t perform that action at this time.
0 commit comments