diff --git a/docz/docs/02-getting-started/01-installation/05-extendscript.md b/docz/docs/02-getting-started/01-installation/05-extendscript.md index 01473fa..2d7fd3f 100644 --- a/docz/docs/02-getting-started/01-installation/05-extendscript.md +++ b/docz/docs/02-getting-started/01-installation/05-extendscript.md @@ -21,3 +21,7 @@ After downloading the script, it can be directly referenced with `#include`: ```c #include "xlsx.extendscript.js" ``` + +For local deployments, the scripts can be placed in the `Scripts` folder. For +Photoshop CS6 on Windows 10, the path is typically +`C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts` diff --git a/docz/docs/03-demos/43-ml.mdx b/docz/docs/03-demos/43-ml.mdx index 92a32c6..b1ca9bb 100644 --- a/docz/docs/03-demos/43-ml.mdx +++ b/docz/docs/03-demos/43-ml.mdx @@ -1,5 +1,6 @@ --- title: Typed Arrays and ML +pagination_next: demos/hosting/index ---
diff --git a/docz/docs/03-demos/44-hosting/01-dropbox.mdx b/docz/docs/03-demos/44-hosting/01-dropbox.mdx new file mode 100644 index 0000000..14bb310 --- /dev/null +++ b/docz/docs/03-demos/44-hosting/01-dropbox.mdx @@ -0,0 +1,185 @@ +--- +title: Dropbox +pagination_prev: demos/ml +pagination_next: solutions/input +--- + + + + + +Dropbox is a file hosting service that offers APIs for programmatic file access. + +"Dropbox Apps" are the standard way to interact with the service. The +["Dropbox App"](#dropbox-app) section describes how this demo was configured. + +:::note + +The Dropbox API script is loaded in this page with + +```html + +``` + +The `data-app-key` used in this demo is a "Development" key associated with the +`localhost` and `docs.sheetjs.com` domains. Dropbox API does not require +"Production" approval for the Chooser or Saver. + +::: + +The live demos require a Dropbox account. + +## Reading Files + +"Chooser" is a small library that lets users select a file from their account. + +### Live Demo + +:::note + +The Dropbox API script is loaded in this page with + +```html + +``` + +The specific App Key used in this demo is a "Development" key associated with +the `localhost` and `docs.sheetjs.com` domains. Dropbox API does not require +"Production" approval for the Chooser. + +::: + +The button must have the following options: + +- `multiselect: false` ensures only one file can be selected +- `folderselect: false` limits selection to real files +- `linkType: "direct"` ensures the link points to a raw file + +When a file is selected, the `success` callback will receive an array of files +(even if `multiselect` is disabled). Each file object has a `link` file which +corresponds to a temporary URL that can be fetched. + +If the live demo shows a message about `Dropbox` being undefined, please reload +this demo page. + +```jsx live +function SheetJSChoisissez() { + const [msg, setMsg] = React.useState("Press the button to show a Chooser"); + const btn = useRef(), tbl = useRef(); + React.useEffect(() => { + /* create button */ + var button = Dropbox.createChooseButton({ + /* required settings */ + multiselect: false, + folderselect: false, + linkType: "direct", + /* optional settings */ + extensions: ['.xlsx', '.xls', '.numbers'], // list of extensions + + /* event handlers */ + cancel: () => setMsg("User Canceled Selection!"), + success: async(files) => { + /* get file entry -- note that dropbox API always passes an array */ + var file = files[0]; + setMsg(`Selected ${file.name} ID=${file.id}`); + + /* fetch file and parse */ + var wb = XLSX.read(await (await fetch(file.link)).arrayBuffer()); + + /* convert first sheet to HTML table and add to page */ + tbl.current.innerHTML = XLSX.utils.sheet_to_html(wb.Sheets[wb.SheetNames[0]]); + } + }); + /* add button to page */ + btn.current.appendChild(button); + }, []); + return ( <>{msg}