using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NPOI
{
class Program
{
static void Main(string[] args)
{
//Create workbook
IWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet("sheet");
//Create dropdown list
IDataValidationHelper validationHelper = new XSSFDataValidationHelper(sheet);
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
IDataValidationConstraint constraint = validationHelper.CreateExplicitListConstraint(new String[] { "One", "Two", "Three", "Four" });
IDataValidation dataValidation = validationHelper.CreateValidation(constraint, addressList);
dataValidation.SuppressDropDownArrow = true;
sheet.AddValidationData(dataValidation);
//Save the file
FileStream file = File.Create("ExcelDropdownList.xlsx");
workbook.Write(file);
file.Close();
//Launch the file
System.Diagnostics.Process.Start("ExcelDropdownList.xlsx");
}
}
}