Hi,
I am exporting data from a table to excel file after that i have to make a excel column as dropdownlist using c#.
Thanks & Regards,
Rahul Rao .
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Shweta LodhaRank #31 · 39.8K reputationPosted Nov 28, 2014, 10:25 PM EST
Please have a look at this:
https://social.msdn.microsoft.com/Forums/office/en-US/8470cf52-c96e-4bc1-af98-6e98022bc77e/how-to-create-dropdownlist-in-excel-on-the-fly-in-c?forum=vsto
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Nov 28, 2014, 10:36 PM EST
Hi Rahul Rao,
Read these links it helps you
http://www.c-sharpcorner.com/UploadFile/kbpatel/how-to-create-a-dropdown-list-to-an-excel-using-C-Sharp/
http://www.c-sharpcorner.com/Blogs/7482/retrieving-excel-data-and-binding-to-a-combobox-in-C-Sharp.aspx
Jacke Elis36 reputationPosted Jan 21, 2015, 2:20 AM EST
Rahul try this:
DataTable table = ... // Create new excel file and insert a DataTable. var excel = new ExcelFile(); var sheet = excel.Worksheets.Add(table.TableName); sheet.InsertDataTable(table); // Cell(s) where the DropDownList(s) will be located. var listCells = sheet.Cells.GetSubrange("M1", "M1"); sheet.DataValidations.Add(new DataValidation(listCells) { Type = DataValidationType.List, // DropDownList values, as an example this one refers to column "C". Formula1 = "=$C:$C" }); excel.Save("Sample.xlsx");The code uses this C# library for excel files.
You can directly import your DataTables to excel in .NET and you can easily add DropDownList via DataValidation.