-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using js-xlsx inside adobe extendscript #603
Comments
@firas3d if it is a standard JS runtime, you should be able to add the If you need international support (like Chinese/Japanese/Korean characters), use I don't think any of the devs are familiar with extend script so it would be helpful if you can produce a small demo that loads the script. And if it does work, please add a note in the wiki :) |
Thanks @reviewher, will do my best tonight to load the shim.js and xlsx.core.min.js If we access xlsx inside adobe extedscript, then that would be awesome achievement to all adobe workflow. (Currently all adobe tools developers are converting tables to text files, but you can imagine how its unfriendly for data visualizations) |
You need to somehow "get the file" then "read it". https://github.com/SheetJS/js-xlsx#parsing-workbooks has some examples. I'm not sure how extend script works but they probably some function to read a file into a string or array. Once you have that, you can call
There are some utilities for converting to JS objects. For example, to convert the first worksheet to an array of arrays like // assume workbook is the result of XLSX.read(...)
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); |
I am facing errors in lines scripts format, for example "expected: ;" thanks. |
Hello @firas3d ! Thanks for looking into this! For development purposes, include the following files in order: They are all unminified so you should have a useful line number |
Appreciate the help from a more experienced developer. Can anyone help by downloading the adobe extendedscript and
http://www.adobe.com/mena_en/products/extendscript-toolkit.html Big thanks, |
There were a few issues with the shims assuming that The ExtendScript I tested was: #include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
XLSX.read and it appeared to work: Download the shim.js and jszip.js files from the link and see if those work. Once that works, try reading the file in (as a binary string or byte array or whatever extendscript does) and call |
Big thanks @SheetJSDev , an error xlsx.flow.js when calling
Appreciate 👍 |
Updated the jszip script, new file at https://gist.github.com/SheetJSDev/5573c7c02c47421b17185a73dc5497f6 -- long story short, none of the usual global suspects (global, window, self) are available, so you have to poke a hole in Here's some sample code to read #include "shim.js";
#include "jszip.js";
var JSZip = app.JSZip;
#include "xlsx.flow.js";
var filename = "sheetjs.xlsx";
var infile = File(filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); For future reference: the guide is available at https://www.adobe.com/content/dam/Adobe/en/devnet/scripting/pdfs/javascript_tools_guide.pdf Test it out and let us know if it works! |
for good measure I also included the test file I was using and the test.jsx file. I can actually reproduce that error, it's most likely coming because extendscript is looking in the wrong directory. To test this, in the javascript console run |
yes, reopened extendscript, and all works fine. |
If you find any other issues, let us know. Going to close this issue and take a nap :) |
small issu when connecting target application. But if it is changed to Adobe Illustrator for example, or adding
|
So I downloaded a trial of Illustrator CC 2017 for OSX and I can't reproduce. It also works if i remove the Are you on windows or mac? Also, can you add the line |
- `aoa_to_sheet` function (fixes #314 h/t @fonzy2013 @rvdwijngaard) - `writeFileAsync` function (fixes #396 h/t @barbalex) - `sheet_to_json` tests + docs + blankrows (fixes #602 h/t @EEaglehouse) - write number format scan now includes every index >= 50 - propagate SSF IE8 fixes (fixes #171 h/t @SheetJSDev) - update shim for extendscript (see #603 h/t @firas3d) - more flow type definitions
@firas3d just to be sure: if you take out the line |
same, wither i put the line #target or link it from interface, the problem occur. from what i understand, the JSZip library doesnt like #target application |
@firas3d we made some changes to the shim and jszip scripts. Please update both |
super, will test it, |
- `aoa_to_sheet` function (fixes SheetJS#314 h/t @fonzy2013 @rvdwijngaard) - `writeFileAsync` function (fixes SheetJS#396 h/t @barbalex) - `sheet_to_json` tests + docs + blankrows (fixes SheetJS#602 h/t @EEaglehouse) - write number format scan now includes every index >= 50 - propagate SSF IE8 fixes (fixes protobi#171 h/t @SheetJSDev) - update shim for extendscript (see SheetJS#603 h/t @firas3d) - more flow type definitions
Is it possible to include the js-xlsx library and scripts inside adobe JavaScript environment ?
Can i include js-xlsx in a non web application ?
Need an advise for resources on this topic.
Thank you all for keeping this place active.
The text was updated successfully, but these errors were encountered: