How can I change the cell data type and create dropdown dynamically

Hi,
I have data of different different data types. I want to Create Excel and change the cell datatype accordingly

@Amrinder_Singh,

Could you please share an Excel file to demonstrate your requirements, we will check it soon. You may use MS Excel to create your desired task manually and save to share it with us.

PS. please zip the Excel file prior attaching here.

Number.zip (6.8 KB)

Attached File will have the excel which will have columns 2nd column will be containing the data type and 3rd column will be containing answer. I want to convert answer cell’s data type based on the type in the second column.
For Dropdown after ; next value of dropdown should come. And number and date should not accept other values

@Amrinder_Singh,

Thanks for the sample file.

I am still not entirely sure about your requirements. Aspose.Cells automatically sets proper data type when you insert into the cells (see the document with example code on adding different types of data to cells for your reference). The best way to cope with proper data types if you are importing into the spreadsheets, you should convert a value to proper data type in code prior inserting or importing into the worksheet cells. You may also re-enter a value (if you have already placed/imported) using Cells.PutValue overload. This method has isCoverted Boolean parameter which will convert the value in the cell to suitable data type based on the value/data (if appropriate). See the sample line of code:
e.g.
cell.PutValue(cell.StringValue, true);

You may use List data validation for it, see the document on List data validation with example code for your reference.

Hope, this helps a bit.

Suppose I have number data type assigned if user enters value other than number, then it should not allow

@Amrinder_Singh,

Please see the detailed document with examples on data validation for your complete reference.
https://docs.aspose.com/cells/net/data-validation/

Hi,
I checked the linked you attached, But I want to do that dynamically I can have multiple cells with dropdown of different values. every time new cell which supposed to be dropdown comes will have new values for dropdown.
In the documentation we are create range and saving dropdown values in separate sheet. Yes we can do that its working also.
Problem comes when new cell comes with different value(value will be string (e.g 1;2;3) we will convert this by spliting based on ; and create list for dropdown ) I want to create new list for dropdown of this cell.

@Amrinder_Singh,
Would you like to provide a sample file? Include the desired results in the sample file. Once we receive the sample file, we will analyze and provide feedback soon.

Hi, My Previous Query is solved. But is there option like I can multiselect values from dropdown?
I have attached the excel file for required output for you to check.
Number.zip (8.3 KB)

@Amrinder_Singh,

As you may have found, for validation it is impossible to select multiple items in ms excel. So, if you want to implement by it for your requirement, we think you need to split and list all combinations of the input values into separate cells, then you may get the dropdown like:
4
4,5
4,5,6
4,6
5
5,6
6

As another solution, we think you may try the form control such as ListBox. This control allows you set the SelectionType as multiple. In program with apis of Aspose.Cells it is easy for you to get those items that have been selected( SelectedCells) and output them to any cell. However, if you need to interact the control in ms excel and make the selected items show in one specified cell, we are afraid it is impossible.

If those scenarios are not what you want to show in your provided excel file, please implement you requirement in ms excel manually and show us the steps you want to process. We will evaluate and try to provide solution. If some kind of operations or requirements cannot be implemented in ms excel manually, we are afraid it is impossible for us to create such one excel file either.