Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

javascript - 如何在Javascript / HTML5中解析Excel文件(How to parse Excel file in Javascript/HTML5)

I am able to read Excel file via FileReader but it outputs text as well as weird characters with it.(我能够通过FileReader读取Excel文件,但它输出文本以及奇怪的字符。)

I need to read xls file row-wise, read data in every column and convert it to JSON.(我需要逐行读取xls文件,读取每列中的数据并将其转换为JSON。)

How to read xls file row by row?(如何逐行读取xls文件?)

  ask by ducktyped translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Old question, but I should note that the general task of parsing XLS files from javascript is tedious and difficult but not impossible.(老问题,但我应该注意,从javascript解析XLS文件的一般任务是繁琐而困难的,但并非不可能。)

I have basic parsers implemented in pure JS:(我在纯JS中实现了基本的解析器:)

Both pages are HTML5 File API-driven XLS/XLSX parsers (you can drag-drop your file and it will print out the data in the cells in a comma-separated list).(这两个页面都是HTML5文件API驱动的XLS / XLSX解析器(您可以拖放文件,它将以逗号分隔的列表打印出单元格中的数据)。)

You can also generate JSON objects (assuming the first row is a header row).(您还可以生成JSON对象(假设第一行是标题行)。)

The test suite http://oss.sheetjs.com/ shows a version that uses XHR to get and parse files.(测试套件http://oss.sheetjs.com/显示了一个使用XHR来获取和解析文件的版本。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...