简体   繁体   中英

How to extract data from an XLS file and put it into a 2D array javascript

Javascript的新手,想知道如何从excel文件中提取数据并将其放入javascript中的2D数组中,对您的帮助将不胜感激!

CSV seems to be a most "programmable" option, but you might get away with creating a column of javascript statements next to your data:

| A   | B      | C      | D                                    |
| 123 | abcdef | 999.99 | myArray.push([123,'abcdef',999.99]); |
| 456 | ghijkl | 123.99 | myArray.push([456,'ghijkl',123.99]); |
...

So you can just copy/paste the column into the code - good solution if you need a one-off transfer. The formula would be:

=concatenate("myArray.push([";A2;",'";B2;"',";C2;"]);")

but please check the exact syntax as I've got no English Excel at hand to test.

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