Other PDF Issues

How to Read Excel Files as Arrays using Acrobat JavaScript

Camila MilosovichCamila Milosovich Nov 5, 2026 869 views

Question details

The user is looking for a way to use Acrobat JavaScript to directly read and parse data from Excel files into arrays.

How to Read Excel Files as Arrays using Acrobat JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Save Excel data as CSV

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.

2
Load the CSV into Acrobat

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.

3
Parse string data into arrays

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.

Convert the Excel File to CSV Format for Import
Local Workflow Requirement: This method relies on local files. To ensure the script executes correctly, test the workflow within your local Acrobat environment before distributing the PDF.
Seamless Data Extraction

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. 1. Launch WPS Office: Open the WPS Office suite on your device and navigate to the built-in PDF toolset.
  2. 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. 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.
Instantly convert PDF tables and forms into editable Excel spreadsheets.High compatibility with Microsoft Office formats like .xlsx and .csv.Built-in PDF editor and spreadsheet tool in one lightweight suite.Completely free to download with a familiar, user-friendly interface.
microsoft office alternative - wps office

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.