Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy paste dropdown data from excel to angular material table (or import excel) and convert it to dropdown

I was trying to enhance the following example to support the dropdown values in the angular material table when the dataset is copy-pasted from excel.

If Copy/paste doesn't work is there any way I can import the excel which carries my dropdown data?

There are two ways we can add a data list in excel:

1. Using the reference range

enter image description here

2. Typing source in the data-validation itself.

enter image description here

I do have the following example in stackblitz which works with normal copy-paste data.

https://stackblitz.com/edit/angular-copy-paste-table-from-excel

I am looking for help that how I can enhance this program to support the dropdown copy paste from excel to the angular material table.

How I can pass dropdown values to the angular material table?

Expected Result:

When copied all datasets given in the below picture, the angular material table should create test1 first value as a dropdown and test2 as a normal dataset.

enter image description here

I got one solution to make column values to dropdown but I am still looking for solutions to create a dropdown list directly from the range given in the excel.

like image 266
a.p. patel Avatar asked Feb 01 '21 22:02

a.p. patel


Video Answer


1 Answers

Here is what I have tried:

  • Only the first column is dropdown, there has to be some specific condition to identify this.
  • Dropdown is created using the used values for the first column (only those which appear in the data).

Here is the link

https://stackblitz.com/edit/angular-copy-paste-table-from-excel-vbnzal?file=src/app/app.component.html

Since the dropdown in the excel is validations and those are separate from the data it's hard to get those values unless you are using some API to read the excel file.

like image 62
Nikhil Walvekar Avatar answered Oct 17 '22 11:10

Nikhil Walvekar