How do I export html table data as .csv file?

前端 未结 8 1184
轮回少年
轮回少年 2020-11-29 19:27

I have a table of data in an html table on a website and need to know how to export that data as .csv file.

How would this be done?

8条回答
  •  清歌不尽
    2020-11-29 20:03

    Here is a really quick CoffeeScript/jQuery example

    csv = []
    for row in $('#sometable tr')
      csv.push ("\"#{col.innerText}\"" for col in $(row).find('td,th')).join(',')
    output = csv.join("\n")
    

提交回复
热议问题