Skip to main content
Participant
August 16, 2018
Question

JavaScript interaction with Excel/Txt Files

  • August 16, 2018
  • 1 reply
  • 1367 views

Hello! I am very new to JavaScript programming within Adobe and am trying to pull an external list of strings (format can change, however, pulling from an Excel file would be most efficient) into an Adobe Pro DC JavaScript as an array, in order to search for that list of strings through the PDF. I have the code working so that I can hard code the strings into the JavaScript. Please let me know if you have any direction or can help me with this. Thank you very much for your time in advance!

Chris

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 16, 2018

You can't read data directly from an Excel file, as it is not a plain-text file. You will need to first convert it to something like a tab-delimited text file, a CSV file, or even an XML file, and then you would be able to read it directly using a script.

Participant
August 16, 2018

I'm able to manually copy the Excel (or really, probably write a VBA script that saves certain cells into a CSV file). Once I do that, how can I import that CSV into an array? Thank you for the quick response!

try67
Community Expert
Community Expert
August 16, 2018

You can use a method like readFileIntoStream of the util object, or even import the file as a data-object (importDataObject), read its contents (getDataObjectContents) and then remove it (removeDataObject, all under the Document object).