This commit is contained in:
SheetJS 2023-04-24 20:51:32 -04:00
parent 945adcd104
commit 31b4925ad5
5 changed files with 57 additions and 4 deletions

@ -29,7 +29,7 @@ This demo was verified in the following deployments:
|:----------|:-------------|:-----------|
| Photoshop | ExtendScript | 2023-04-15 |
| InDesign | ExtendScript | 2023-04-15 |
| InDesign | CEP | 2023-04-15 |
| InDesign | CEP | 2023-04-24 |
| InDesign | UXP | 2023-04-15 |
:::
@ -220,7 +220,7 @@ manifest must include the following flags to enable `cep.fs`:
The Base64 encoding is compatible with `type: "base64"`.
**Reading Files**
### Reading Files
The typical flow is to read data from CEP and pass the data into the host
ExtendScript context. The following snippet parses a workbook:
@ -234,7 +234,35 @@ const data = cep.fs.readFile(fn.data[0], cep.encoding.Base64);
const wb = XLSX.read(data.data, { type: "base64" });
```
**Writing Files**
<details open><summary><b>Complete Example</b> (click to hide)</summary>
<Tabs groupId="ccapp">
<TabItem value="indesign" label="InDesign">
0) Download [`com.sheetjs.data.zip`](pathname:///extendscript/com.sheetjs.data.zip)
and extract to a `com.sheetjs.data` subdirectory.
1) Move the entire `com.sheetjs.data` folder to the CEP extensions folder. In
Windows, the folder is `C:\Program Files (x86)\Common Files\Adobe\CEP\extensions\` .
If prompted, give administrator privileges.
2) Download and open [`Template.idml`](pathname:///extendscript/Template.idml)
3) Download <https://sheetjs.com/pres.xlsx>
4) Show the extension (in the menu bar, select Window > Extensions > SheetJS)
5) In the extension panel, click "Import from file" and select `pres.xlsx`
After "success" popup, the first worksheet should be written to the file.
</TabItem>
</Tabs>
</details>
### Writing Files
The typical flow is to invoke a function with `CSInterface#evalScript` that
returns data from the host ExtendScript context. The callback should build the
@ -249,6 +277,31 @@ const fn = cep.fs.showSaveDialogEx("Save File","",["xlsx"],"SheetJSIDCEP.xlsx");
cep.fs.writeFile(fn.data, b64, cep.encoding.Base64);
```
<details open><summary><b>Complete Example</b> (click to hide)</summary>
<Tabs groupId="ccapp">
<TabItem value="indesign" label="InDesign">
0) Download [`com.sheetjs.data.zip`](pathname:///extendscript/com.sheetjs.data.zip)
and extract to a `com.sheetjs.data` subdirectory.
1) Move the entire `com.sheetjs.data` folder to the CEP extensions folder. In
Windows, the folder is `C:\Program Files (x86)\Common Files\Adobe\CEP\extensions\` .
If prompted, give administrator privileges.
2) Download and open [`Filled.idml`](pathname:///extendscript/Filled.idml)
3) Show the extension (in the menu bar, select Window > Extensions > SheetJS)
4) In the extension panel, click "Export to XLSX" and "Save" in the dialog.
5) A popup will display the path to the generated file. Open the new file.
</TabItem>
</Tabs>
</details>
## UXP
UXP uses bundled scripts with `.psjs` (PS) or `.idjs` (InDesign) extension. The

@ -237,7 +237,7 @@ end extractResult
chmod +x sheetosa.scpt
```
3) Run the script (it is hardcoded to read `pres.numbers`):
4) Run the script (it is hardcoded to read `pres.numbers`):
```bash
./sheetosa.scpt

Binary file not shown.

Binary file not shown.

Binary file not shown.