How to Read Excel Files as Arrays using Acrobat JavaScript
Question details
The user is looking for a way to use Acrobat JavaScript to directly read and parse data from Excel files into arrays.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Attempting to import, read, or parse data from an external Excel spreadsheet into a PDF document using Acrobat JavaScript.
- Observed behavior
- Acrobat JavaScript does not natively include an Excel parser or permit unrestricted access to remote files via HTTP, preventing direct reading of .xlsx files.
Ensure you have local access to the target Excel file, as Acrobat's security sandbox generally blocks JavaScript from directly accessing or reading files hosted on remote web servers over HTTP.
Convert the Excel File to CSV Format for Import
Since Acrobat JavaScript cannot natively parse raw .xlsx files, converting the Excel file to a plain-text CSV format allows Acrobat to easily read and split the structured data into arrays.
Acrobat JavaScript excels at reading plain-text strings. By saving your spreadsheet as a CSV, you bypass the need for a complex external parser and can handle the data directly with native JavaScript array methods.
Open your original workbook in Microsoft Excel or WPS Spreadsheet. Go to File > Save As, and choose 'CSV (Comma delimited) (*.csv)' as the output format to save it locally.
Use Acrobat's built-in data import methods, such as the util.readFileIntoStream or importTextData() function, to securely load the local plain-text data into your PDF's JavaScript environment.
Write a custom Document-Level JavaScript function to split the imported CSV string by line breaks and commas (e.g., using string.split(',')), pushing the resulting values into a multi-dimensional array.

Implement a Custom JavaScript Parser
If converting to CSV manually is not an option, you can integrate a third-party pure JavaScript Excel parser into the PDF, provided it runs strictly locally without external HTTP calls.
Manage PDF and Excel Data Effortlessly with WPS Office
Instead of writing complex JavaScript parsers in Acrobat to extract data, use WPS Office to directly convert, manage, and bridge the gap between PDF documents and Excel spreadsheets without any coding.
- 1. Launch WPS Office: Open the WPS Office suite on your device and navigate to the built-in PDF toolset.
- 2. Convert PDF to Excel: Click on the 'PDF to Excel' feature to automatically detect tables and form data, converting them directly into a structured spreadsheet.
- 3. Manipulate the Data: Open the newly converted file in WPS Spreadsheet to easily organize columns, calculate values, or export data as a standard CSV.

Frequently Asked Questions
Why can't Acrobat JavaScript read remote Excel files over the web?
Acrobat JavaScript enforces strict security sandbox restrictions designed to protect users from malicious scripts. These restrictions block unauthorized HTTP requests and prevent scripts from directly accessing files hosted on remote servers.
What is the best format to import data into a PDF via JavaScript?
Plain-text formats like CSV (Comma Separated Values) or tab-delimited text are the ideal formats. They are lightweight, completely unencrypted, and easily parsed into arrays using native JavaScript string manipulation.
Can I use external JavaScript libraries in an Acrobat PDF?
Yes, but with limitations. You can embed pure-JavaScript libraries directly into the Document-Level scripts. However, any library that requires browser-specific APIs (like window or document objects) or external web connections will fail in the Acrobat environment.
How do I export PDF form data back out to an Excel file?
You can export form data directly from Acrobat without scripts by going to Tools > Prepare Form > More > Export Data. Save the output as a CSV or XML file, both of which can be natively opened and mapped into Excel.




