• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to read the .xlsx file in Illustrator using Extendscript?

Explorer ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

Hi All,

 

I can able to read the CSV file. But I can't read the .xlsx file. Could anyone tell me how to read that?

var csvFile = File("~/Downloads/data.xlsx");
csvFile.encoding = 'UTF8'; // set to 'UTF8' or 'UTF-8'
csvFile.open("r");
var csvContent = csvFile.read();
csvFile.close();

 

Thanks.

TOPICS
Scripting

Views

933

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

Long answer: No

Short answer: save your *.xlsx as tab delimited *.txt and read this *.txt

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

LATEST

Not in ECMAScript 3 (JSX), which predates the dinosaurs. (Technically not impossible, but you’d have to write everything from scratch and it’s quicker just to go mad.)

 

There are several XLSX parsing libraries for Node.js if you don’t mind using Node/CEP (or UXP, once that ships). Just search on NPM.

 

However, expect to run into various gotchas when reading cells that use text styles, automatic number and date formatting, and other Excel features. What Excel displays on screen is not necessarily how that data is stored in the file. Not so much an issue when using Excel files in Excel as mathematical spreadsheets, as they were meant to be used. But a source of excitingly unanticipated bugs when reading XLSX files from customers who like to use them as ersatz databases. (e.g. Barcode numbers that start with “0”, which Excel will happily discard on cells that aren’t explicitly set to TEXT format.)

 

Otherwise, use Excel to export your spreadsheet file to .csv or .txt plaintext format, which bring their own sets of issues but are at least comparatively simple (relative to .xlsx) to parse and troubleshoot.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines