简体   繁体   中英

Reading XLS/XLSX Data With JavaScript in NetSuite

I'm looking into potentially building code for NetSuite to read the contents of an Excel file (XLS or XLSX) within JavaScript in order to process the data. I can do this just fine with a CSV file, but I'd like to expand capabilities to read Excel worksheets.

I've seen a variety of scripts to read in Excel files, but they all seem to revolve around a dependency of Internet Explorer, and none of them seem to offer a solution on how to get the used columns and rows. They assume you already know this information ahead of time. NetSuite being what it is, these solutions don't really work, and you have to grab the base64 encoded contents of the file object stored in the system. This isn't an issue with CSV files, it's still just plain text.

I've done some testing and found that I get different results when trying to decode the string (I get something from XLS, but nothing from XLSX). I was wondering if anyone has tried and succeeded and reading data from these files formats in a NetSuite JavaScript implementation. If there's no good way, then I'll just have to force use of CSV, but I'd like to have some flexibility.

Essentially, you are asking for a javascript implementation of XLS and XLSX parsers. It is incredibly difficult, mostly due to the nature of the data format and the sheer amount of parsing required to get basic data).

I have built a basic version:

http://oss.sheetjs.com/js-xls/ (xls)

http://oss.sheetjs.com/js-xlsx/ (xlsx)

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