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

Read XL File

Contributor ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

Hi,

     We can read TXT and CSV file using InDesign Javascript.  Can we read XL file using javascript?

TOPICS
Scripting

Views

578

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
Community Expert ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

I suppose you are talking about excel files, if so then Kasyan Servetsky​ has a script that does that. Have a look at the following

Get data directly from Excel

-Manan

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
Contributor ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

Thank you..

Read xl using applescript.  is it possible using only javascript?

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
Community Expert ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

i don't think so unless you know the file format of excel file. These scripts leverage the capability of OS to read these files and hence are using VB/Applescript to read the file. If you want to write something in pure Javascript you would need to know the internals of Excel format to proceed. Basically excel files are an archive of xml files so if you are interested you can explore it, have a look at the following link to explore further if interested

https://professor-excel.com/xml-zip-excel-file-structure/

-Manan

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
Contributor ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

Thank you for the information..

I wanted to read XL file. I read applescript but don't know how to read in InDesign Javascript.  I wanted to know is there is any possibilities to read it in javascript.  Thanks for your information.  I will check.

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
Contributor ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

I haved checked that code given in the below url

Get data directly from Excel

Its returning the number like floating. ie., XL data is 1 but it returns 2.0.  similarly 13 digits numbers (isbn) are returns something different like floating number with +E (ie., 8.987654325678+E). How can i get the value placed in xl?

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
Community Expert ,
Feb 13, 2019 Feb 13, 2019

Copy link to clipboard

Copied

I have not tested the code myself but i doubt that it will falter at reading simple number values, lots of folks on the forum have been using this script and quite a bit of discussion has gone around this piece of code. Is the behaviour the same with all the excel files? Are you using the MAC or WIN version of the script? Did you test on both the platforms i.e. MAC and WIN, what is the behaviour. Maybe the creator of the script has some ready insights into what might be causing the issue at your end, i am tagging him Kasyan Servetsky, hope that he has some time at hand to look into your issue.

-Manan

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
Community Expert ,
Feb 13, 2019 Feb 13, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Sudha+K  wrote

I haved checked that code given in the below url

Get data directly from Excel

Its returning the number like floating. ie., XL data is 1 but it returns 2.0.  similarly 13 digits numbers (isbn) are returns something different like floating number with +E (ie., 8.987654325678+E). How can i get the value placed in xl?

Hi Sudha,

if something like this will happen also test if it will happen when using InDesign's UI with placing an Excel file.

I suspect that the formatting of the cells in the Excel file is the cause of that issue. Change the formatting to plain text should help. And strip off all formulas.

Regards,
Uwe

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
Contributor ,
Feb 13, 2019 Feb 13, 2019

Copy link to clipboard

Copied

Hi,

     Thank you for your replies... Thank you..

     I have tested in MAC only.  I did not set any formulas.  I have created the xl as you said. see my screenshot below.

XL.png

  1st column is formatted as text (1st row is formatted with text and placed the cursor in text and gave enter & 2nd one is just formatted as text for the 12 digits number). I ran the script and getting the below out put of the row data.

XLData.png

     I don't know how to get the data as it is in xl file (ie, display text in xl).

     So i have used Number(column1Val). its returning 239876543212. Similary i used number for column 3 also.  Don't know whether this is correct way or not?

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
Community Expert ,
Feb 14, 2019 Feb 14, 2019

Copy link to clipboard

Copied

Precede every number value in your excel with a single quote that will format that number into text and then the script seems to work fine without converting the number into scientific format and neither displaying a decimal. Try the file that works fine for me

Dropbox - Workbook1.xlsx

The results that i get from this excel are shown below

Screen Shot 2019-02-14 at 2.09.17 pm.png

-Manan

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
Contributor ,
Feb 14, 2019 Feb 14, 2019

Copy link to clipboard

Copied

LATEST

Ok thank you.. i will check and get back.

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