ns-suitelet

This commit is contained in:
SheetJS 2023-10-28 04:57:22 -04:00
parent 36d350427c
commit b23c03f051
5 changed files with 121 additions and 30 deletions

View File

@ -1,4 +1,5 @@
{
"label": "Electronic Mail",
"collapsed": false,
"position": 4
}

View File

@ -213,7 +213,7 @@ known location. After writing, an alert will display the location of the file.
2) Install required global dependencies:
```bash
npm i -g cordova-res @angular/cli native-run @ionic/cli
npm i -g cordova cordova-res @angular/cli native-run @ionic/cli
```
### Base Project

View File

@ -46,10 +46,10 @@ This demo was tested in the following environments:
| OS and Version | Arch | RN Platform | Date |
|:---------------|:-----|:------------|:-----------|
| Windows 10 | x64 | `v0.71.25` | 2023-07-24 |
| Windows 10 | x64 | `v0.72.16` | 2023-10-27 |
| Windows 11 | x64 | `v0.72.12` | 2023-10-14 |
| Windows 11 | ARM | `v0.72.9` | 2023-09-18 |
| MacOS 12.6 | x64 | `v0.71.26` | 2023-07-23 |
| MacOS 14.1 | x64 | `v0.72.5` | 2023-10-27 |
| MacOS 13.5.2 | ARM | `v0.72.4` | 2023-09-18 |
:::
@ -420,10 +420,10 @@ setup instructions" to find instructions for manual installation.
### Project Setup
1) Create a new project using React Native `0.72`:
1) Create a new project using React Native `0.72.6`:
```bash
npx react-native init SheetJSWin --template react-native@^0.72.0
npx react-native init SheetJSWin --template react-native@0.72.6
cd SheetJSWin
```
@ -522,8 +522,10 @@ curl -Lo windows/SheetJSWin/DocumentPicker.cs https://docs.sheetjs.com/reactnati
6) Add the highlighted line to `windows\SheetJSWin\SheetJSWin.csproj`. Look for
the `ItemGroup` that contains `ReactPackageProvider.cs`:
6) Edit `windows\SheetJSWin\SheetJSWin.csproj` to reference `DocumentPicker.cs`
Search for `ReactPackageProvider.cs` in the file. There will be one instance.
Add the highlighted line just before that instance:
```xml title="windows\SheetJSWin\SheetJSWin.csproj"
<!-- highlight-next-line -->
@ -577,6 +579,7 @@ Now the native module will be added to the app.
<TabItem value="pwsh" label="PowerShell">
```bash
rm App.js
iwr -Uri https://docs.sheetjs.com/reactnative/rnw/App.tsx -OutFile App.tsx
```
@ -584,6 +587,7 @@ iwr -Uri https://docs.sheetjs.com/reactnative/rnw/App.tsx -OutFile App.tsx
<TabItem value="bash" label="WSL Bash">
```bash
rm App.js
curl -LO https://docs.sheetjs.com/reactnative/rnw/App.tsx
```
@ -632,6 +636,17 @@ select `pres.xlsx` . The app will refresh and display the data from the file.
## macOS Demo
:::info pass
When the demo was last tested, the official website asserted that the React
Native for macOS required React Native `0.71`.
**The official documentation is out of date.**
There exist official `react-native-macos` releases compatible with RN `0.72`
:::
0) Follow the "Setting up the development environment"[^5] guide in the React
Native documentation for "React Native CLI Quickstart" + "macOS" + "iOS".
@ -780,8 +795,8 @@ Within the block, look for `buildPhases` and find the hex string for `Sources`:
```
Search for that hex string (`514201452437B4B30078DB4F` in our example) in the
file and it should show up in a `PBXSourcesBuildPhase` section. Within `files`,
add the highlighted line:
file and it should show up in a `PBXSourcesBuildPhase` section. Within the
`files` list, add the highlighted line:
```plist
514201452437B4B30078DB4F /* Sources */ = {
@ -854,36 +869,55 @@ Close the running app from the dock and close the Metro terminal window.
curl -LO https://docs.sheetjs.com/reactnative/rnm/App.tsx
```
10) Test the app:
10) Download <https://sheetjs.com/pres.xlsx> to the Downloads folder.
#### Development
11) Launch the app again:
```bash
npx react-native run-macos
```
Download <https://sheetjs.com/pres.xlsx>.
12) Click "Click here to Open File!" and use the file picker to select
`pres.xlsx` from the Downloads folder.
Click "Click here to Open File!" and use the file picker to select `pres.xlsx` .
The app will refresh and display the data from the file.
11) Make a release build:
Close the running app from the dock and close the Metro terminal window.
#### Production
13) Make a release build:
```bash
xcodebuild -workspace macos/SheetJSmacOS.xcworkspace -scheme SheetJSmacOS-macOS -config Release
```
The last line of the output will include the path to the app. If it is not
displayed, the app path can be found in the `DerivedData` folder:
When the demo was last tested, the path to the generated app was displayed in
the terminal. Search for `Release/SheetJSmacOS.app`:
```
/usr/bin/touch -c /Users/sheetjs/Library/Developer/Xcode/DerivedData/SheetJSmacOS-abcdefghijklmnopqrstuvwxyzab/Build/Products/Release/SheetJSmacOS.app
```
If there are no instances, the app path can be found in the `DerivedData` folder:
```bash
find ~/Library/Developer/Xcode/DerivedData -name SheetJSmacOS.app | grep Release
```
12) Run the release app:
14) Run the release app:
```bash
open -a "$(find ~/Library/Developer/Xcode/DerivedData -name SheetJSmacOS.app | grep Release | head -n 1)"
```
15) Click "Click here to Open File!" and use the file picker to select
`pres.xlsx` from the Downloads folder.
The app will refresh and display the data from the file.
[^1]: The [official website](https://microsoft.github.io/react-native-windows/) covers both platforms, but there are separate repositories for [Windows](https://github.com/microsoft/react-native-windows) and [macOS](https://github.com/microsoft/react-native-macos)
[^2]: See ["Array of Arrays" in the API reference](/docs/api/utilities/array#array-of-arrays)
[^3]: See ["Array Output" in "Utility Functions"](/docs/api/utilities/array#array-output)

View File

@ -26,7 +26,7 @@ This demo was verified by NetSuite consultants in the following deployments:
|:----------------|:---------------|:-----------|
| ScheduledScript | 2.1 | 2023-08-18 |
| Restlet | 2.1 | 2023-10-05 |
| Suitelet | 2.1 | 2023-07-21 |
| Suitelet | 2.1 | 2023-10-27 |
| MapReduceScript | 2.1 | 2023-07-31 |
:::

View File

@ -1,5 +1,7 @@
---
title: C + Duktape
title: Data Processing with Duktape
sidebar_label: C + Duktape
description: Process structured data in C programs. Seamlessly integrate spreadsheets into your program by pairing Duktape and SheetJS. Supercharge programs with modern data tools.
pagination_prev: demos/bigdata/index
pagination_next: solutions/input
---
@ -9,15 +11,21 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
Duktape is an embeddable JS engine written in C. It has been ported to a number
of exotic architectures and operating systems.
[Duktape](https://duktape.org) is an embeddable JS engine written in C. It has
been ported to a number of exotic architectures and operating systems.
The [SheetJS Standalone scripts](/docs/getting-started/installation/standalone)
can be parsed and evaluated in a Duktape context.
[SheetJS](https://sheetjs.com) is a JavaScript library for reading and writing
data from spreadsheets.
The ["Integration Example"](#integration-example) section includes a complete
command-line tool for reading data from spreadsheets and exporting to Excel XLSB
workbooks.
The ["Bindings"](#bindings) section covers bindings for other ecosystems.
## Integration Details
_Initialize Duktape_
### Initialize Duktape
Duktape does not provide a `global` variable. It can be created in one line:
@ -30,7 +38,10 @@ duk_context *ctx = duk_create_heap_default();
duk_eval_string_noresult(ctx, "var global = (function(){ return this; }).call(null);");
```
_Load SheetJS Scripts_
### Load SheetJS Scripts
The [SheetJS Standalone scripts](/docs/getting-started/installation/standalone)
can be parsed and evaluated in a Duktape context.
The shim and main libraries can be loaded by reading the scripts from the file
system and evaluating in the Duktape context:
@ -121,7 +132,7 @@ This demo was tested in the following deployments:
|:-------------|:--------|:-----------|
| `darwin-x64` | `2.7.0` | 2023-10-26 |
| `darwin-arm` | `2.7.0` | 2023-10-18 |
| `win10-x64` | `2.7.0` | 2023-07-24 |
| `win10-x64` | `2.7.0` | 2023-10-27 |
| `win11-arm` | `2.7.0` | 2023-09-26 |
| `linux-x64` | `2.7.0` | 2023-10-11 |
| `linux-arm` | `2.7.0` | 2023-08-30 |
@ -133,17 +144,47 @@ generates an XLSB file and writes to the filesystem.
The [flow diagram is displayed after the example steps](#flow-diagram)
0) Download and extract Duktape:
:::info pass
On Windows, the Visual Studio "Native Tools Command Prompt" must be used.
:::
0) Create a project folder:
```bash
mkdir sheetjs-duk
cd sheetjs-duk
```
1) Download and extract Duktape:
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
</TabItem>
<TabItem value="win" label="Windows">
:::caution pass
The Windows built-in `tar` does not support `xz` archives.
**The commands must be run within WSL `bash`.**
After the `mv` command, exit WSL.
:::
</TabItem>
</Tabs>
```bash
curl -LO https://duktape.org/duktape-2.7.0.tar.xz
tar -xJf duktape-2.7.0.tar.xz
mv duktape-2.7.0/src/*.{c,h} .
```
1) Download the SheetJS Standalone script, shim script and test file. Move all
2) Download the SheetJS Standalone script, shim script and test file. Move all
three files to the project directory:
<ul>
@ -152,19 +193,34 @@ three files to the project directory:
<li><a href="https://sheetjs.com/pres.numbers">pres.numbers</a></li>
</ul>
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
</TabItem>
<TabItem value="win" label="Windows">
:::caution pass
If the `curl` command fails, run the commands within WSL `bash`.
:::
</TabItem>
</Tabs>
<CodeBlock language="bash">{`\
curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/shim.min.js
curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js
curl -LO https://sheetjs.com/pres.numbers`}
</CodeBlock>
2) Download [`sheetjs.duk.c`](pathname:///duk/sheetjs.duk.c):
3) Download [`sheetjs.duk.c`](pathname:///duk/sheetjs.duk.c):
```bash
curl -LO https://docs.sheetjs.com/duk/sheetjs.duk.c
```
3) Compile standalone `sheetjs.duk` binary
4) Compile standalone `sheetjs.duk` binary
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
@ -197,7 +253,7 @@ cl sheetjs.duk.c duktape.c /I .\
</TabItem>
</Tabs>
4) Run the demo:
5) Run the demo:
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">