This commit is contained in:
SheetJS 2023-11-15 23:20:57 -05:00
parent 014c28c5f5
commit a4ad3195f5
8 changed files with 164 additions and 33 deletions

@ -17,8 +17,8 @@ an open source object-relational database system.
data from spreadsheets.
This demo uses SheetJS to exchange data between spreadsheets and PostgreSQL
databases. We'll explore how to use save tables from a database to spreadsheets
and how to add data from spreadsheets into a database.
databases. We'll explore how to save tables from a database to spreadsheets and
how to add data from spreadsheets into a database.
:::caution pass
@ -215,7 +215,7 @@ On macOS, install the `postgresql` formula with Homebrew:
brew install postgresql@16
```
The last few lines of the installer explains how to start the database:
The last few lines of the installer explain how to start the database:
```text
Or, if you don't want/need a background service you can just run:

@ -6,6 +6,8 @@ pagination_next: demos/bigdata/index
---
import current from '/version.js';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
export const b = {style: {color:"blue"}};
@ -44,7 +46,7 @@ This demo covers Stata extensions. For directly processing Stata DTA files, the
:::note Tested Deployments
This demo was last tested by SheetJS users on 2023 November 05.
This demo was last tested by SheetJS users on 2023 November 15.
:::
@ -120,8 +122,8 @@ can be loaded in Duktape by reading the source from the filesystem.
:::info pass
This demo was tested in Windows x64. The path names and build commands will
differ in other platforms and operating systems.
This demo was tested in Windows x64 and macOS x64. The path names and build
commands will differ in other platforms and operating systems.
:::
@ -137,6 +139,33 @@ import excel "sheetjs.tmp.xlsx", firstrow
### Create Plugin
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
0) Ensure a compatible C compiler (Xcode on macOS) is installed.
1) Open Stata and run the following command:
```stata
pwd
```
The output will be the default data directory. On macOS this is typically
`~/Documents/Stata`
2) Open a terminal window and create a project folder `sheetjs-stata` within the
Stata data directory:
```bash
# `cd` to the Stata data directory
cd ~/Documents/Stata
mkdir sheetjs-stata
cd sheetjs-stata
```
</TabItem>
<TabItem value="win" label="Windows">
0) Ensure "Windows Subsystem for Linux" (WSL) and Visual Studio are installed.
1) Open a new "x64 Native Tools Command Prompt" window and create a project
@ -154,6 +183,9 @@ cd sheetjs-stata
bash
```
</TabItem>
</Tabs>
3) Download [`stplugin.c`](https://www.stata.com/plugins/stplugin.c) and
[`stplugin.h`](https://www.stata.com/plugins/stplugin.h) from the Stata website:
@ -162,7 +194,8 @@ curl -LO https://www.stata.com/plugins/stplugin.c
curl -LO https://www.stata.com/plugins/stplugin.h
```
4) Still within WSL, install Duktape:
4) Download Duktape. In Windows, the following commands should be run in WSL. In
macOS, the commands should be run in the same Terminal session.
```bash
curl -LO https://duktape.org/duktape-2.7.0.tar.xz
@ -170,13 +203,29 @@ tar -xJf duktape-2.7.0.tar.xz
mv duktape-2.7.0/src/*.{c,h} .
```
5) Still within WSL, download the demo source
[`cleanfile.c`](https://docs.sheetjs.com/stata/cleanfile.c):
5) Download [`cleanfile.c`](https://docs.sheetjs.com/stata/cleanfile.c).
In Windows, the following commands should be run in WSL. In macOS, the commands
should be run in the same Terminal session.
```bash
curl -LO https://docs.sheetjs.com/stata/cleanfile.c
```
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
6) Observe that macOS does not need a "Linux Subsystem" and move to Step 7.
7) Build the plugin:
```bash
gcc -shared -fPIC -DSYSTEM=APPLEMAC stplugin.c duktape.c cleanfile.c -lm -std=c99 -Wall -ocleanfile.plugin
```
</TabItem>
<TabItem value="win" label="Windows">
6) Exit WSL:
```bash
@ -191,8 +240,23 @@ The window will return to the command prompt.
cl /LD cleanfile.c stplugin.c duktape.c
```
</TabItem>
</Tabs>
### Install Plugin
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
8) Copy the plugin to the Stata data directory:
```bash
cp cleanfile.plugin ../
```
</TabItem>
<TabItem value="win" label="Windows">
8) Copy the DLL to `cleanfile.plugin` in the Stata data directory. For example,
with a shared data directory `c:\data`:
@ -201,9 +265,26 @@ mkdir c:\data
copy cleanfile.dll c:\data\cleanfile.plugin
```
</TabItem>
</Tabs>
### Download SheetJS Scripts
9) Move to the `c:\data` directory
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
9) Move to the Stata data directory:
```bash
cd ..
```
10) Observe that macOS does not need a "Linux Subsystem" and move to Step 11.
</TabItem>
<TabItem value="win" label="Windows">
9) Move to the `c:\data` directory:
```powershell
cd c:\data
@ -215,7 +296,13 @@ cd c:\data
bash
```
11) Within WSL, download SheetJS scripts and the test file.
</TabItem>
</Tabs>
11) Download SheetJS scripts and the test file.
In Windows, the following commands should be run in WSL. In macOS, the commands
should be run in the same Terminal session.
<CodeBlock language="bash">{`\
curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/shim.min.js
@ -223,14 +310,6 @@ curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js
curl -LO https://sheetjs.com/pres.numbers`}
</CodeBlock>
12) Exit WSL:
```bash
exit
```
The window will return to the command prompt.
### Stata Test
:::note pass
@ -239,15 +318,32 @@ The screenshot in the introduction shows the result of steps 13 - 19
:::
13) Open Stata
12) If it is not currently running, start the Stata application.
14) Move to the `c:\data` directory in Stata:
<Tabs groupId="os">
<TabItem value="unix" label="Linux/MacOS">
13) Run the following command in Stata:
```stata
dir
```
Inspect the output and confirm that `cleanfile.plugin` is listed.
</TabItem>
<TabItem value="win" label="Windows">
13) Move to the `c:\data` directory in Stata:
```stata
cd c:\data
```
15) Load the `cleanfile` plugin:
</TabItem>
</Tabs>
14) Load the `cleanfile` plugin:
```stata
program cleanfile, plugin

@ -124,7 +124,7 @@ This demo was tested in the following deployments:
| V8 Version | Platform | OS Version | Compiler | Date |
|:--------------|:-------------|:--------------|:-----------------|:-----------|
| `11.8.82` | `darwin-x64` | macOS 13.5.1 | `clang 14.0.3` | 2023-08-26 |
| `12.1.131` | `darwin-x64` | macOS 14.1 | `clang 15.0.0` | 2023-11-15 |
| `12.0.175` | `darwin-arm` | macOS 14.0 | `clang 15.0.0` | 2023-10-20 |
| `12.0.265` | `win10-x64` | Windows 10 | `CL 19.37.32822` | 2023-10-28 |
| `12.0.72` | `linux-x64` | HoloOS 3.4.11 | `gcc 12.2.0` | 2023-10-11 |
@ -811,9 +811,9 @@ This demo was last tested in the following deployments:
| Architecture | V8 Crate | Date |
|:-------------|:---------|:-----------|
| `darwin-x64` | `0.75.1` | 2023-08-26 |
| `darwin-x64` | `0.81.0` | 2023-11-14 |
| `darwin-arm` | `0.79.2` | 2023-10-18 |
| `win10-x64` | `0.79.2` | 2023-10-09 |
| `win10-x64` | `0.81.0` | 2023-11-14 |
| `linux-x64` | `0.79.2` | 2023-10-11 |
| `linux-arm` | `0.75.1` | 2023-08-30 |

@ -41,7 +41,7 @@ setting the environment variable on supported platforms.
:::note pass
Most of the integration functions are not documented. This explanation is based
on version `3.0.0-beta-2053`.
on version `3.0.0-beta-2055`.
:::
@ -163,7 +163,7 @@ This demo was tested in the following deployments:
| Architecture | Jint Version | Date |
|:-------------|:------------------|:-----------|
| `darwin-x64` | `3.0.0-beta-2051` | 2023-09-16 |
| `darwin-x64` | `3.0.0-beta-2055` | 2023-11-14 |
| `darwin-arm` | `3.0.0-beta-2051` | 2023-09-26 |
| `win10-x64` | `3.0.0-beta-2053` | 2023-10-28 |
| `win11-arm` | `3.0.0-beta-2051` | 2023-09-26 |
@ -238,7 +238,7 @@ dotnet run
```bash
dotnet nuget add source https://www.myget.org/F/jint/api/v3/index.json
dotnet add package Jint --version 3.0.0-beta-2053
dotnet add package Jint --version 3.0.0-beta-2055
```
To verify Jint is installed, replace `Program.cs` with the following:

@ -362,7 +362,7 @@ This demo was tested in the following deployments:
| Architecture | Git Commit | Date |
|:-------------|:-----------|:-----------|
| `darwin-x64` | `70af78b` | 2023-08-27 |
| `darwin-x64` | `84732b3` | 2023-11-14 |
| `darwin-arm` | `2b4f949` | 2023-10-18 |
| `linux-x64` | `2b4f949` | 2023-10-11 |
| `linux-arm` | `70af78b` | 2023-08-27 |
@ -429,6 +429,38 @@ curl -LO https://docs.sheetjs.com/hermes/sheetjs-hermes.cpp
make init
```
:::caution pass
During the most recent macOS x64 test, the build failed due to Ninja issues:
```
CMake Error at CMakeLists.txt:64 (project):
Running
'/usr/local/lib/depot_tools/ninja' '--version'
failed with:
depot_tools/ninja.py: Could not find Ninja in the third_party of the current project, nor in your PATH.
```
This is due to a conflict with the Ninja version that ships with `depot_tools`.
Since `depot_tools` typically is added before other folders in the system `PATH`
variable, it is strongly recommended to rename the `ninja` binary, build the
Hermes libraries, and restore the `ninja` binary:
```bash
# Rename `ninja`
mv /usr/local/lib/depot_tools/ninja /usr/local/lib/depot_tools/ninja_tmp
# Build Hermes
make init
# Restore `ninja`
mv /usr/local/lib/depot_tools/ninja_tmp /usr/local/lib/depot_tools/ninja
```
:::
5) Build the application:
```bash

@ -70,7 +70,7 @@ This demo was tested in the following deployments:
| Platform | Ruby | ExecJS | Date |
|:-------------|:---------|:--------|:-----------|
| `darwin-x64` | `2.7.6` | `2.9.1` | 2023-09-24 |
| `darwin-x64` | `2.6.10` | `2.9.1` | 2023-11-14 |
| `darwin-arm` | `2.7.4` | `2.9.1` | 2023-09-24 |
| `win10-x64` | `3.2.2` | `2.9.1` | 2023-10-28 |
| `win11-arm` | `3.0.2` | `2.9.1` | 2023-09-24 |

@ -131,7 +131,7 @@ This demo was tested in the following deployments:
| Architecture | Commit | Date |
|:-------------|:----------|:-----------|
| `darwin-x64` | `a588e49` | 2023-09-22 |
| `darwin-x64` | `bc408b1` | 2023-11-14 |
| `linux-x64` | `a588e49` | 2023-10-11 |
:::
@ -221,6 +221,9 @@ ready, it will read the bundled test data and print the contents as CSV.
build/bin/jerry xlsx.jerry.js; echo $?
```
If successful, the contents of the test file will be displayed in CSV rows. The
status code `0` will be printed after the rows.
</details>
### Jint

@ -1,5 +1,5 @@
# Note: The official Hermes documentation includes zero guidance on embedding.
# Tested against commit 2b4f949f6ff4d1de03fbad0dbef9b744153e0adb
# Tested against commit 84732b3ce6a859cbc6a20112437c81154f111fe7
MYCC=llvm-g++
POSTAMBLE=-framework CoreFoundation
@ -64,5 +64,5 @@ sheetjs-hermes: sheetjs-hermes.cpp init
.PHONY: init
init:
if [ ! -e hermes ]; then git clone https://github.com/facebook/hermes.git; cd hermes; git checkout 2b4f949f6ff4d1de03fbad0dbef9b744153e0adb; cd ..; fi
if [ ! -e hermes ]; then git clone https://github.com/facebook/hermes.git; cd hermes; git checkout 84732b3ce6a859cbc6a20112437c81154f111fe7; cd ..; fi
if [ ! -e build_release ]; then cmake -S hermes -B build_release -G Ninja -DCMAKE_BUILD_TYPE=Release; cmake --build ./build_release; fi