简体   繁体   中英

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

在此处输入图像描述

2. Typing source in the data-validation itself.

在此处输入图像描述

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.

在此处输入图像描述

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM