Compare commits
1 Commits
feature/ni
...
feature/ni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
517221fac5 |
446
.github/workflows/npm.yml
vendored
446
.github/workflows/npm.yml
vendored
@@ -1,446 +0,0 @@
|
||||
name: nodejs
|
||||
env:
|
||||
DEBUG: napi:*
|
||||
APP_NAME: nodejs
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
'on':
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
publish:
|
||||
description: "Publish to npm"
|
||||
required: true
|
||||
type: boolean
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
settings:
|
||||
- host: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
build: yarn build --target x86_64-apple-darwin
|
||||
- host: windows-latest
|
||||
build: yarn build --target x86_64-pc-windows-msvc
|
||||
target: x86_64-pc-windows-msvc
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
|
||||
build: yarn build --target x86_64-unknown-linux-gnu
|
||||
- host: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
||||
build: yarn build --target x86_64-unknown-linux-musl
|
||||
- host: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
build: yarn build --target aarch64-apple-darwin
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
|
||||
build: yarn build --target aarch64-unknown-linux-gnu
|
||||
- host: ubuntu-latest
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
||||
build: yarn build --target armv7-unknown-linux-gnueabihf
|
||||
- host: ubuntu-latest
|
||||
target: armv7-unknown-linux-musleabihf
|
||||
build: yarn build --target armv7-unknown-linux-musleabihf
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-linux-android
|
||||
build: yarn build --target aarch64-linux-android
|
||||
- host: ubuntu-latest
|
||||
target: armv7-linux-androideabi
|
||||
build: yarn build --target armv7-linux-androideabi
|
||||
- host: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
||||
build: |-
|
||||
set -e &&
|
||||
rustup target add aarch64-unknown-linux-musl &&
|
||||
yarn build --target aarch64-unknown-linux-musl
|
||||
- host: windows-latest
|
||||
target: aarch64-pc-windows-msvc
|
||||
build: yarn build --target aarch64-pc-windows-msvc
|
||||
- host: ubuntu-latest
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-riscv64-linux-gnu -y
|
||||
build: yarn build --target riscv64gc-unknown-linux-gnu
|
||||
name: stable - ${{ matrix.settings.target }} - node@20
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
- name: Install
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: ${{ matrix.settings.target }}
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
.cargo-cache
|
||||
target/
|
||||
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
|
||||
with:
|
||||
version: 0.13.0
|
||||
- name: Setup toolchain
|
||||
run: ${{ matrix.settings.setup }}
|
||||
if: ${{ matrix.settings.setup }}
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Build in docker
|
||||
uses: addnab/docker-run-action@v3
|
||||
if: ${{ matrix.settings.docker }}
|
||||
with:
|
||||
image: ${{ matrix.settings.docker }}
|
||||
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build/bindings/nodejs'
|
||||
run: ${{ matrix.settings.build }}
|
||||
- name: Build
|
||||
run: ${{ matrix.settings.build }}
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
shell: bash
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bindings-${{ matrix.settings.target }}
|
||||
path: bindings/nodejs/${{ env.APP_NAME }}.*.node
|
||||
if-no-files-found: error
|
||||
test-macOS-windows-binding:
|
||||
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
settings:
|
||||
- host: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
- host: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
node:
|
||||
- '18'
|
||||
- '20'
|
||||
runs-on: ${{ matrix.settings.host }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
architecture: x64
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-${{ matrix.settings.target }}
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Test bindings
|
||||
run: yarn test
|
||||
test-linux-x64-gnu-binding:
|
||||
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '18'
|
||||
- '20'
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-x86_64-unknown-linux-gnu
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Test bindings
|
||||
run: docker run --rm -v $(pwd):/build -w /build/bindings/nodejs node:${{ matrix.node }}-slim yarn test
|
||||
test-linux-x64-musl-binding:
|
||||
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '18'
|
||||
- '20'
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn install
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-x86_64-unknown-linux-musl
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Test bindings
|
||||
run: docker run --rm -v $(pwd):/build -w /build/bindings/nodejs node:${{ matrix.node }}-alpine yarn test
|
||||
test-linux-aarch64-gnu-binding:
|
||||
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '18'
|
||||
- '20'
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-aarch64-unknown-linux-gnu
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
yarn config set supportedArchitectures.cpu "arm64"
|
||||
yarn config set supportedArchitectures.libc "glibc"
|
||||
yarn install
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- name: Setup and run tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: node:${{ matrix.node }}-slim
|
||||
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/bindings/nodejs'
|
||||
run: |
|
||||
set -e
|
||||
yarn test
|
||||
ls -la
|
||||
test-linux-aarch64-musl-binding:
|
||||
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-aarch64-unknown-linux-musl
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
yarn config set supportedArchitectures.cpu "arm64"
|
||||
yarn config set supportedArchitectures.libc "musl"
|
||||
yarn install
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- name: Setup and run tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: node:lts-alpine
|
||||
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/bindings/nodejs'
|
||||
run: |
|
||||
set -e
|
||||
yarn test
|
||||
test-linux-arm-gnueabihf-binding:
|
||||
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
|
||||
needs:
|
||||
- build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node:
|
||||
- '18'
|
||||
- '20'
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-armv7-unknown-linux-gnueabihf
|
||||
path: bindings/nodejs/
|
||||
- name: List packages
|
||||
run: ls -R .
|
||||
shell: bash
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
yarn config set supportedArchitectures.cpu "arm"
|
||||
yarn install
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- name: Setup and run tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: node:${{ matrix.node }}-bullseye-slim
|
||||
options: '--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build/bindings/nodejs'
|
||||
run: |
|
||||
set -e
|
||||
yarn test
|
||||
ls -la
|
||||
universal-macOS:
|
||||
name: Build universal macOS binary
|
||||
needs:
|
||||
- build
|
||||
runs-on: macos-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Download macOS x64 artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-x86_64-apple-darwin
|
||||
path: bindings/nodejs/artifacts
|
||||
- name: Download macOS arm64 artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bindings-aarch64-apple-darwin
|
||||
path: bindings/nodejs/artifacts
|
||||
- name: Combine binaries
|
||||
run: yarn universal
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: bindings-universal-apple-darwin
|
||||
path: bindings/nodejs/${{ env.APP_NAME }}.*.node
|
||||
if-no-files-found: error
|
||||
publish:
|
||||
name: Publish
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./bindings/nodejs
|
||||
needs:
|
||||
- test-macOS-windows-binding
|
||||
- test-linux-x64-gnu-binding
|
||||
- test-linux-x64-musl-binding
|
||||
- test-linux-aarch64-gnu-binding
|
||||
- test-linux-aarch64-musl-binding
|
||||
- test-linux-arm-gnueabihf-binding
|
||||
- universal-macOS
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
cache-dependency-path: "bindings/nodejs"
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: bindings/nodejs/artifacts
|
||||
- name: Move artifacts
|
||||
run: yarn artifacts
|
||||
- name: List packages
|
||||
run: ls -R ./npm
|
||||
shell: bash
|
||||
- name: Publish
|
||||
run: |
|
||||
echo "${{ github.event.inputs.publish }}"
|
||||
if [ "${{ github.event.inputs.publish }}" = "true" ]; then
|
||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||
npm publish --access public
|
||||
echo "Published to npm"
|
||||
else
|
||||
echo "Not a release, skipping publish"
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
143
.github/workflows/pypi.yml
vendored
143
.github/workflows/pypi.yml
vendored
@@ -1,143 +0,0 @@
|
||||
name: Upload component to Python Package Index
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
description: "Release? If false, publish to test.pypi.org, if true, publish to pypi.org"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Build wheels
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
args: --release --out dist --find-interpreter
|
||||
sccache: 'true'
|
||||
manylinux: auto
|
||||
working-directory: bindings/python
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/dist
|
||||
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
target: [x64, x86]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
architecture: ${{ matrix.target }}
|
||||
- name: Build wheels
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
args: --release --out dist --find-interpreter
|
||||
sccache: 'true'
|
||||
working-directory: bindings/python
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/dist
|
||||
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
target: [x86_64, aarch64]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Build wheels
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
args: --release --out dist --find-interpreter
|
||||
sccache: 'true'
|
||||
working-directory: bindings/python
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/dist
|
||||
|
||||
sdist:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build sdist
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
command: sdist
|
||||
args: --out dist
|
||||
working-directory: bindings/python
|
||||
- name: Upload sdist
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/dist
|
||||
|
||||
publish-to-test-pypi:
|
||||
if: ${{ github.event.inputs.release != 'true' }}
|
||||
name: >-
|
||||
Publish Python 🐍 distribution 📦 to Test PyPI
|
||||
runs-on: ubuntu-latest
|
||||
needs: [linux, windows, macos, sdist]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/
|
||||
- name: Publish distribution 📦 to Test PyPI
|
||||
uses: PyO3/maturin-action@v1
|
||||
env:
|
||||
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TEST_API_TOKEN }}
|
||||
MATURIN_REPOSITORY_URL: "https://test.pypi.org/legacy/"
|
||||
with:
|
||||
command: upload
|
||||
args: --skip-existing *
|
||||
working-directory: bindings/python
|
||||
|
||||
publish-pypi:
|
||||
if: ${{ github.event.inputs.release == 'true' }}
|
||||
name: >-
|
||||
Publish Python 🐍 distribution 📦 to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
needs: [linux, windows, macos, sdist]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: wheels
|
||||
path: bindings/python/
|
||||
- name: Publish distribution 📦 to PyPI
|
||||
uses: PyO3/maturin-action@v1
|
||||
env:
|
||||
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
||||
MATURIN_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
|
||||
with:
|
||||
command: upload
|
||||
args: --skip-existing *
|
||||
working-directory: bindings/python
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
target/*
|
||||
**/node_modules/**
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
@@ -7,21 +7,12 @@
|
||||
- New function UNICODE ([#128](https://github.com/ironcalc/IronCalc/pull/128))
|
||||
- New document server (Thanks Dani!)
|
||||
- New function FORMULATEXT
|
||||
- Name Manager ([#212](https://github.com/ironcalc/IronCalc/pull/212) [#220](https://github.com/ironcalc/IronCalc/pull/220))
|
||||
- Add context menu. We can now insert rows and columns. Freeze and unfreeze rows and columns. Delete rows and columns [#271]
|
||||
- Add nodejs bindings [#254]
|
||||
- Add python bindings for all platforms
|
||||
- Add is split into the product and widget
|
||||
- Add Python documentation [#260]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed several issues with pasting content
|
||||
- Fixed several issues with borders
|
||||
- Fixed bug where columns and rows could be resized to negative width and height, respectively
|
||||
- Undo/redo when add/delete sheet now works [#270]
|
||||
- Numerous small fixes
|
||||
- Multiple fixes to the documentation
|
||||
|
||||
## [0.2.0] - 2024-11-06 (The HN release)
|
||||
|
||||
|
||||
145
Cargo.lock
generated
145
Cargo.lock
generated
@@ -85,12 +85,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
@@ -216,15 +210,6 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.6"
|
||||
@@ -286,16 +271,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
@@ -414,7 +389,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ironcalc"
|
||||
version = "0.3.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bitcode",
|
||||
"chrono",
|
||||
@@ -430,7 +405,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ironcalc_base"
|
||||
version = "0.3.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bitcode",
|
||||
"chrono",
|
||||
@@ -446,17 +421,6 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ironcalc_nodejs"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"ironcalc",
|
||||
"napi",
|
||||
"napi-build",
|
||||
"napi-derive",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
@@ -496,16 +460,6 @@ version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.21"
|
||||
@@ -536,65 +490,6 @@ dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi"
|
||||
version = "2.16.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "214f07a80874bb96a8433b3cdfc84980d56c7b02e1a0d7ba4ba0db5cef785e2b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"ctor",
|
||||
"napi-derive",
|
||||
"napi-sys",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi-build"
|
||||
version = "2.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db836caddef23662b94e16bf1f26c40eceb09d6aee5d5b06a7ac199320b69b19"
|
||||
|
||||
[[package]]
|
||||
name = "napi-derive"
|
||||
version = "2.16.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cbe2585d8ac223f7d34f13701434b9d5f4eb9c332cccce8dee57ea18ab8ab0c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"convert_case",
|
||||
"napi-derive-backend",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi-derive-backend"
|
||||
version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1639aaa9eeb76e91c6ae66da8ce3e89e921cd3885e99ec85f4abacae72fc91bf"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"semver",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi-sys"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "427802e8ec3a734331fec1035594a210ce1ff4dc5bc1950530920ab717964ea3"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
@@ -721,9 +616,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyo3"
|
||||
version = "0.23.4"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc"
|
||||
checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"indoc",
|
||||
@@ -739,9 +634,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-build-config"
|
||||
version = "0.23.4"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7"
|
||||
checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"target-lexicon",
|
||||
@@ -749,9 +644,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-ffi"
|
||||
version = "0.23.4"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d"
|
||||
checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pyo3-build-config",
|
||||
@@ -759,9 +654,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros"
|
||||
version = "0.23.4"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91871864b353fd5ffcb3f91f2f703a22a9797c91b9ab497b1acac7b07ae509c7"
|
||||
checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"pyo3-macros-backend",
|
||||
@@ -771,9 +666,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros-backend"
|
||||
version = "0.23.4"
|
||||
version = "0.22.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43abc3b80bc20f3facd86cd3c60beed58c3e2aa26213f3cda368de39c60a27e4"
|
||||
checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -784,7 +679,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pyroncalc"
|
||||
version = "0.3.0"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"ironcalc",
|
||||
"pyo3",
|
||||
@@ -884,12 +779,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.197"
|
||||
@@ -1034,12 +923,6 @@ version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||
|
||||
[[package]]
|
||||
name = "unindent"
|
||||
version = "0.2.3"
|
||||
@@ -1070,7 +953,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm"
|
||||
version = "0.3.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"ironcalc_base",
|
||||
"serde",
|
||||
|
||||
@@ -6,12 +6,10 @@ members = [
|
||||
"xlsx",
|
||||
"bindings/wasm",
|
||||
"bindings/python",
|
||||
"bindings/nodejs",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"generate_locale",
|
||||
"webapp/app.ironcalc.com/server",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
||||
5
Makefile
5
Makefile
@@ -2,8 +2,7 @@
|
||||
lint:
|
||||
cargo fmt -- --check
|
||||
cargo clippy --all-targets --all-features -- -W clippy::unwrap_used -W clippy::expect_used -W clippy::panic -D warnings
|
||||
cd webapp/IronCalc/ && npm install && npm run check
|
||||
cd webapp/app.ironcalc.com/frontend/ && npm install && npm run check
|
||||
cd webapp && npm install && npm run check
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
@@ -16,7 +15,7 @@ tests: lint
|
||||
# Regretabbly we need to build the wasm twice, once for the nodejs tests
|
||||
# and a second one for the vitest.
|
||||
cd bindings/wasm/ && wasm-pack build --target nodejs && node tests/test.mjs && make
|
||||
cd webapp/IronCalc/ && npm run test
|
||||
cd webapp && npm run test
|
||||
cd bindings/python && ./run_tests.sh && ./run_examples.sh
|
||||
|
||||
.PHONY: remove-artifacts
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "ironcalc_base"
|
||||
version = "0.3.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Nicolás Hatcher <nicolas@theuniverse.today>"]
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
homepage = "https://www.ironcalc.com"
|
||||
repository = "https://github.com/ironcalc/ironcalc/"
|
||||
description = "Open source spreadsheet engine"
|
||||
description = "The democratization of spreadsheets"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc_base::{Model, types::CellType};
|
||||
use ironcalc_base::{types::CellType, Model};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("formulas-and-errors", "en", "UTC")?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc_base::{Model, cell::CellValue};
|
||||
use ironcalc_base::{cell::CellValue, Model};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("hello-world", "en", "UTC")?;
|
||||
|
||||
@@ -136,33 +136,6 @@ impl Model {
|
||||
}),
|
||||
);
|
||||
|
||||
// In the list of columns:
|
||||
// * Keep all the columns to the left
|
||||
// * Displace all the columns to the right
|
||||
|
||||
let worksheet = &mut self.workbook.worksheet_mut(sheet)?;
|
||||
|
||||
let mut new_columns = Vec::new();
|
||||
for col in worksheet.cols.iter_mut() {
|
||||
// range under study
|
||||
let min = col.min;
|
||||
let max = col.max;
|
||||
if column > max {
|
||||
// If the range under study is to our left, this is a noop
|
||||
} else if column <= min {
|
||||
// If the range under study is to our right, we displace it
|
||||
col.min = min + column_count;
|
||||
col.max = max + column_count;
|
||||
} else {
|
||||
// If the range under study is in the middle we augment it
|
||||
col.max = max + column_count;
|
||||
}
|
||||
new_columns.push(col.clone());
|
||||
}
|
||||
// TODO: If in a row the cell to the right and left have the same style we should copy it
|
||||
|
||||
worksheet.cols = new_columns;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,3 @@ pub(crate) const LAST_ROW: i32 = 1_048_576;
|
||||
// NaiveDate::from_ymd(1900, 1, 1).num_days_from_ce() - 2
|
||||
// The 2 days offset is because of Excel 1900 bug
|
||||
pub(crate) const EXCEL_DATE_BASE: i32 = 693_594;
|
||||
|
||||
// We do not support dates before 1899-12-31.
|
||||
pub(crate) const MINIMUM_DATE_SERIAL_NUMBER: i32 = 1;
|
||||
|
||||
// Excel can handle dates until the year 9999-12-31
|
||||
// 2958465 is the number of days from 1900-01-01 to 9999-12-31
|
||||
pub(crate) const MAXIMUM_DATE_SERIAL_NUMBER: i32 = 2_958_465;
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{
|
||||
expressions::{
|
||||
parser::{
|
||||
move_formula::ref_is_in_area,
|
||||
stringify::{DisplaceData, to_string, to_string_displaced},
|
||||
stringify::{to_string, to_string_displaced, DisplaceData},
|
||||
walk::forward_references,
|
||||
},
|
||||
types::{Area, CellReferenceIndex, CellReferenceRC},
|
||||
|
||||
@@ -149,16 +149,14 @@ impl Lexer {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_left), position));
|
||||
.set_error(&format!("Failed parsing row {}", row_left), position))
|
||||
}
|
||||
};
|
||||
let row_right = match row_right.parse::<i32>() {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(self.set_error(
|
||||
&format!("Failed parsing row {}", row_right),
|
||||
position,
|
||||
));
|
||||
return Err(self
|
||||
.set_error(&format!("Failed parsing row {}", row_right), position))
|
||||
}
|
||||
};
|
||||
if row_left > LAST_ROW {
|
||||
|
||||
@@ -642,38 +642,7 @@ impl Parser {
|
||||
position: 0,
|
||||
message: "Unexpected end of input.".to_string(),
|
||||
},
|
||||
TokenType::Boolean(value) => {
|
||||
// Could be a function call "TRUE()"
|
||||
let next_token = self.lexer.peek_token();
|
||||
if next_token == TokenType::LeftParenthesis {
|
||||
self.lexer.advance_token();
|
||||
// We parse all the arguments, although technically this is moot
|
||||
// But is has the upside of transforming `=TRUE( 4 )` into `=TRUE(4)`
|
||||
let args = match self.parse_function_args() {
|
||||
Ok(s) => s,
|
||||
Err(e) => return e,
|
||||
};
|
||||
if let Err(err) = self.lexer.expect(TokenType::RightParenthesis) {
|
||||
return Node::ParseErrorKind {
|
||||
formula: self.lexer.get_formula(),
|
||||
position: err.position,
|
||||
message: err.message,
|
||||
};
|
||||
}
|
||||
if value {
|
||||
return Node::FunctionKind {
|
||||
kind: Function::True,
|
||||
args,
|
||||
};
|
||||
} else {
|
||||
return Node::FunctionKind {
|
||||
kind: Function::False,
|
||||
args,
|
||||
};
|
||||
}
|
||||
}
|
||||
Node::BooleanKind(value)
|
||||
}
|
||||
TokenType::Boolean(value) => Node::BooleanKind(value),
|
||||
TokenType::Compare(_) => {
|
||||
// A primary Node cannot start with an operator
|
||||
Node::ParseErrorKind {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{
|
||||
stringify::{stringify_reference, DisplaceData},
|
||||
Node, Reference,
|
||||
stringify::{DisplaceData, stringify_reference},
|
||||
};
|
||||
use crate::{
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::lexer::LexerMode;
|
||||
use crate::expressions::parser::stringify::{
|
||||
DisplaceData, to_rc_format, to_string, to_string_displaced,
|
||||
to_rc_format, to_string, to_string_displaced, DisplaceData,
|
||||
};
|
||||
use crate::expressions::parser::{Node, Parser};
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::move_formula::{move_formula, MoveContext};
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::move_formula::{MoveContext, move_formula};
|
||||
use crate::expressions::types::{Area, CellReferenceRC};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::lexer::LexerMode;
|
||||
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::{to_rc_format, to_string};
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
struct Formula<'a> {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::parser::stringify::to_string;
|
||||
use crate::expressions::parser::Parser;
|
||||
use crate::expressions::types::CellReferenceRC;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{Node, move_formula::ref_is_in_area};
|
||||
use super::{move_formula::ref_is_in_area, Node};
|
||||
|
||||
use crate::expressions::types::{Area, CellReferenceIndex};
|
||||
|
||||
|
||||
@@ -1,158 +1,18 @@
|
||||
use chrono::Datelike;
|
||||
use chrono::Days;
|
||||
use chrono::Duration;
|
||||
use chrono::Months;
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::constants::EXCEL_DATE_BASE;
|
||||
use crate::constants::MAXIMUM_DATE_SERIAL_NUMBER;
|
||||
use crate::constants::MINIMUM_DATE_SERIAL_NUMBER;
|
||||
|
||||
#[inline]
|
||||
fn convert_to_serial_number(date: NaiveDate) -> i32 {
|
||||
date.num_days_from_ce() - EXCEL_DATE_BASE
|
||||
}
|
||||
|
||||
fn is_date_within_range(date: NaiveDate) -> bool {
|
||||
convert_to_serial_number(date) >= MINIMUM_DATE_SERIAL_NUMBER
|
||||
&& convert_to_serial_number(date) <= MAXIMUM_DATE_SERIAL_NUMBER
|
||||
}
|
||||
|
||||
pub fn from_excel_date(days: i64) -> Result<NaiveDate, String> {
|
||||
if days < MINIMUM_DATE_SERIAL_NUMBER as i64 {
|
||||
return Err(format!(
|
||||
"Excel date must be greater than {}",
|
||||
MINIMUM_DATE_SERIAL_NUMBER
|
||||
));
|
||||
};
|
||||
if days > MAXIMUM_DATE_SERIAL_NUMBER as i64 {
|
||||
return Err(format!(
|
||||
"Excel date must be less than {}",
|
||||
MAXIMUM_DATE_SERIAL_NUMBER
|
||||
));
|
||||
};
|
||||
pub fn from_excel_date(days: i64) -> NaiveDate {
|
||||
#[allow(clippy::expect_used)]
|
||||
let dt = NaiveDate::from_ymd_opt(1900, 1, 1).expect("problem with chrono::NaiveDate");
|
||||
Ok(dt + Duration::days(days - 2))
|
||||
dt + Duration::days(days - 2)
|
||||
}
|
||||
|
||||
pub fn date_to_serial_number(day: u32, month: u32, year: i32) -> Result<i32, String> {
|
||||
match NaiveDate::from_ymd_opt(year, month, day) {
|
||||
Some(native_date) => Ok(convert_to_serial_number(native_date)),
|
||||
Some(native_date) => Ok(native_date.num_days_from_ce() - EXCEL_DATE_BASE),
|
||||
None => Err("Out of range parameters for date".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn permissive_date_to_serial_number(day: i32, month: i32, year: i32) -> Result<i32, String> {
|
||||
// Excel parses `DATE` very permissively. It allows not just for valid date values, but it
|
||||
// allows for invalid dates as well. If you for example enter `DATE(1900, 1, 32)` it will
|
||||
// return the date `1900-02-01`. Despite giving a day that is out of range it will just
|
||||
// wrap the month and year around.
|
||||
//
|
||||
// This function applies that same logic to dates. And does it in the most compatible way as
|
||||
// possible.
|
||||
|
||||
// Special case for the minimum date
|
||||
if year == 1899 && month == 12 && day == 31 {
|
||||
return Ok(MINIMUM_DATE_SERIAL_NUMBER);
|
||||
}
|
||||
let Some(mut date) = NaiveDate::from_ymd_opt(year, 1, 1) else {
|
||||
return Err("Out of range parameters for date".to_string());
|
||||
};
|
||||
|
||||
// One thing to note for example is that even if you started with a year out of range
|
||||
// but tried to increment the months so that it wraps around into within range, excel
|
||||
// would still return an error.
|
||||
//
|
||||
// I.E. DATE(0,13,-1) will return an error, despite it being equivalent to DATE(1,1,0) which
|
||||
// is within range.
|
||||
//
|
||||
// As a result, we have to run range checks as we parse the date from the biggest unit to the
|
||||
// smallest unit.
|
||||
if !is_date_within_range(date) {
|
||||
return Err("Out of range parameters for date".to_string());
|
||||
}
|
||||
|
||||
date = {
|
||||
let month_diff = month - 1;
|
||||
let abs_month = month_diff.unsigned_abs();
|
||||
if month_diff <= 0 {
|
||||
date = date - Months::new(abs_month);
|
||||
} else {
|
||||
date = date + Months::new(abs_month);
|
||||
}
|
||||
if !is_date_within_range(date) {
|
||||
return Err("Out of range parameters for date".to_string());
|
||||
}
|
||||
date
|
||||
};
|
||||
|
||||
date = {
|
||||
let day_diff = day - 1;
|
||||
let abs_day = day_diff.unsigned_abs() as u64;
|
||||
if day_diff <= 0 {
|
||||
date = date - Days::new(abs_day);
|
||||
} else {
|
||||
date = date + Days::new(abs_day);
|
||||
}
|
||||
if !is_date_within_range(date) {
|
||||
return Err("Out of range parameters for date".to_string());
|
||||
}
|
||||
date
|
||||
};
|
||||
|
||||
Ok(convert_to_serial_number(date))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_permissive_date_to_serial_number() {
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(42, 42, 2002),
|
||||
date_to_serial_number(12, 7, 2005)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(1, 42, 2002),
|
||||
date_to_serial_number(1, 6, 2005)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(1, 15, 2000),
|
||||
date_to_serial_number(1, 3, 2001)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(1, 49, 2000),
|
||||
date_to_serial_number(1, 1, 2004)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(1, 49, 2000),
|
||||
date_to_serial_number(1, 1, 2004)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(31, 49, 2000),
|
||||
date_to_serial_number(31, 1, 2004)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(256, 49, 2000),
|
||||
date_to_serial_number(12, 9, 2004)
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(256, 1, 2004),
|
||||
date_to_serial_number(12, 9, 2004)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_max_and_min_dates() {
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(31, 12, 9999),
|
||||
Ok(MAXIMUM_DATE_SERIAL_NUMBER),
|
||||
);
|
||||
assert_eq!(
|
||||
permissive_date_to_serial_number(31, 12, 1899),
|
||||
Ok(MINIMUM_DATE_SERIAL_NUMBER),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,16 +154,15 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
||||
ParsePart::Date(p) => {
|
||||
let tokens = &p.tokens;
|
||||
let mut text = "".to_string();
|
||||
let date = match from_excel_date(value as i64) {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
return Formatted {
|
||||
text: "#VALUE!".to_owned(),
|
||||
color: None,
|
||||
error: Some(e),
|
||||
};
|
||||
}
|
||||
};
|
||||
if !(1.0..=2_958_465.0).contains(&value) {
|
||||
// 2_958_465 is 31 December 9999
|
||||
return Formatted {
|
||||
text: "#VALUE!".to_owned(),
|
||||
color: None,
|
||||
error: Some("Date negative or too long".to_owned()),
|
||||
};
|
||||
}
|
||||
let date = from_excel_date(value as i64);
|
||||
for token in tokens {
|
||||
match token {
|
||||
TextToken::Literal(c) => {
|
||||
@@ -391,7 +390,11 @@ pub fn format_number(value_original: f64, format: &str, locale: &Locale) -> Form
|
||||
if l_exp <= p.exponent_digit_count {
|
||||
if !(number_index < 0 && digit.kind == '#') {
|
||||
let c = if number_index < 0 {
|
||||
if digit.kind == '?' { ' ' } else { '0' }
|
||||
if digit.kind == '?' {
|
||||
' '
|
||||
} else {
|
||||
'0'
|
||||
}
|
||||
} else {
|
||||
exponent_part[number_index as usize]
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{
|
||||
formatter::format::format_number,
|
||||
locale::{Locale, get_locale},
|
||||
locale::{get_locale, Locale},
|
||||
};
|
||||
|
||||
fn get_default_locale() -> &'static Locale {
|
||||
|
||||
@@ -3,11 +3,8 @@ use chrono::Datelike;
|
||||
use chrono::Months;
|
||||
use chrono::Timelike;
|
||||
|
||||
use crate::constants::MAXIMUM_DATE_SERIAL_NUMBER;
|
||||
use crate::constants::MINIMUM_DATE_SERIAL_NUMBER;
|
||||
use crate::expressions::types::CellReferenceIndex;
|
||||
use crate::formatter::dates::date_to_serial_number;
|
||||
use crate::formatter::dates::permissive_date_to_serial_number;
|
||||
use crate::model::get_milliseconds_since_epoch;
|
||||
use crate::{
|
||||
calc_result::CalcResult, constants::EXCEL_DATE_BASE, expressions::parser::Node,
|
||||
@@ -21,19 +18,20 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let serial_number = match self.get_number(&args[0], cell) {
|
||||
Ok(c) => c.floor() as i64,
|
||||
Ok(c) => {
|
||||
let t = c.floor() as i64;
|
||||
if t < 0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Function DAY parameter 1 value is negative. It should be positive or zero.".to_string(),
|
||||
};
|
||||
}
|
||||
t
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
let date = match from_excel_date(serial_number) {
|
||||
Ok(date) => date,
|
||||
Err(_) => {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
};
|
||||
let date = from_excel_date(serial_number);
|
||||
let day = date.day() as f64;
|
||||
CalcResult::Number(day)
|
||||
}
|
||||
@@ -44,19 +42,20 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let serial_number = match self.get_number(&args[0], cell) {
|
||||
Ok(c) => c.floor() as i64,
|
||||
Ok(c) => {
|
||||
let t = c.floor() as i64;
|
||||
if t < 0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Function MONTH parameter 1 value is negative. It should be positive or zero.".to_string(),
|
||||
};
|
||||
}
|
||||
t
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
let date = match from_excel_date(serial_number) {
|
||||
Ok(date) => date,
|
||||
Err(_) => {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
};
|
||||
let date = from_excel_date(serial_number);
|
||||
let month = date.month() as f64;
|
||||
CalcResult::Number(month)
|
||||
}
|
||||
@@ -80,23 +79,6 @@ impl Model {
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
let date = match from_excel_date(serial_number) {
|
||||
Ok(date) => date,
|
||||
Err(_) => {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
};
|
||||
if serial_number > MAXIMUM_DATE_SERIAL_NUMBER as i64 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Function DAY parameter 1 value is too large.".to_string(),
|
||||
};
|
||||
}
|
||||
|
||||
let months = match self.get_number_no_bools(&args[1], cell) {
|
||||
Ok(c) => {
|
||||
@@ -109,9 +91,9 @@ impl Model {
|
||||
let months_abs = months.unsigned_abs();
|
||||
|
||||
let native_date = if months > 0 {
|
||||
date + Months::new(months_abs)
|
||||
from_excel_date(serial_number) + Months::new(months_abs)
|
||||
} else {
|
||||
date - Months::new(months_abs)
|
||||
from_excel_date(serial_number) - Months::new(months_abs)
|
||||
};
|
||||
|
||||
// Instead of calculating the end of month we compute the first day of the following month
|
||||
@@ -155,18 +137,32 @@ impl Model {
|
||||
let month = match self.get_number(&args[1], cell) {
|
||||
Ok(c) => {
|
||||
let t = c.floor();
|
||||
t as i32
|
||||
if t < 0.0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
t as u32
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
let day = match self.get_number(&args[2], cell) {
|
||||
Ok(c) => {
|
||||
let t = c.floor();
|
||||
t as i32
|
||||
if t < 0.0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
t as u32
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
match permissive_date_to_serial_number(day, month, year) {
|
||||
match date_to_serial_number(day, month, year) {
|
||||
Ok(serial_number) => CalcResult::Number(serial_number as f64),
|
||||
Err(message) => CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
@@ -182,19 +178,20 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let serial_number = match self.get_number(&args[0], cell) {
|
||||
Ok(c) => c.floor() as i64,
|
||||
Ok(c) => {
|
||||
let t = c.floor() as i64;
|
||||
if t < 0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Function YEAR parameter 1 value is negative. It should be positive or zero.".to_string(),
|
||||
};
|
||||
}
|
||||
t
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
let date = match from_excel_date(serial_number) {
|
||||
Ok(date) => date,
|
||||
Err(_) => {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
}
|
||||
};
|
||||
let date = from_excel_date(serial_number);
|
||||
let year = date.year() as f64;
|
||||
CalcResult::Number(year)
|
||||
}
|
||||
@@ -206,18 +203,19 @@ impl Model {
|
||||
return CalcResult::new_args_number_error(cell);
|
||||
}
|
||||
let serial_number = match self.get_number(&args[0], cell) {
|
||||
Ok(c) => c.floor() as i64,
|
||||
Err(s) => return s,
|
||||
};
|
||||
let date = match from_excel_date(serial_number) {
|
||||
Ok(date) => date,
|
||||
Err(_) => {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Out of range parameters for date".to_string(),
|
||||
};
|
||||
Ok(c) => {
|
||||
let t = c.floor() as i64;
|
||||
if t < 0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Parameter 1 value is negative. It should be positive or zero."
|
||||
.to_string(),
|
||||
};
|
||||
}
|
||||
t
|
||||
}
|
||||
Err(s) => return s,
|
||||
};
|
||||
|
||||
let months = match self.get_number(&args[1], cell) {
|
||||
@@ -231,13 +229,13 @@ impl Model {
|
||||
let months_abs = months.unsigned_abs();
|
||||
|
||||
let native_date = if months > 0 {
|
||||
date + Months::new(months_abs)
|
||||
from_excel_date(serial_number) + Months::new(months_abs)
|
||||
} else {
|
||||
date - Months::new(months_abs)
|
||||
from_excel_date(serial_number) - Months::new(months_abs)
|
||||
};
|
||||
|
||||
let serial_number = native_date.num_days_from_ce() - EXCEL_DATE_BASE;
|
||||
if serial_number < MINIMUM_DATE_SERIAL_NUMBER {
|
||||
if serial_number < 0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
@@ -266,7 +264,7 @@ impl Model {
|
||||
error: Error::ERROR,
|
||||
origin: cell,
|
||||
message: "Invalid date".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
// 693_594 is computed as:
|
||||
@@ -296,7 +294,7 @@ impl Model {
|
||||
error: Error::ERROR,
|
||||
origin: cell,
|
||||
message: "Invalid date".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
// 693_594 is computed as:
|
||||
|
||||
@@ -188,7 +188,10 @@ impl Model {
|
||||
node: &Node,
|
||||
cell: CellReferenceIndex,
|
||||
) -> Result<(f64, f64, Suffix), CalcResult> {
|
||||
let value = self.get_string(node, cell)?;
|
||||
let value = match self.get_string(node, cell) {
|
||||
Ok(s) => s,
|
||||
Err(s) => return Err(s),
|
||||
};
|
||||
if value.is_empty() {
|
||||
return Ok((0.0, 0.0, Suffix::I));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
use std::f64::consts::FRAC_2_PI;
|
||||
|
||||
use super::bessel_util::{FRAC_2_SQRT_PI, HUGE, high_word, split_words};
|
||||
use super::bessel_util::{high_word, split_words, FRAC_2_SQRT_PI, HUGE};
|
||||
|
||||
// R0/S0 on [0, 2.00]
|
||||
const R02: f64 = 1.562_499_999_999_999_5e-2; // 0x3F8FFFFF, 0xFFFFFFFD
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
use std::f64::consts::FRAC_2_PI;
|
||||
|
||||
use super::bessel_util::{FRAC_2_SQRT_PI, HUGE, high_word, split_words};
|
||||
use super::bessel_util::{high_word, split_words, FRAC_2_SQRT_PI, HUGE};
|
||||
|
||||
// R0/S0 on [0,2]
|
||||
const R00: f64 = -6.25e-2; // 0xBFB00000, 0x00000000
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
use super::{
|
||||
bessel_j0_y0::{j0, y0},
|
||||
bessel_j1_y1::{j1, y1},
|
||||
bessel_util::{FRAC_2_SQRT_PI, split_words},
|
||||
bessel_util::{split_words, FRAC_2_SQRT_PI},
|
||||
};
|
||||
|
||||
// Special cases are:
|
||||
@@ -232,7 +232,11 @@ pub(crate) fn jn(n: i32, x: f64) -> f64 {
|
||||
}
|
||||
}
|
||||
};
|
||||
if sign == 1 { -b } else { b }
|
||||
if sign == 1 {
|
||||
-b
|
||||
} else {
|
||||
b
|
||||
}
|
||||
}
|
||||
|
||||
// Yn returns the order-n Bessel function of the second kind.
|
||||
@@ -317,5 +321,9 @@ pub(crate) fn yn(n: i32, x: f64) -> f64 {
|
||||
}
|
||||
b
|
||||
};
|
||||
if sign > 0 { b } else { -b }
|
||||
if sign > 0 {
|
||||
b
|
||||
} else {
|
||||
-b
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,9 @@ pub(crate) fn erf(x: f64) -> f64 {
|
||||
}
|
||||
|
||||
let res = t * f64::exp(-x_abs * x_abs + 0.5 * (cof[0] + ty * d) - dd);
|
||||
if x < 0.0 { res - 1.0 } else { 1.0 - res }
|
||||
if x < 0.0 {
|
||||
res - 1.0
|
||||
} else {
|
||||
1.0 - res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use chrono::Datelike;
|
||||
|
||||
use crate::{
|
||||
calc_result::CalcResult,
|
||||
constants::{LAST_COLUMN, LAST_ROW, MAXIMUM_DATE_SERIAL_NUMBER, MINIMUM_DATE_SERIAL_NUMBER},
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
expressions::{parser::Node, token::Error, types::CellReferenceIndex},
|
||||
formatter::dates::from_excel_date,
|
||||
model::Model,
|
||||
@@ -13,32 +13,37 @@ use super::financial_util::{compute_irr, compute_npv, compute_rate, compute_xirr
|
||||
// See:
|
||||
// https://github.com/apache/openoffice/blob/c014b5f2b55cff8d4b0c952d5c16d62ecde09ca1/main/scaddins/source/analysis/financial.cxx
|
||||
|
||||
fn is_less_than_one_year(start_date: i64, end_date: i64) -> Result<bool, String> {
|
||||
let end = from_excel_date(end_date)?;
|
||||
let start = from_excel_date(start_date)?;
|
||||
// FIXME: Is this enough?
|
||||
fn is_valid_date(date: f64) -> bool {
|
||||
date > 0.0
|
||||
}
|
||||
|
||||
fn is_less_than_one_year(start_date: i64, end_date: i64) -> bool {
|
||||
if end_date - start_date < 365 {
|
||||
return Ok(true);
|
||||
return true;
|
||||
}
|
||||
let end = from_excel_date(end_date);
|
||||
let start = from_excel_date(start_date);
|
||||
let end_year = end.year();
|
||||
let start_year = start.year();
|
||||
if end_year == start_year {
|
||||
return Ok(true);
|
||||
return true;
|
||||
}
|
||||
if end_year != start_year + 1 {
|
||||
return Ok(false);
|
||||
return false;
|
||||
}
|
||||
let start_month = start.month();
|
||||
let end_month = end.month();
|
||||
if end_month < start_month {
|
||||
return Ok(true);
|
||||
return true;
|
||||
}
|
||||
if end_month > start_month {
|
||||
return Ok(false);
|
||||
return false;
|
||||
}
|
||||
// we are one year later same month
|
||||
let start_day = start.day();
|
||||
let end_day = end.day();
|
||||
Ok(end_day <= start_day)
|
||||
end_day <= start_day
|
||||
}
|
||||
|
||||
fn compute_payment(
|
||||
@@ -431,7 +436,7 @@ impl Model {
|
||||
}
|
||||
if rate == -1.0 {
|
||||
return CalcResult::Error {
|
||||
error: Error::DIV,
|
||||
error: Error::NUM,
|
||||
origin: cell,
|
||||
message: "Rate must be != -1".to_string(),
|
||||
};
|
||||
@@ -698,7 +703,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
CalcResult::Number(ipmt)
|
||||
@@ -762,7 +767,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
CalcResult::Number(ppmt)
|
||||
@@ -918,9 +923,7 @@ impl Model {
|
||||
}
|
||||
let first_date = dates[0];
|
||||
for date in &dates {
|
||||
if *date < MINIMUM_DATE_SERIAL_NUMBER as f64
|
||||
|| *date > MAXIMUM_DATE_SERIAL_NUMBER as f64
|
||||
{
|
||||
if !is_valid_date(*date) {
|
||||
// Excel docs claim that if any number in dates is not a valid date,
|
||||
// XNPV returns the #VALUE! error value, but it seems to return #VALUE!
|
||||
return CalcResult::new_error(
|
||||
@@ -986,9 +989,7 @@ impl Model {
|
||||
}
|
||||
let first_date = dates[0];
|
||||
for date in &dates {
|
||||
if *date < MINIMUM_DATE_SERIAL_NUMBER as f64
|
||||
|| *date > MAXIMUM_DATE_SERIAL_NUMBER as f64
|
||||
{
|
||||
if !is_valid_date(*date) {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
cell,
|
||||
@@ -1075,7 +1076,7 @@ impl Model {
|
||||
error,
|
||||
origin: cell,
|
||||
message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1096,7 +1097,7 @@ impl Model {
|
||||
error,
|
||||
origin: cell,
|
||||
message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1372,10 +1373,9 @@ impl Model {
|
||||
Ok(f) => f,
|
||||
Err(s) => return s,
|
||||
};
|
||||
let less_than_one_year = match is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
Ok(f) => f,
|
||||
Err(_) => return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string()),
|
||||
};
|
||||
if !is_valid_date(settlement) || !is_valid_date(maturity) {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string());
|
||||
}
|
||||
if settlement > maturity {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
@@ -1383,7 +1383,7 @@ impl Model {
|
||||
"settlement should be <= maturity".to_string(),
|
||||
);
|
||||
}
|
||||
if !less_than_one_year {
|
||||
if !is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
cell,
|
||||
@@ -1437,10 +1437,9 @@ impl Model {
|
||||
Ok(f) => f,
|
||||
Err(s) => return s,
|
||||
};
|
||||
let less_than_one_year = match is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
Ok(f) => f,
|
||||
Err(_) => return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string()),
|
||||
};
|
||||
if !is_valid_date(settlement) || !is_valid_date(maturity) {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string());
|
||||
}
|
||||
if settlement > maturity {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
@@ -1448,7 +1447,7 @@ impl Model {
|
||||
"settlement should be <= maturity".to_string(),
|
||||
);
|
||||
}
|
||||
if !less_than_one_year {
|
||||
if !is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
cell,
|
||||
@@ -1488,10 +1487,9 @@ impl Model {
|
||||
Ok(f) => f,
|
||||
Err(s) => return s,
|
||||
};
|
||||
let less_than_one_year = match is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
Ok(f) => f,
|
||||
Err(_) => return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string()),
|
||||
};
|
||||
if !is_valid_date(settlement) || !is_valid_date(maturity) {
|
||||
return CalcResult::new_error(Error::NUM, cell, "Invalid date".to_string());
|
||||
}
|
||||
if settlement > maturity {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
@@ -1499,7 +1497,7 @@ impl Model {
|
||||
"settlement should be <= maturity".to_string(),
|
||||
);
|
||||
}
|
||||
if !less_than_one_year {
|
||||
if !is_less_than_one_year(settlement as i64, maturity as i64) {
|
||||
return CalcResult::new_error(
|
||||
Error::NUM,
|
||||
cell,
|
||||
@@ -1634,7 +1632,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1702,7 +1700,7 @@ impl Model {
|
||||
error: error.0,
|
||||
origin: cell,
|
||||
message: error.1,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1750,7 +1748,11 @@ impl Model {
|
||||
rate = 1.0
|
||||
};
|
||||
let value = if rate == 1.0 {
|
||||
if period == 1.0 { cost } else { 0.0 }
|
||||
if period == 1.0 {
|
||||
cost
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
} else {
|
||||
cost * (1.0 - rate).powf(period - 1.0)
|
||||
};
|
||||
|
||||
@@ -257,10 +257,10 @@ impl Model {
|
||||
{
|
||||
match defined_name {
|
||||
ParsedDefinedName::CellReference(reference) => {
|
||||
return CalcResult::Number(reference.sheet as f64 + 1.0);
|
||||
return CalcResult::Number(reference.sheet as f64 + 1.0)
|
||||
}
|
||||
ParsedDefinedName::RangeReference(range) => {
|
||||
return CalcResult::Number(range.left.sheet as f64 + 1.0);
|
||||
return CalcResult::Number(range.left.sheet as f64 + 1.0)
|
||||
}
|
||||
ParsedDefinedName::InvalidDefinedNameFormula => {
|
||||
return CalcResult::Error {
|
||||
@@ -296,7 +296,7 @@ impl Model {
|
||||
error: Error::NAME,
|
||||
origin: cell,
|
||||
message: format!("Name not found: {name}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
arg => {
|
||||
// Now it should be the name of a sheet
|
||||
|
||||
@@ -7,22 +7,6 @@ use crate::{
|
||||
use super::util::compare_values;
|
||||
|
||||
impl Model {
|
||||
pub(crate) fn fn_true(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.is_empty() {
|
||||
CalcResult::Boolean(true)
|
||||
} else {
|
||||
CalcResult::new_args_number_error(cell)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn fn_false(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.is_empty() {
|
||||
CalcResult::Boolean(false)
|
||||
} else {
|
||||
CalcResult::new_args_number_error(cell)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn fn_if(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
|
||||
if args.len() == 2 || args.len() == 3 {
|
||||
let cond_result = self.get_boolean(&args[0], cell);
|
||||
|
||||
@@ -949,7 +949,7 @@ impl Model {
|
||||
match kind {
|
||||
// Logical
|
||||
Function::And => self.fn_and(args, cell),
|
||||
Function::False => self.fn_false(args, cell),
|
||||
Function::False => CalcResult::Boolean(false),
|
||||
Function::If => self.fn_if(args, cell),
|
||||
Function::Iferror => self.fn_iferror(args, cell),
|
||||
Function::Ifna => self.fn_ifna(args, cell),
|
||||
@@ -957,7 +957,7 @@ impl Model {
|
||||
Function::Not => self.fn_not(args, cell),
|
||||
Function::Or => self.fn_or(args, cell),
|
||||
Function::Switch => self.fn_switch(args, cell),
|
||||
Function::True => self.fn_true(args, cell),
|
||||
Function::True => CalcResult::Boolean(true),
|
||||
Function::Xor => self.fn_xor(args, cell),
|
||||
// Math and trigonometry
|
||||
Function::Sin => self.fn_sin(args, cell),
|
||||
|
||||
@@ -388,7 +388,7 @@ impl Model {
|
||||
Error::ERROR,
|
||||
cell,
|
||||
format!("Invalid worksheet index: '{}'", first_range.left.sheet),
|
||||
);
|
||||
)
|
||||
}
|
||||
};
|
||||
let max_row = dimension.max_row;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
calc_result::CalcResult,
|
||||
expressions::{
|
||||
parser::{Node, parse_range},
|
||||
parser::{parse_range, Node},
|
||||
token::Error,
|
||||
types::CellReferenceIndex,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
text_util::{Case, substitute, text_after, text_before},
|
||||
text_util::{substitute, text_after, text_before, Case},
|
||||
util::from_wildcard_to_regex,
|
||||
};
|
||||
|
||||
@@ -368,7 +368,7 @@ impl Model {
|
||||
error: Error::VALUE,
|
||||
origin: cell,
|
||||
message: "Empty cell".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -629,7 +629,7 @@ impl Model {
|
||||
error: Error::VALUE,
|
||||
origin: cell,
|
||||
message: "Expecting number".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
error @ CalcResult::Error { .. } => return error,
|
||||
CalcResult::Range { .. } => {
|
||||
|
||||
@@ -57,8 +57,8 @@ mod test;
|
||||
#[cfg(test)]
|
||||
pub mod mock_time;
|
||||
|
||||
pub use model::Model;
|
||||
pub use model::get_milliseconds_since_epoch;
|
||||
pub use model::Model;
|
||||
pub use user_model::BorderArea;
|
||||
pub use user_model::ClipboardData;
|
||||
pub use user_model::UserModel;
|
||||
|
||||
@@ -10,11 +10,11 @@ use crate::{
|
||||
expressions::{
|
||||
lexer::LexerMode,
|
||||
parser::{
|
||||
Node, Parser,
|
||||
move_formula::{MoveContext, move_formula},
|
||||
move_formula::{move_formula, MoveContext},
|
||||
stringify::{rename_defined_name_in_node, to_rc_format, to_string},
|
||||
Node, Parser,
|
||||
},
|
||||
token::{Error, OpCompare, OpProduct, OpSum, OpUnary, get_error_by_name},
|
||||
token::{get_error_by_name, Error, OpCompare, OpProduct, OpSum, OpUnary},
|
||||
types::*,
|
||||
utils::{self, is_valid_column_number, is_valid_identifier, is_valid_row},
|
||||
},
|
||||
@@ -24,8 +24,8 @@ use crate::{
|
||||
},
|
||||
functions::util::compare_values,
|
||||
implicit_intersection::implicit_intersection,
|
||||
language::{Language, get_language},
|
||||
locale::{Currency, Locale, get_locale},
|
||||
language::{get_language, Language},
|
||||
locale::{get_locale, Currency, Locale},
|
||||
types::*,
|
||||
utils as common,
|
||||
};
|
||||
@@ -960,7 +960,10 @@ impl Model {
|
||||
}
|
||||
}
|
||||
}
|
||||
let sheet = self.get_sheet_index_by_name(&sheet_name)?;
|
||||
let sheet = match self.get_sheet_index_by_name(&sheet_name) {
|
||||
Some(s) => s,
|
||||
None => return None,
|
||||
};
|
||||
let row = match row.parse::<i32>() {
|
||||
Ok(r) => r,
|
||||
Err(_) => return None,
|
||||
@@ -1872,29 +1875,12 @@ impl Model {
|
||||
}
|
||||
|
||||
/// Returns the style for cell (`sheet`, `row`, `column`)
|
||||
/// If the cell does not have a style defined we check the row, otherwise the column and finally a default
|
||||
pub fn get_style_for_cell(&self, sheet: u32, row: i32, column: i32) -> Result<Style, String> {
|
||||
let style_index = self.get_cell_style_index(sheet, row, column)?;
|
||||
let style = self.workbook.styles.get_style(style_index)?;
|
||||
Ok(style)
|
||||
}
|
||||
|
||||
/// Returns the style defined in a cell if any.
|
||||
pub fn get_cell_style_or_none(
|
||||
&self,
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
column: i32,
|
||||
) -> Result<Option<Style>, String> {
|
||||
let style = self
|
||||
.workbook
|
||||
.worksheet(sheet)?
|
||||
.cell(row, column)
|
||||
.map(|c| self.workbook.styles.get_style(c.get_style()))
|
||||
.transpose();
|
||||
style
|
||||
}
|
||||
|
||||
/// Returns an internal binary representation of the workbook
|
||||
///
|
||||
/// See also:
|
||||
@@ -2178,73 +2164,6 @@ impl Model {
|
||||
Err("Defined name not found".to_string())
|
||||
}
|
||||
}
|
||||
/// Returns the style object of a column, if any
|
||||
pub fn get_column_style(&self, sheet: u32, column: i32) -> Result<Option<Style>, String> {
|
||||
if let Some(worksheet) = self.workbook.worksheets.get(sheet as usize) {
|
||||
let cols = &worksheet.cols;
|
||||
for col in cols {
|
||||
if column >= col.min && column <= col.max {
|
||||
if let Some(style_index) = col.style {
|
||||
let style = self.workbook.styles.get_style(style_index)?;
|
||||
return Ok(Some(style));
|
||||
}
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
} else {
|
||||
Err("Invalid sheet".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the style object of a row, if any
|
||||
pub fn get_row_style(&self, sheet: u32, row: i32) -> Result<Option<Style>, String> {
|
||||
if let Some(worksheet) = self.workbook.worksheets.get(sheet as usize) {
|
||||
let rows = &worksheet.rows;
|
||||
for r in rows {
|
||||
if row == r.r {
|
||||
let style = self.workbook.styles.get_style(r.s)?;
|
||||
return Ok(Some(style));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
} else {
|
||||
Err("Invalid sheet".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets a column with style
|
||||
pub fn set_column_style(
|
||||
&mut self,
|
||||
sheet: u32,
|
||||
column: i32,
|
||||
style: &Style,
|
||||
) -> Result<(), String> {
|
||||
let style_index = self.workbook.styles.get_style_index_or_create(style);
|
||||
self.workbook
|
||||
.worksheet_mut(sheet)?
|
||||
.set_column_style(column, style_index)
|
||||
}
|
||||
|
||||
/// Sets a row with style
|
||||
pub fn set_row_style(&mut self, sheet: u32, row: i32, style: &Style) -> Result<(), String> {
|
||||
let style_index = self.workbook.styles.get_style_index_or_create(style);
|
||||
self.workbook
|
||||
.worksheet_mut(sheet)?
|
||||
.set_row_style(row, style_index)
|
||||
}
|
||||
|
||||
/// Deletes the style of a column if the is any
|
||||
pub fn delete_column_style(&mut self, sheet: u32, column: i32) -> Result<(), String> {
|
||||
self.workbook
|
||||
.worksheet_mut(sheet)?
|
||||
.delete_column_style(column)
|
||||
}
|
||||
|
||||
/// Deletes the style of a row if there is any
|
||||
pub fn delete_row_style(&mut self, sheet: u32, row: i32) -> Result<(), String> {
|
||||
self.workbook.worksheet_mut(sheet)?.delete_row_style(row)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -8,14 +8,14 @@ use crate::{
|
||||
expressions::{
|
||||
lexer::LexerMode,
|
||||
parser::{
|
||||
Parser,
|
||||
stringify::{rename_sheet_in_node, to_rc_format},
|
||||
Parser,
|
||||
},
|
||||
types::CellReferenceRC,
|
||||
},
|
||||
language::get_language,
|
||||
locale::get_locale,
|
||||
model::{Model, ParsedDefinedName, get_milliseconds_since_epoch},
|
||||
model::{get_milliseconds_since_epoch, Model, ParsedDefinedName},
|
||||
types::{
|
||||
Metadata, SheetState, Workbook, WorkbookSettings, WorkbookView, Worksheet, WorksheetView,
|
||||
},
|
||||
@@ -301,7 +301,7 @@ impl Model {
|
||||
};
|
||||
if sheet_index >= sheet_count {
|
||||
return Err("Sheet index too large".to_string());
|
||||
};
|
||||
}
|
||||
self.workbook.worksheets.remove(sheet_index as usize);
|
||||
self.reset_parsed_structures();
|
||||
Ok(())
|
||||
|
||||
@@ -150,7 +150,7 @@ pub fn format_number(value: f64, format_code: &str, locale: &str) -> Formatted {
|
||||
text: "#ERROR!".to_owned(),
|
||||
color: None,
|
||||
error: Some("Invalid locale".to_string()),
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
formatter::format::format_number(value, format_code, locale)
|
||||
|
||||
@@ -4,6 +4,8 @@ use crate::{
|
||||
types::{Border, CellStyles, CellXfs, Fill, Font, NumFmt, Style, Styles},
|
||||
};
|
||||
|
||||
// TODO: Move Styles and all related types from crate::types here
|
||||
// Not doing it right now to not have conflicts with exporter branch
|
||||
impl Styles {
|
||||
fn get_font_index(&self, font: &Font) -> Option<i32> {
|
||||
for (font_index, item) in self.fonts.iter().enumerate() {
|
||||
|
||||
@@ -13,7 +13,6 @@ mod test_fn_averageifs;
|
||||
mod test_fn_choose;
|
||||
mod test_fn_concatenate;
|
||||
mod test_fn_count;
|
||||
mod test_fn_day;
|
||||
mod test_fn_exact;
|
||||
mod test_fn_financial;
|
||||
mod test_fn_formulatext;
|
||||
@@ -37,13 +36,11 @@ mod test_model_cell_clear_all;
|
||||
mod test_model_is_empty_cell;
|
||||
mod test_move_formula;
|
||||
mod test_quote_prefix;
|
||||
mod test_row_column_styles;
|
||||
mod test_set_user_input;
|
||||
mod test_sheet_markup;
|
||||
mod test_sheets;
|
||||
mod test_styles;
|
||||
mod test_trigonometric;
|
||||
mod test_true_false;
|
||||
mod test_workbook;
|
||||
mod test_worksheet;
|
||||
pub(crate) mod util;
|
||||
|
||||
@@ -206,11 +206,9 @@ fn test_delete_column_width() {
|
||||
let (sheet, column) = (0, 5);
|
||||
let normal_width = model.get_column_width(sheet, column).unwrap();
|
||||
// Set the width of one column to 5 times the normal width
|
||||
assert!(
|
||||
model
|
||||
.set_column_width(sheet, column, normal_width * 5.0)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(model
|
||||
.set_column_width(sheet, column, normal_width * 5.0)
|
||||
.is_ok());
|
||||
|
||||
// delete it
|
||||
assert!(model.delete_columns(sheet, column, 1).is_ok());
|
||||
|
||||
@@ -37,12 +37,12 @@ fn test_fn_date_arguments() {
|
||||
assert_eq!(model._get_text("A3"), *"#ERROR!");
|
||||
assert_eq!(model._get_text("A4"), *"#ERROR!");
|
||||
|
||||
assert_eq!(model._get_text("A5"), *"10/10/1974");
|
||||
assert_eq!(model._get_text("A6"), *"21/01/1975");
|
||||
assert_eq!(model._get_text("A7"), *"10/02/1976");
|
||||
assert_eq!(model._get_text("A8"), *"02/03/1975");
|
||||
assert_eq!(model._get_text("A5"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A6"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A7"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A8"), *"#NUM!");
|
||||
|
||||
assert_eq!(model._get_text("A9"), *"01/03/1975");
|
||||
assert_eq!(model._get_text("A9"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A10"), *"29/02/1976");
|
||||
assert_eq!(
|
||||
model.get_cell_value_by_ref("Sheet1!A10"),
|
||||
@@ -64,18 +64,15 @@ fn test_date_out_of_range() {
|
||||
|
||||
// year (actually years < 1900 don't really make sense)
|
||||
model._set("C1", "=DATE(-1, 5, 5)");
|
||||
// excel is not compatible with years past 9999
|
||||
model._set("C2", "=DATE(10000, 5, 5)");
|
||||
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"10/12/2021");
|
||||
assert_eq!(model._get_text("A2"), *"10/01/2023");
|
||||
assert_eq!(model._get_text("B1"), *"30/04/2042");
|
||||
assert_eq!(model._get_text("B2"), *"01/06/2025");
|
||||
assert_eq!(model._get_text("A1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A2"), *"#NUM!");
|
||||
assert_eq!(model._get_text("B1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("B2"), *"#NUM!");
|
||||
|
||||
assert_eq!(model._get_text("C1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("C2"), *"#NUM!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -132,7 +129,8 @@ fn test_day_small_serial() {
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A2"), *"#NUM!");
|
||||
// This agrees with Google Docs and disagrees with Excel
|
||||
assert_eq!(model._get_text("A2"), *"30");
|
||||
// Excel thinks is Feb 29, 1900
|
||||
assert_eq!(model._get_text("A3"), *"28");
|
||||
|
||||
@@ -152,7 +150,8 @@ fn test_month_small_serial() {
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A2"), *"#NUM!");
|
||||
// This agrees with Google Docs and disagrees with Excel
|
||||
assert_eq!(model._get_text("A2"), *"12");
|
||||
// We agree with Excel here (We are both in Feb)
|
||||
assert_eq!(model._get_text("A3"), *"2");
|
||||
|
||||
@@ -172,7 +171,8 @@ fn test_year_small_serial() {
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A2"), *"#NUM!");
|
||||
// This agrees with Google Docs and disagrees with Excel
|
||||
assert_eq!(model._get_text("A2"), *"1899");
|
||||
|
||||
assert_eq!(model._get_text("A3"), *"1900");
|
||||
|
||||
@@ -204,10 +204,7 @@ fn test_date_early_dates() {
|
||||
model.get_cell_value_by_ref("Sheet1!A2"),
|
||||
Ok(CellValue::Number(60.0))
|
||||
);
|
||||
|
||||
// This does not agree with Excel, instead of mistakenly allowing
|
||||
// for Feb 29, it will auto-wrap to the next day after Feb 28.
|
||||
assert_eq!(model._get_text("B2"), *"01/03/1900");
|
||||
assert_eq!(model._get_text("B2"), *"#NUM!");
|
||||
|
||||
// This agrees with Excel from he onward
|
||||
assert_eq!(model._get_text("A3"), *"01/03/1900");
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn test_fn_date_arguments() {
|
||||
let mut model = new_empty_model();
|
||||
|
||||
model._set("A1", "=DAY(95051806)");
|
||||
model._set("A2", "=DAY(2958465)");
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"#NUM!");
|
||||
assert_eq!(model._get_text("A2"), *"31");
|
||||
}
|
||||
@@ -179,60 +179,52 @@ fn test_move_formula_rectangle() {
|
||||
width: 2,
|
||||
height: 20,
|
||||
};
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 3,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 2,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 20,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 21,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 3,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 2,
|
||||
row: 1,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 20,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_ok());
|
||||
assert!(model
|
||||
.move_cell_value_to_area(
|
||||
value,
|
||||
&CellReferenceIndex {
|
||||
sheet: 0,
|
||||
column: 1,
|
||||
row: 21,
|
||||
},
|
||||
target,
|
||||
area
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{constants::DEFAULT_COLUMN_WIDTH, test::util::new_empty_model};
|
||||
|
||||
#[test]
|
||||
fn test_model_set_cells_with_values_styles() {
|
||||
let mut model = new_empty_model();
|
||||
|
||||
let style_base = model.get_style_for_cell(0, 1, 1).unwrap();
|
||||
let mut style = style_base.clone();
|
||||
style.font.b = true;
|
||||
|
||||
model.set_column_style(0, 10, &style).unwrap();
|
||||
|
||||
assert!(model.get_style_for_cell(0, 21, 10).unwrap().font.b);
|
||||
|
||||
model.delete_column_style(0, 10).unwrap();
|
||||
|
||||
// There are no styles in the column
|
||||
assert!(model.workbook.worksheets[0].cols.is_empty());
|
||||
|
||||
// lets change the column width and check it does not affect the style
|
||||
model
|
||||
.set_column_width(0, 10, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
model.set_column_style(0, 10, &style).unwrap();
|
||||
|
||||
model.delete_column_style(0, 10).unwrap();
|
||||
|
||||
// There are no styles in the column
|
||||
assert!(model.workbook.worksheets[0].cols.len() == 1);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn true_false_arguments() {
|
||||
let mut model = new_empty_model();
|
||||
model._set("A1", "=TRUE( )");
|
||||
model._set("A2", "=FALSE( )");
|
||||
model._set("A3", "=TRUE( 4 )");
|
||||
model._set("A4", "=FALSE( 4 )");
|
||||
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"TRUE");
|
||||
assert_eq!(model._get_text("A2"), *"FALSE");
|
||||
|
||||
assert_eq!(model._get_formula("A1"), *"=TRUE()");
|
||||
assert_eq!(model._get_formula("A2"), *"=FALSE()");
|
||||
|
||||
assert_eq!(model._get_text("A3"), *"#ERROR!");
|
||||
assert_eq!(model._get_text("A4"), *"#ERROR!");
|
||||
assert_eq!(model._get_formula("A3"), *"=TRUE(4)");
|
||||
assert_eq!(model._get_formula("A4"), *"=FALSE(4)");
|
||||
}
|
||||
@@ -3,9 +3,7 @@ mod test_autofill_columns;
|
||||
mod test_autofill_rows;
|
||||
mod test_border;
|
||||
mod test_clear_cells;
|
||||
mod test_column_style;
|
||||
mod test_defined_names;
|
||||
mod test_delete_row_column_formatting;
|
||||
mod test_diff_queue;
|
||||
mod test_evaluation;
|
||||
mod test_general;
|
||||
@@ -15,11 +13,9 @@ mod test_on_area_selection;
|
||||
mod test_on_expand_selected_range;
|
||||
mod test_on_paste_styles;
|
||||
mod test_paste_csv;
|
||||
mod test_recursive;
|
||||
mod test_rename_sheet;
|
||||
mod test_row_column;
|
||||
mod test_sheet_state;
|
||||
mod test_sheets_undo_redo;
|
||||
mod test_styles;
|
||||
mod test_to_from_bytes;
|
||||
mod test_undo_redo;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{UserModel, constants::DEFAULT_COLUMN_WIDTH};
|
||||
use crate::{constants::DEFAULT_COLUMN_WIDTH, UserModel};
|
||||
|
||||
#[test]
|
||||
fn add_undo_redo() {
|
||||
@@ -9,7 +9,7 @@ fn add_undo_redo() {
|
||||
model.set_user_input(1, 1, 1, "=1 + 1").unwrap();
|
||||
model.set_user_input(1, 1, 2, "=A1*3").unwrap();
|
||||
model
|
||||
.set_columns_width(1, 5, 5, 5.0 * DEFAULT_COLUMN_WIDTH)
|
||||
.set_column_width(1, 5, 5.0 * DEFAULT_COLUMN_WIDTH)
|
||||
.unwrap();
|
||||
model.new_sheet().unwrap();
|
||||
model.set_user_input(2, 1, 1, "=Sheet2!B1").unwrap();
|
||||
@@ -25,6 +25,9 @@ fn add_undo_redo() {
|
||||
assert_eq!(model.get_formatted_cell_value(2, 1, 1), Ok("6".to_string()));
|
||||
|
||||
model.delete_sheet(1).unwrap();
|
||||
|
||||
assert!(!model.can_undo());
|
||||
assert!(!model.can_redo());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
BorderArea, UserModel,
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
expressions::{types::Area, utils::number_to_column},
|
||||
types::{Border, BorderItem, BorderStyle},
|
||||
BorderArea, UserModel,
|
||||
};
|
||||
|
||||
// checks there are no borders in the sheet
|
||||
@@ -520,19 +520,14 @@ fn borders_top() {
|
||||
.unwrap();
|
||||
model.set_area_with_border(range, &border_area).unwrap();
|
||||
check_borders(&model);
|
||||
for row in 4..9 {
|
||||
for row in 5..9 {
|
||||
for column in 6..9 {
|
||||
let style = model.get_cell_style(0, row, column).unwrap();
|
||||
let border_item = BorderItem {
|
||||
style: BorderStyle::Thin,
|
||||
color: Some("#FF5566".to_string()),
|
||||
};
|
||||
let bottom = if row != 4 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
};
|
||||
let top = if row != 5 {
|
||||
let bottom = if row == 8 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
@@ -542,7 +537,7 @@ fn borders_top() {
|
||||
diagonal_down: false,
|
||||
left: None,
|
||||
right: None,
|
||||
top,
|
||||
top: Some(border_item.clone()),
|
||||
bottom,
|
||||
diagonal: None,
|
||||
};
|
||||
@@ -652,12 +647,12 @@ fn borders_right() {
|
||||
style: BorderStyle::Thin,
|
||||
color: Some("#FF5566".to_string()),
|
||||
};
|
||||
let left = if column != 9 {
|
||||
let left = if column == 6 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
};
|
||||
let right = if column != 8 {
|
||||
let right = if column == 9 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
@@ -710,7 +705,7 @@ fn borders_bottom() {
|
||||
color: Some("#FF5566".to_string()),
|
||||
};
|
||||
// The top will also have a value for all but the first one
|
||||
let bottom = if row != 8 {
|
||||
let top = if row == 5 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
@@ -720,8 +715,8 @@ fn borders_bottom() {
|
||||
diagonal_down: false,
|
||||
left: None,
|
||||
right: None,
|
||||
top: None,
|
||||
bottom,
|
||||
top,
|
||||
bottom: Some(border_item.clone()),
|
||||
diagonal: None,
|
||||
};
|
||||
assert_eq!(style.border, expected_border);
|
||||
@@ -756,13 +751,18 @@ fn borders_left() {
|
||||
model.set_area_with_border(range, &border_area).unwrap();
|
||||
|
||||
for row in 5..9 {
|
||||
for column in 6..9 {
|
||||
for column in 5..9 {
|
||||
let style = model.get_cell_style(0, row, column).unwrap();
|
||||
let border_item = BorderItem {
|
||||
style: BorderStyle::Thin,
|
||||
color: Some("#FF5566".to_string()),
|
||||
};
|
||||
let left = if column != 6 {
|
||||
let left = if column == 5 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
};
|
||||
let right = if column == 8 {
|
||||
None
|
||||
} else {
|
||||
Some(border_item.clone())
|
||||
@@ -771,29 +771,13 @@ fn borders_left() {
|
||||
diagonal_up: false,
|
||||
diagonal_down: false,
|
||||
left,
|
||||
right: None,
|
||||
right,
|
||||
top: None,
|
||||
bottom: None,
|
||||
diagonal: None,
|
||||
};
|
||||
assert_eq!(style.border, expected_border);
|
||||
}
|
||||
// Column 5 has a border to the right, of course:
|
||||
let style = model.get_cell_style(0, row, 5).unwrap();
|
||||
let border_item = BorderItem {
|
||||
style: BorderStyle::Thin,
|
||||
color: Some("#FF5566".to_string()),
|
||||
};
|
||||
let expected_border = Border {
|
||||
diagonal_up: false,
|
||||
diagonal_down: false,
|
||||
left: None,
|
||||
right: Some(border_item.clone()),
|
||||
top: None,
|
||||
bottom: None,
|
||||
diagonal: None,
|
||||
};
|
||||
assert_eq!(style.border, expected_border);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1034,7 +1018,10 @@ fn border_top() {
|
||||
style: BorderStyle::Thin,
|
||||
color: Some("#F2F2F2".to_string()),
|
||||
};
|
||||
assert_eq!(model._get_cell_actual_border("C4").top, Some(border_item));
|
||||
assert_eq!(
|
||||
model._get_cell_actual_border("C4").bottom,
|
||||
Some(border_item)
|
||||
);
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{UserModel, expressions::types::Area};
|
||||
use crate::{expressions::types::Area, UserModel};
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
|
||||
@@ -1,504 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW};
|
||||
use crate::expressions::types::Area;
|
||||
|
||||
#[test]
|
||||
fn column_width() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(!style.font.i);
|
||||
assert!(!style.font.b);
|
||||
assert!(!style.font.u);
|
||||
assert!(!style.font.strike);
|
||||
assert_eq!(style.font.color, Some("#000000".to_owned()));
|
||||
|
||||
// Set the whole column style and check it works
|
||||
model.update_range_style(&range, "font.b", "true").unwrap();
|
||||
let style = model.get_cell_style(0, 109, 7).unwrap();
|
||||
assert!(style.font.b);
|
||||
|
||||
// undo and check it works
|
||||
model.undo().unwrap();
|
||||
let style = model.get_cell_style(0, 109, 7).unwrap();
|
||||
assert!(!style.font.b);
|
||||
|
||||
// redo and check it works
|
||||
model.redo().unwrap();
|
||||
let style = model.get_cell_style(0, 109, 7).unwrap();
|
||||
assert!(style.font.b);
|
||||
|
||||
// change the column width and check it does not affect the style
|
||||
model
|
||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
let style = model.get_cell_style(0, 109, 7).unwrap();
|
||||
assert!(style.font.b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_style() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let cell_g123 = Area {
|
||||
sheet: 0,
|
||||
row: 123,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
// Set G123 background to red
|
||||
model
|
||||
.update_range_style(&cell_g123, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// Now set the style of the whole column
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
// Get the style of G123
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_owned()));
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
// Check the style of G123 is now what it was before
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
|
||||
model.redo().unwrap();
|
||||
|
||||
// Check G123 has the column style now
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn row_column() {
|
||||
// We set the row style, then a column style
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_3_range = Area {
|
||||
sheet: 0,
|
||||
row: 3,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// update the row style
|
||||
model
|
||||
.update_range_style(&row_3_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// update the column style
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
// Check G3 has the column style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_owned()));
|
||||
|
||||
// undo twice. Color must be default
|
||||
model.undo().unwrap();
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
model.undo().unwrap();
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_row() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let default_style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_3_range = Area {
|
||||
sheet: 0,
|
||||
row: 3,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// update the column style
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
// update the row style
|
||||
model
|
||||
.update_range_style(&row_3_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// Check G3 has the row style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
// Check G3 has the column style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_owned()));
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
// Check G3 has the default_style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, default_style.fill.bg_color);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn row_column_column() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let column_c_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 3,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let column_e_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 5,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_5_range = Area {
|
||||
sheet: 0,
|
||||
row: 5,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// update the row style
|
||||
model
|
||||
.update_range_style(&row_5_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// update the column style
|
||||
model
|
||||
.update_range_style(&column_c_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&column_e_range, "fill.bg_color", "#CCC111")
|
||||
.unwrap();
|
||||
|
||||
model.undo().unwrap();
|
||||
model.undo().unwrap();
|
||||
model.undo().unwrap();
|
||||
|
||||
// Test E5 has the default style
|
||||
let style = model.get_cell_style(0, 5, 5).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn width_column_undo() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
model
|
||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#CCC111")
|
||||
.unwrap();
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
assert_eq!(
|
||||
model.get_column_width(0, 7).unwrap(),
|
||||
DEFAULT_COLUMN_WIDTH * 2.0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn height_row_undo() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
model
|
||||
.set_rows_height(0, 10, 10, DEFAULT_ROW_HEIGHT * 2.0)
|
||||
.unwrap();
|
||||
|
||||
let row_10_range = Area {
|
||||
sheet: 0,
|
||||
row: 10,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
model
|
||||
.update_range_style(&row_10_range, "fill.bg_color", "#CCC111")
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
model.get_row_height(0, 10).unwrap(),
|
||||
2.0 * DEFAULT_ROW_HEIGHT
|
||||
);
|
||||
model.undo().unwrap();
|
||||
assert_eq!(
|
||||
model.get_row_height(0, 10).unwrap(),
|
||||
2.0 * DEFAULT_ROW_HEIGHT
|
||||
);
|
||||
model.undo().unwrap();
|
||||
assert_eq!(model.get_row_height(0, 10).unwrap(), DEFAULT_ROW_HEIGHT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cell_row_undo() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let cell_g12 = Area {
|
||||
sheet: 0,
|
||||
row: 12,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let row_12_range = Area {
|
||||
sheet: 0,
|
||||
row: 12,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// Set G12 background to red
|
||||
model
|
||||
.update_range_style(&cell_g12, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&row_12_range, "fill.bg_color", "#CCC111")
|
||||
.unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 12, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#CCC111".to_string()));
|
||||
model.undo().unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 12, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_column_style_then_cell() {
|
||||
// We check that if we set a cell style in a column that already has a style
|
||||
// the styles compound
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let cell_g12 = Area {
|
||||
sheet: 0,
|
||||
row: 12,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
// Set G12 background to red
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&cell_g12, "alignment.horizontal", "center")
|
||||
.unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 12, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_string()));
|
||||
|
||||
model.undo().unwrap();
|
||||
model.undo().unwrap();
|
||||
let style = model.get_cell_style(0, 12, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_row_style_then_cell() {
|
||||
// We check that if we set a cell style in a column that already has a style
|
||||
// the styles compound
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let cell_g12 = Area {
|
||||
sheet: 0,
|
||||
row: 12,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let row_12_range = Area {
|
||||
sheet: 0,
|
||||
row: 12,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// Set G12 background to red
|
||||
model
|
||||
.update_range_style(&row_12_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&cell_g12, "alignment.horizontal", "center")
|
||||
.unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 12, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_style_then_row_alignment() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
let row_3_range = Area {
|
||||
sheet: 0,
|
||||
row: 3,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
model
|
||||
.update_range_style(&row_3_range, "alignment.horizontal", "center")
|
||||
.unwrap();
|
||||
// check the row alignment does not affect the column style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_style_then_width() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
model
|
||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
|
||||
// Check column width worked:
|
||||
assert_eq!(
|
||||
model.get_column_width(0, 7).unwrap(),
|
||||
DEFAULT_COLUMN_WIDTH * 2.0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_row_column_column() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let column_c_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 3,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let column_e_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 5,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_5_range = Area {
|
||||
sheet: 0,
|
||||
row: 5,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// update the row style
|
||||
model
|
||||
.update_range_style(&row_5_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// update the column style
|
||||
model
|
||||
.update_range_style(&column_c_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&column_e_range, "fill.bg_color", "#CCC111")
|
||||
.unwrap();
|
||||
|
||||
// test E5 has the column style
|
||||
let style = model.get_cell_style(0, 5, 5).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#CCC111".to_string()));
|
||||
}
|
||||
@@ -396,30 +396,3 @@ fn undo_redo() {
|
||||
Ok("Hola!".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_scope_to_first_sheet() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
model.new_sheet().unwrap();
|
||||
model.set_user_input(0, 1, 1, "Hello").unwrap();
|
||||
model
|
||||
.set_user_input(1, 2, 1, r#"=CONCATENATE(MyName, " world!")"#)
|
||||
.unwrap();
|
||||
model
|
||||
.new_defined_name("myName", None, "Sheet1!$A$1")
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
model.get_formatted_cell_value(1, 2, 1),
|
||||
Ok("Hello world!".to_string())
|
||||
);
|
||||
|
||||
model
|
||||
.update_defined_name("myName", None, "myName", Some(0), "Sheet1!$A$1")
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
model.get_formatted_cell_value(1, 2, 1),
|
||||
Ok("#NAME?".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN, LAST_ROW},
|
||||
expressions::types::Area,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn delete_column_formatting() {
|
||||
// We are going to delete formatting in column G (7)
|
||||
// There are cells with their own styles
|
||||
// There are rows with their own styles
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let cell_g123 = Area {
|
||||
sheet: 0,
|
||||
row: 123,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_3_range = Area {
|
||||
sheet: 0,
|
||||
row: 3,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// Set the style of the whole column
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
// Set G123 background to red
|
||||
model
|
||||
.update_range_style(&cell_g123, "fill.bg_color", "#FF5533")
|
||||
.unwrap();
|
||||
|
||||
// Set the style of the whole row
|
||||
model
|
||||
.update_range_style(&row_3_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
|
||||
// Delete the column formatting
|
||||
model.range_clear_formatting(&column_g_range).unwrap();
|
||||
|
||||
// Check the style of G123 is now what it was before
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
// Check the style of the whole row is still there
|
||||
let style = model.get_cell_style(0, 3, 1).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
|
||||
// Check the style of the whole column is now gone
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
let style = model.get_cell_style(0, 40, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
// Check the style of G123 is now what it was before
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#FF5533".to_owned()));
|
||||
|
||||
// Check G3 is the row style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
|
||||
// Check G40 is the column style
|
||||
let style = model.get_cell_style(0, 40, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_owned()));
|
||||
|
||||
model.redo().unwrap();
|
||||
|
||||
// Check the style of G123 is now what it was before
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
// Check the style of the whole row is still there
|
||||
let style = model.get_cell_style(0, 3, 1).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#333444".to_owned()));
|
||||
|
||||
// Check the style of the whole column is now gone
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
let style = model.get_cell_style(0, 40, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_width() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
model
|
||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
// Set the style of the whole column
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
// Delete the column formatting
|
||||
model.range_clear_formatting(&column_g_range).unwrap();
|
||||
// This does not change the column width
|
||||
assert_eq!(
|
||||
model.get_column_width(0, 7).unwrap(),
|
||||
2.0 * DEFAULT_COLUMN_WIDTH
|
||||
);
|
||||
|
||||
model.undo().unwrap();
|
||||
assert_eq!(
|
||||
model.get_column_width(0, 7).unwrap(),
|
||||
2.0 * DEFAULT_COLUMN_WIDTH
|
||||
);
|
||||
model.redo().unwrap();
|
||||
assert_eq!(
|
||||
model.get_column_width(0, 7).unwrap(),
|
||||
2.0 * DEFAULT_COLUMN_WIDTH
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_row_style_undo() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
model
|
||||
.set_columns_width(0, 7, 7, DEFAULT_COLUMN_WIDTH * 2.0)
|
||||
.unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_123_range = Area {
|
||||
sheet: 0,
|
||||
row: 123,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
let delete_range = Area {
|
||||
sheet: 0,
|
||||
row: 120,
|
||||
column: 5,
|
||||
width: 20,
|
||||
height: 20,
|
||||
};
|
||||
|
||||
// Set the style of the whole column
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&row_123_range, "fill.bg_color", "#111222")
|
||||
.unwrap();
|
||||
|
||||
model.range_clear_formatting(&delete_range).unwrap();
|
||||
|
||||
// check G123 is empty
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
|
||||
// uno clear formatting
|
||||
model.undo().unwrap();
|
||||
|
||||
// G123 has the row style
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#111222".to_owned()));
|
||||
|
||||
// undo twice
|
||||
model.undo().unwrap();
|
||||
model.undo().unwrap();
|
||||
|
||||
// check G123 is empty
|
||||
let style = model.get_cell_style(0, 123, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn column_row_row_height_undo() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
let row_3_range = Area {
|
||||
sheet: 0,
|
||||
row: 3,
|
||||
column: 1,
|
||||
width: LAST_COLUMN,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#555666")
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.set_rows_height(0, 3, 3, DEFAULT_ROW_HEIGHT * 2.0)
|
||||
.unwrap();
|
||||
|
||||
model
|
||||
.update_range_style(&row_3_range, "fill.bg_color", "#111222")
|
||||
.unwrap();
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
// check G3 has the column style
|
||||
let style = model.get_cell_style(0, 3, 7).unwrap();
|
||||
assert_eq!(style.fill.bg_color, Some("#555666".to_string()));
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn send_queue() {
|
||||
let mut model1 = UserModel::from_model(new_empty_model());
|
||||
let width = model1.get_column_width(0, 3).unwrap() * 3.0;
|
||||
model1.set_columns_width(0, 3, 3, width).unwrap();
|
||||
model1.set_column_width(0, 3, width).unwrap();
|
||||
model1.set_user_input(0, 1, 2, "Hello IronCalc!").unwrap();
|
||||
let send_queue = model1.flush_send_queue();
|
||||
|
||||
@@ -34,7 +34,7 @@ fn apply_external_diffs_wrong_str() {
|
||||
fn queue_undo_redo() {
|
||||
let mut model1 = UserModel::from_model(new_empty_model());
|
||||
let width = model1.get_column_width(0, 3).unwrap() * 3.0;
|
||||
model1.set_columns_width(0, 3, 3, width).unwrap();
|
||||
model1.set_column_width(0, 3, width).unwrap();
|
||||
model1.set_user_input(0, 1, 2, "Hello IronCalc!").unwrap();
|
||||
assert!(model1.undo().is_ok());
|
||||
assert!(model1.redo().is_ok());
|
||||
@@ -57,8 +57,8 @@ fn queue_undo_redo_multiple() {
|
||||
// do a bunch of things
|
||||
model1.set_frozen_columns_count(0, 5).unwrap();
|
||||
model1.set_frozen_rows_count(0, 6).unwrap();
|
||||
model1.set_columns_width(0, 7, 7, 300.0).unwrap();
|
||||
model1.set_rows_height(0, 23, 23, 123.0).unwrap();
|
||||
model1.set_column_width(0, 7, 300.0).unwrap();
|
||||
model1.set_row_height(0, 23, 123.0).unwrap();
|
||||
model1.set_user_input(0, 55, 55, "=42+8").unwrap();
|
||||
|
||||
for row in 1..5 {
|
||||
@@ -157,9 +157,7 @@ fn new_sheet() {
|
||||
#[test]
|
||||
fn wrong_diffs_handled() {
|
||||
let mut model = UserModel::from_model(new_empty_model());
|
||||
assert!(
|
||||
model
|
||||
.apply_external_diffs("Hello world".as_bytes())
|
||||
.is_err()
|
||||
);
|
||||
assert!(model
|
||||
.apply_external_diffs("Hello world".as_bytes())
|
||||
.is_err());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::constants::{LAST_COLUMN, LAST_ROW};
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::types::CellType;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn set_user_input_errors() {
|
||||
@@ -59,7 +59,7 @@ fn insert_remove_rows() {
|
||||
// Insert some data in row 5 (and change the style)
|
||||
assert!(model.set_user_input(0, 5, 1, "100$").is_ok());
|
||||
// Change the height of the column
|
||||
assert!(model.set_rows_height(0, 5, 5, 3.0 * height).is_ok());
|
||||
assert!(model.set_row_height(0, 5, 3.0 * height).is_ok());
|
||||
|
||||
// remove the row
|
||||
assert!(model.delete_row(0, 5).is_ok());
|
||||
@@ -95,7 +95,7 @@ fn insert_remove_columns() {
|
||||
// Insert some data in row 5 (and change the style) in E1
|
||||
assert!(model.set_user_input(0, 1, 5, "100$").is_ok());
|
||||
// Change the width of the column
|
||||
assert!(model.set_columns_width(0, 5, 5, 3.0 * column_width).is_ok());
|
||||
assert!(model.set_column_width(0, 5, 3.0 * column_width).is_ok());
|
||||
assert_eq!(model.get_column_width(0, 5).unwrap(), 3.0 * column_width);
|
||||
|
||||
// remove the column
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{
|
||||
DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH,
|
||||
LAST_COLUMN,
|
||||
},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_WINDOW_WIDTH},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_WINDOW_WIDTH, LAST_COLUMN},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::types::Fill;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn simple_pasting() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{UserModel, expressions::types::Area};
|
||||
use crate::{expressions::types::Area, UserModel};
|
||||
|
||||
#[test]
|
||||
fn csv_paste() {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel, constants::LAST_ROW, expressions::types::Area, test::util::new_empty_model,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn two_columns() {
|
||||
let model = new_empty_model();
|
||||
let mut model = UserModel::from_model(model);
|
||||
|
||||
// Set style in column C (column 3)
|
||||
let column_c_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 3,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
model
|
||||
.update_range_style(&column_c_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
model.set_user_input(0, 5, 3, "2").unwrap();
|
||||
|
||||
// Set Style in column G (column 7)
|
||||
let column_g_range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 7,
|
||||
width: 1,
|
||||
height: LAST_ROW,
|
||||
};
|
||||
|
||||
model
|
||||
.update_range_style(&column_g_range, "fill.bg_color", "#333444")
|
||||
.unwrap();
|
||||
model.set_user_input(0, 5, 6, "42").unwrap();
|
||||
// Set formula in G5: =F5*C5
|
||||
model.set_user_input(0, 5, 7, "=F5*C5").unwrap();
|
||||
|
||||
assert_eq!(model.get_formatted_cell_value(0, 5, 7).unwrap(), "84");
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, LAST_COLUMN},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -59,7 +59,7 @@ fn simple_delete_column() {
|
||||
model.set_user_input(0, 1, 5, "3").unwrap();
|
||||
model.set_user_input(0, 2, 5, "=E1*2").unwrap();
|
||||
model
|
||||
.set_columns_width(0, 5, 5, DEFAULT_COLUMN_WIDTH * 3.0)
|
||||
.set_column_width(0, 5, DEFAULT_COLUMN_WIDTH * 3.0)
|
||||
.unwrap();
|
||||
|
||||
model.delete_column(0, 5).unwrap();
|
||||
@@ -116,7 +116,7 @@ fn simple_delete_row() {
|
||||
model.set_user_input(0, 15, 6, "=D15*2").unwrap();
|
||||
|
||||
model
|
||||
.set_rows_height(0, 15, 15, DEFAULT_ROW_HEIGHT * 3.0)
|
||||
.set_row_height(0, 15, DEFAULT_ROW_HEIGHT * 3.0)
|
||||
.unwrap();
|
||||
|
||||
model.delete_row(0, 15).unwrap();
|
||||
@@ -172,42 +172,3 @@ fn row_heigh_increases_automatically() {
|
||||
.unwrap();
|
||||
assert_eq!(model.get_row_height(0, 1), Ok(2.0 * DEFAULT_ROW_HEIGHT));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_row_evaluates() {
|
||||
let model = new_empty_model();
|
||||
let mut model = UserModel::from_model(model);
|
||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||
model.set_user_input(0, 1, 2, "=A1*2").unwrap();
|
||||
|
||||
assert!(model.insert_row(0, 1).is_ok());
|
||||
assert_eq!(model.get_formatted_cell_value(0, 2, 2).unwrap(), "84");
|
||||
model.undo().unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 1, 2).unwrap(), "84");
|
||||
model.redo().unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 2, 2).unwrap(), "84");
|
||||
|
||||
model.delete_row(0, 1).unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 1, 2).unwrap(), "84");
|
||||
assert_eq!(model.get_cell_content(0, 1, 2).unwrap(), "=A1*2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_column_evaluates() {
|
||||
let model = new_empty_model();
|
||||
let mut model = UserModel::from_model(model);
|
||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
||||
model.set_user_input(0, 10, 1, "=A1*2").unwrap();
|
||||
|
||||
assert!(model.insert_column(0, 1).is_ok());
|
||||
assert_eq!(model.get_formatted_cell_value(0, 10, 2).unwrap(), "84");
|
||||
|
||||
model.undo().unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 10, 1).unwrap(), "84");
|
||||
model.redo().unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 10, 2).unwrap(), "84");
|
||||
|
||||
model.delete_column(0, 1).unwrap();
|
||||
assert_eq!(model.get_formatted_cell_value(0, 10, 1).unwrap(), "84");
|
||||
assert_eq!(model.get_cell_content(0, 10, 1).unwrap(), "=A1*2");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
use crate::UserModel;
|
||||
|
||||
#[test]
|
||||
fn basic_tests() {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::UserModel;
|
||||
use crate::test::util::new_empty_model;
|
||||
|
||||
#[test]
|
||||
fn basic_undo_redo() {
|
||||
let model = new_empty_model();
|
||||
let mut model = UserModel::from_model(model);
|
||||
assert_eq!(model.get_selected_sheet(), 0);
|
||||
|
||||
model.new_sheet().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 1);
|
||||
model.undo().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 0);
|
||||
{
|
||||
let props = model.get_worksheets_properties();
|
||||
assert_eq!(props.len(), 1);
|
||||
let view = model.get_selected_view();
|
||||
assert_eq!(view.sheet, 0);
|
||||
}
|
||||
|
||||
model.redo().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 1);
|
||||
{
|
||||
let props = model.get_worksheets_properties();
|
||||
assert_eq!(props.len(), 2);
|
||||
let view = model.get_selected_view();
|
||||
|
||||
assert_eq!(view.sheet, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_undo() {
|
||||
let model = new_empty_model();
|
||||
let mut model = UserModel::from_model(model);
|
||||
assert_eq!(model.get_selected_sheet(), 0);
|
||||
|
||||
model.new_sheet().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 1);
|
||||
model.set_user_input(1, 1, 1, "42").unwrap();
|
||||
model.set_user_input(1, 1, 2, "=A1*2").unwrap();
|
||||
model.delete_sheet(1).unwrap();
|
||||
|
||||
assert_eq!(model.get_selected_sheet(), 0);
|
||||
|
||||
model.undo().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 1);
|
||||
model.redo().unwrap();
|
||||
assert_eq!(model.get_selected_sheet(), 0);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
expressions::types::Area,
|
||||
types::{Alignment, HorizontalAlignment, VerticalAlignment},
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -436,47 +436,3 @@ fn false_removes_value() {
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(!style.font.b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cell_clear_formatting() {
|
||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||
let range = Area {
|
||||
sheet: 0,
|
||||
row: 1,
|
||||
column: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
};
|
||||
|
||||
// bold
|
||||
model.update_range_style(&range, "font.b", "true").unwrap();
|
||||
model
|
||||
.update_range_style(&range, "alignment.horizontal", "centerContinuous")
|
||||
.unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(style.font.b);
|
||||
assert_eq!(
|
||||
style.alignment.unwrap().horizontal,
|
||||
HorizontalAlignment::CenterContinuous
|
||||
);
|
||||
|
||||
model.range_clear_all(&range).unwrap();
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(!style.font.b);
|
||||
assert_eq!(style.alignment, None);
|
||||
|
||||
model.undo().unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(style.font.b);
|
||||
assert_eq!(
|
||||
style.alignment.unwrap().horizontal,
|
||||
HorizontalAlignment::CenterContinuous
|
||||
);
|
||||
model.redo().unwrap();
|
||||
|
||||
let style = model.get_cell_style(0, 1, 1).unwrap();
|
||||
assert!(!style.font.b);
|
||||
assert_eq!(style.alignment, None);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{UserModel, test::util::new_empty_model};
|
||||
use crate::{test::util::new_empty_model, UserModel};
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
let mut model1 = UserModel::from_model(new_empty_model());
|
||||
let width = model1.get_column_width(0, 3).unwrap() * 3.0;
|
||||
model1.set_columns_width(0, 3, 3, width).unwrap();
|
||||
model1.set_column_width(0, 3, width).unwrap();
|
||||
model1.set_user_input(0, 1, 2, "Hello IronCalc!").unwrap();
|
||||
|
||||
let model_bytes = model1.to_bytes();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{UserModel, test::util::new_empty_model};
|
||||
use crate::{test::util::new_empty_model, UserModel};
|
||||
|
||||
#[test]
|
||||
fn simple_undo_redo() {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
test::util::new_empty_model,
|
||||
user_model::SelectedView,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{
|
||||
UserModel,
|
||||
constants::{DEFAULT_ROW_HEIGHT, DEFAULT_WINDOW_HEIGHT, DEFAULT_WINDOW_WIDTH},
|
||||
test::util::new_empty_model,
|
||||
UserModel,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{BorderArea, UserModel, expressions::types::Area, types::Border};
|
||||
use crate::{expressions::types::Area, types::Border, BorderArea, UserModel};
|
||||
|
||||
impl UserModel {
|
||||
pub fn _set_cell_border(&mut self, cell: &str, color: &str) {
|
||||
|
||||
@@ -323,19 +323,6 @@ pub struct Style {
|
||||
pub quote_prefix: bool,
|
||||
}
|
||||
|
||||
impl Default for Style {
|
||||
fn default() -> Self {
|
||||
Style {
|
||||
alignment: None,
|
||||
num_fmt: "general".to_string(),
|
||||
fill: Fill::default(),
|
||||
font: Font::default(),
|
||||
border: Border::default(),
|
||||
quote_prefix: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct NumFmt {
|
||||
pub num_fmt_id: i32,
|
||||
|
||||
@@ -50,9 +50,8 @@ impl Units {
|
||||
fn get_units_from_format_string(num_fmt: &str) -> Option<Units> {
|
||||
let mut parser = Parser::new(num_fmt);
|
||||
parser.parse();
|
||||
let parts = parser.parts.first()?;
|
||||
// We only care about the first part (positive number)
|
||||
match parts {
|
||||
match &parser.parts[0] {
|
||||
ParsePart::Number(part) => {
|
||||
if part.percent > 0 {
|
||||
Some(Units::Percentage {
|
||||
|
||||
@@ -1,507 +0,0 @@
|
||||
use crate::{
|
||||
constants::{LAST_COLUMN, LAST_ROW},
|
||||
expressions::types::Area,
|
||||
};
|
||||
|
||||
use super::{
|
||||
BorderArea, UserModel, border_utils::is_max_border, common::BorderType, history::Diff,
|
||||
};
|
||||
|
||||
impl UserModel {
|
||||
fn update_single_cell_border(
|
||||
&mut self,
|
||||
border_area: &BorderArea,
|
||||
cell: (u32, i32, i32),
|
||||
range: (i32, i32, i32, i32),
|
||||
diff_list: &mut Vec<Diff>,
|
||||
) -> Result<(), String> {
|
||||
let (sheet, row, column) = cell;
|
||||
let (first_row, first_column, last_row, last_column) = range;
|
||||
|
||||
let old_value = self.model.get_cell_style_or_none(sheet, row, column)?;
|
||||
let mut new_value = match &old_value {
|
||||
Some(value) => value.clone(),
|
||||
None => Default::default(),
|
||||
};
|
||||
match border_area.r#type {
|
||||
BorderType::All => {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
BorderType::Inner => {
|
||||
if row != first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row != last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
if column != first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column != last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Outer => {
|
||||
if row == first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row == last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
if column == first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column == last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Top => {
|
||||
if row == first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Right => {
|
||||
if column == last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Bottom => {
|
||||
if row == last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Left => {
|
||||
if column == first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::CenterH => {
|
||||
if row != first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row != last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::CenterV => {
|
||||
if column != first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column != last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::None => {
|
||||
new_value.border.top = None;
|
||||
new_value.border.right = None;
|
||||
new_value.border.bottom = None;
|
||||
new_value.border.left = None;
|
||||
}
|
||||
}
|
||||
self.model.set_cell_style(sheet, row, column, &new_value)?;
|
||||
diff_list.push(Diff::SetCellStyle {
|
||||
sheet,
|
||||
row,
|
||||
column,
|
||||
old_value: Box::new(old_value),
|
||||
new_value: Box::new(new_value),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_rows_with_border(
|
||||
&mut self,
|
||||
sheet: u32,
|
||||
first_row: i32,
|
||||
last_row: i32,
|
||||
border_area: &BorderArea,
|
||||
) -> Result<(), String> {
|
||||
let mut diff_list = Vec::new();
|
||||
for row in first_row..=last_row {
|
||||
let old_value = self.model.get_row_style(sheet, row)?;
|
||||
let mut new_value = match &old_value {
|
||||
Some(value) => value.clone(),
|
||||
None => Default::default(),
|
||||
};
|
||||
|
||||
match border_area.r#type {
|
||||
BorderType::All => {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
BorderType::Inner => {
|
||||
if row != first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row != last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Outer => {
|
||||
if row == first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row == last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Top => {
|
||||
if row == first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Right => {
|
||||
// noop
|
||||
}
|
||||
BorderType::Bottom => {
|
||||
if row == last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Left => {
|
||||
// noop
|
||||
}
|
||||
BorderType::CenterH => {
|
||||
if row != first_row {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
if row != last_row {
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::CenterV => {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
BorderType::None => {
|
||||
new_value.border.top = None;
|
||||
new_value.border.right = None;
|
||||
new_value.border.bottom = None;
|
||||
new_value.border.left = None;
|
||||
}
|
||||
}
|
||||
|
||||
// We need to go throw each non-empty cell in the row
|
||||
let columns: Vec<i32> = self
|
||||
.model
|
||||
.workbook
|
||||
.worksheet(sheet)?
|
||||
.sheet_data
|
||||
.get(&row)
|
||||
.map(|row_data| row_data.keys().copied().collect())
|
||||
.unwrap_or_default();
|
||||
for column in columns {
|
||||
self.update_single_cell_border(
|
||||
border_area,
|
||||
(sheet, row, column),
|
||||
(first_row, 1, last_row, LAST_COLUMN),
|
||||
&mut diff_list,
|
||||
)?;
|
||||
}
|
||||
|
||||
self.model.set_row_style(sheet, row, &new_value)?;
|
||||
diff_list.push(Diff::SetRowStyle {
|
||||
sheet,
|
||||
row,
|
||||
old_value: Box::new(old_value),
|
||||
new_value: Box::new(new_value),
|
||||
});
|
||||
}
|
||||
// TODO: We need to check the rows above and below. also any non empty cell in the rows above and below.
|
||||
self.push_diff_list(diff_list);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_columns_with_border(
|
||||
&mut self,
|
||||
sheet: u32,
|
||||
first_column: i32,
|
||||
last_column: i32,
|
||||
border_area: &BorderArea,
|
||||
) -> Result<(), String> {
|
||||
let mut diff_list = Vec::new();
|
||||
// We need all the rows in the column to update the style
|
||||
// NB: This is too much, this is all the rows that have values
|
||||
let data_rows: Vec<i32> = self
|
||||
.model
|
||||
.workbook
|
||||
.worksheet(sheet)?
|
||||
.sheet_data
|
||||
.keys()
|
||||
.copied()
|
||||
.collect();
|
||||
let styled_rows = &self.model.workbook.worksheet(sheet)?.rows.clone();
|
||||
for column in first_column..=last_column {
|
||||
let old_value = self.model.get_column_style(sheet, column)?;
|
||||
let mut new_value = match &old_value {
|
||||
Some(value) => value.clone(),
|
||||
None => Default::default(),
|
||||
};
|
||||
|
||||
match border_area.r#type {
|
||||
BorderType::All => {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
BorderType::Inner => {
|
||||
if column != first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column != last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Outer => {
|
||||
if column == first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column == last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Top => {
|
||||
// noop
|
||||
}
|
||||
BorderType::Right => {
|
||||
if column == last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::Bottom => {
|
||||
// noop
|
||||
}
|
||||
BorderType::Left => {
|
||||
if column == first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::CenterH => {
|
||||
new_value.border.top = Some(border_area.item.clone());
|
||||
new_value.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
BorderType::CenterV => {
|
||||
if column != first_column {
|
||||
new_value.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
if column != last_column {
|
||||
new_value.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
}
|
||||
BorderType::None => {
|
||||
new_value.border.top = None;
|
||||
new_value.border.right = None;
|
||||
new_value.border.bottom = None;
|
||||
new_value.border.left = None;
|
||||
}
|
||||
}
|
||||
// We need to go through each non empty cell in the column
|
||||
for &row in &data_rows {
|
||||
if let Some(data_row) = self.model.workbook.worksheet(sheet)?.sheet_data.get(&row) {
|
||||
if data_row.get(&column).is_some() {
|
||||
self.update_single_cell_border(
|
||||
border_area,
|
||||
(sheet, row, column),
|
||||
(1, first_column, LAST_ROW, last_column),
|
||||
&mut diff_list,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We also need to overwrite those that have a row style
|
||||
for row_s in styled_rows.iter() {
|
||||
let row = row_s.r;
|
||||
self.update_single_cell_border(
|
||||
border_area,
|
||||
(sheet, row, column),
|
||||
(1, first_column, LAST_ROW, last_column),
|
||||
&mut diff_list,
|
||||
)?;
|
||||
}
|
||||
|
||||
self.model.set_column_style(sheet, column, &new_value)?;
|
||||
diff_list.push(Diff::SetColumnStyle {
|
||||
sheet,
|
||||
column,
|
||||
old_value: Box::new(old_value),
|
||||
new_value: Box::new(new_value),
|
||||
});
|
||||
}
|
||||
// We need to check the borders of the column to the left and the column to the right
|
||||
// We also need to check every non-empty cell in the columns to the left and right
|
||||
self.push_diff_list(diff_list);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the border in an area of cells.
|
||||
/// When setting the border we need to check if the adjacent cells have a "heavier" border
|
||||
/// If that is the case we need to change it
|
||||
pub fn set_area_with_border(
|
||||
&mut self,
|
||||
range: &Area,
|
||||
border_area: &BorderArea,
|
||||
) -> Result<(), String> {
|
||||
let sheet = range.sheet;
|
||||
let first_row = range.row;
|
||||
let first_column = range.column;
|
||||
let last_row = first_row + range.height - 1;
|
||||
let last_column = first_column + range.width - 1;
|
||||
if first_row == 1 && last_row == LAST_ROW {
|
||||
// full columns
|
||||
self.set_columns_with_border(sheet, first_column, last_column, border_area)?;
|
||||
return Ok(());
|
||||
}
|
||||
if first_column == 1 && last_column == LAST_COLUMN {
|
||||
// full rows
|
||||
self.set_rows_with_border(sheet, first_row, last_row, border_area)?;
|
||||
return Ok(());
|
||||
}
|
||||
let mut diff_list = Vec::new();
|
||||
for row in first_row..=last_row {
|
||||
for column in first_column..=last_column {
|
||||
self.update_single_cell_border(
|
||||
border_area,
|
||||
(sheet, row, column),
|
||||
(first_row, first_column, last_row, last_column),
|
||||
&mut diff_list,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
// bottom of the cells above the first
|
||||
if first_row > 1
|
||||
&& [
|
||||
BorderType::All,
|
||||
BorderType::None,
|
||||
BorderType::Outer,
|
||||
BorderType::Top,
|
||||
]
|
||||
.contains(&border_area.r#type)
|
||||
{
|
||||
let row = first_row - 1;
|
||||
for column in first_column..=last_column {
|
||||
let old_value = self.model.get_style_for_cell(sheet, row, column)?;
|
||||
if is_max_border(Some(&border_area.item), old_value.border.bottom.as_ref()) {
|
||||
let mut style = old_value.clone();
|
||||
if border_area.r#type == BorderType::None {
|
||||
style.border.bottom = None;
|
||||
} else {
|
||||
style.border.bottom = Some(border_area.item.clone());
|
||||
}
|
||||
self.model.set_cell_style(sheet, row, column, &style)?;
|
||||
diff_list.push(Diff::SetCellStyle {
|
||||
sheet,
|
||||
row,
|
||||
column,
|
||||
old_value: Box::new(Some(old_value)),
|
||||
new_value: Box::new(style),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cells to the right
|
||||
if last_column < LAST_COLUMN
|
||||
&& [
|
||||
BorderType::All,
|
||||
BorderType::None,
|
||||
BorderType::Outer,
|
||||
BorderType::Right,
|
||||
]
|
||||
.contains(&border_area.r#type)
|
||||
{
|
||||
let column = last_column + 1;
|
||||
for row in first_row..=last_row {
|
||||
let old_value = self.model.get_style_for_cell(sheet, row, column)?;
|
||||
// If the border in the adjacent cell is "heavier" we change it
|
||||
if is_max_border(Some(&border_area.item), old_value.border.left.as_ref()) {
|
||||
let mut style = old_value.clone();
|
||||
if border_area.r#type == BorderType::None {
|
||||
style.border.left = None;
|
||||
} else {
|
||||
style.border.left = Some(border_area.item.clone());
|
||||
}
|
||||
self.model.set_cell_style(sheet, row, column, &style)?;
|
||||
diff_list.push(Diff::SetCellStyle {
|
||||
sheet,
|
||||
row,
|
||||
column,
|
||||
old_value: Box::new(Some(old_value)),
|
||||
new_value: Box::new(style),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cells bellow
|
||||
if last_row < LAST_ROW
|
||||
&& [
|
||||
BorderType::All,
|
||||
BorderType::None,
|
||||
BorderType::Outer,
|
||||
BorderType::Bottom,
|
||||
]
|
||||
.contains(&border_area.r#type)
|
||||
{
|
||||
let row = last_row + 1;
|
||||
for column in first_column..=last_column {
|
||||
let old_value = self.model.get_style_for_cell(sheet, row, column)?;
|
||||
if is_max_border(Some(&border_area.item), old_value.border.top.as_ref()) {
|
||||
let mut style = old_value.clone();
|
||||
if border_area.r#type == BorderType::None {
|
||||
style.border.top = None;
|
||||
} else {
|
||||
style.border.top = Some(border_area.item.clone());
|
||||
}
|
||||
self.model.set_cell_style(sheet, row, column, &style)?;
|
||||
diff_list.push(Diff::SetCellStyle {
|
||||
sheet,
|
||||
row,
|
||||
column,
|
||||
old_value: Box::new(Some(old_value)),
|
||||
new_value: Box::new(style),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cells to the left
|
||||
if first_column > 1
|
||||
&& [
|
||||
BorderType::All,
|
||||
BorderType::None,
|
||||
BorderType::Outer,
|
||||
BorderType::Left,
|
||||
]
|
||||
.contains(&border_area.r#type)
|
||||
{
|
||||
let column = first_column - 1;
|
||||
for row in first_row..=last_row {
|
||||
let old_value = self.model.get_style_for_cell(sheet, row, column)?;
|
||||
if is_max_border(Some(&border_area.item), old_value.border.right.as_ref()) {
|
||||
let mut style = old_value.clone();
|
||||
if border_area.r#type == BorderType::None {
|
||||
style.border.right = None;
|
||||
} else {
|
||||
style.border.right = Some(border_area.item.clone());
|
||||
}
|
||||
self.model.set_cell_style(sheet, row, column, &style)?;
|
||||
diff_list.push(Diff::SetCellStyle {
|
||||
sheet,
|
||||
row,
|
||||
column,
|
||||
old_value: Box::new(Some(old_value)),
|
||||
new_value: Box::new(style),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.push_diff_list(diff_list);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use bitcode::{Decode, Encode};
|
||||
|
||||
use crate::types::{Cell, Col, Row, SheetState, Style, Worksheet};
|
||||
use crate::types::{Cell, Col, Row, SheetState, Style};
|
||||
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
pub(crate) struct RowData {
|
||||
@@ -39,17 +39,11 @@ pub(crate) enum Diff {
|
||||
old_value: Box<Option<Cell>>,
|
||||
old_style: Box<Style>,
|
||||
},
|
||||
CellClearFormatting {
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
column: i32,
|
||||
old_style: Box<Option<Style>>,
|
||||
},
|
||||
SetCellStyle {
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
column: i32,
|
||||
old_value: Box<Option<Style>>,
|
||||
old_value: Box<Style>,
|
||||
new_value: Box<Style>,
|
||||
},
|
||||
// Column and Row diffs
|
||||
@@ -65,28 +59,6 @@ pub(crate) enum Diff {
|
||||
new_value: f64,
|
||||
old_value: f64,
|
||||
},
|
||||
SetColumnStyle {
|
||||
sheet: u32,
|
||||
column: i32,
|
||||
old_value: Box<Option<Style>>,
|
||||
new_value: Box<Style>,
|
||||
},
|
||||
SetRowStyle {
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
old_value: Box<Option<Style>>,
|
||||
new_value: Box<Style>,
|
||||
},
|
||||
DeleteColumnStyle {
|
||||
sheet: u32,
|
||||
column: i32,
|
||||
old_value: Box<Option<Style>>,
|
||||
},
|
||||
DeleteRowStyle {
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
old_value: Box<Option<Style>>,
|
||||
},
|
||||
InsertRow {
|
||||
sheet: u32,
|
||||
row: i32,
|
||||
@@ -105,10 +77,6 @@ pub(crate) enum Diff {
|
||||
column: i32,
|
||||
old_data: Box<ColumnData>,
|
||||
},
|
||||
DeleteSheet {
|
||||
sheet: u32,
|
||||
old_data: Box<Worksheet>,
|
||||
},
|
||||
SetFrozenRowsCount {
|
||||
sheet: u32,
|
||||
new_value: i32,
|
||||
@@ -119,6 +87,9 @@ pub(crate) enum Diff {
|
||||
new_value: i32,
|
||||
old_value: i32,
|
||||
},
|
||||
DeleteSheet {
|
||||
sheet: u32,
|
||||
},
|
||||
NewSheet {
|
||||
index: u32,
|
||||
name: String,
|
||||
@@ -197,6 +168,11 @@ impl History {
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.redo_stack = vec![];
|
||||
self.undo_stack = vec![];
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![deny(missing_docs)]
|
||||
|
||||
mod border;
|
||||
mod border_utils;
|
||||
mod common;
|
||||
mod history;
|
||||
|
||||
@@ -156,7 +156,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::language::get_language;
|
||||
use crate::locale::{Locale, get_locale};
|
||||
use crate::locale::{get_locale, Locale};
|
||||
|
||||
fn get_test_locale() -> &'static Locale {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
@@ -29,7 +29,7 @@ impl Workbook {
|
||||
}
|
||||
|
||||
/// Returns the a list of defined names in the workbook with their scope
|
||||
pub fn get_defined_names_with_scope(&self) -> Vec<(String, Option<u32>, String)> {
|
||||
pub(crate) fn get_defined_names_with_scope(&self) -> Vec<(String, Option<u32>, String)> {
|
||||
let sheet_id_index: Vec<u32> = self.worksheets.iter().map(|s| s.sheet_id).collect();
|
||||
|
||||
let defined_names = self
|
||||
|
||||
@@ -108,120 +108,37 @@ impl Worksheet {
|
||||
self.cols = vec![Col {
|
||||
min: 1,
|
||||
max: constants::LAST_COLUMN,
|
||||
width: constants::DEFAULT_COLUMN_WIDTH,
|
||||
custom_width: false,
|
||||
width: constants::DEFAULT_COLUMN_WIDTH / constants::COLUMN_WIDTH_FACTOR,
|
||||
custom_width: true,
|
||||
style: Some(style_index),
|
||||
}];
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_column_style(&mut self, column: i32, style_index: i32) -> Result<(), String> {
|
||||
let width = self
|
||||
.get_column_width(column)
|
||||
.unwrap_or(constants::DEFAULT_COLUMN_WIDTH);
|
||||
let width = constants::DEFAULT_COLUMN_WIDTH / constants::COLUMN_WIDTH_FACTOR;
|
||||
self.set_column_width_and_style(column, width, Some(style_index))
|
||||
}
|
||||
|
||||
pub fn set_row_style(&mut self, row: i32, style_index: i32) -> Result<(), String> {
|
||||
// FIXME: This is a HACK
|
||||
let custom_format = style_index != 0;
|
||||
for r in self.rows.iter_mut() {
|
||||
if r.r == row {
|
||||
r.s = style_index;
|
||||
r.custom_format = custom_format;
|
||||
r.custom_format = true;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
self.rows.push(Row {
|
||||
height: constants::DEFAULT_ROW_HEIGHT / constants::ROW_HEIGHT_FACTOR,
|
||||
r: row,
|
||||
custom_format,
|
||||
custom_height: false,
|
||||
custom_format: true,
|
||||
custom_height: true,
|
||||
s: style_index,
|
||||
hidden: false,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_row_style(&mut self, row: i32) -> Result<(), String> {
|
||||
let mut index = None;
|
||||
for (i, r) in self.rows.iter().enumerate() {
|
||||
if r.r == row {
|
||||
index = Some(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if let Some(i) = index {
|
||||
if let Some(r) = self.rows.get_mut(i) {
|
||||
r.s = 0;
|
||||
r.custom_format = false;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_column_style(&mut self, column: i32) -> Result<(), String> {
|
||||
if !is_valid_column_number(column) {
|
||||
return Err(format!("Column number '{column}' is not valid."));
|
||||
}
|
||||
let cols = &mut self.cols;
|
||||
|
||||
let mut index = 0;
|
||||
let mut split = false;
|
||||
for c in cols.iter_mut() {
|
||||
let min = c.min;
|
||||
let max = c.max;
|
||||
if min <= column && column <= max {
|
||||
//
|
||||
split = true;
|
||||
break;
|
||||
}
|
||||
if column < min {
|
||||
// We passed, there is nothing to delete
|
||||
break;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
if split {
|
||||
let min = cols[index].min;
|
||||
let max = cols[index].max;
|
||||
let custom_width = cols[index].custom_width;
|
||||
let width = cols[index].width;
|
||||
let pre = Col {
|
||||
min,
|
||||
max: column - 1,
|
||||
width,
|
||||
custom_width,
|
||||
style: cols[index].style,
|
||||
};
|
||||
let col = Col {
|
||||
min: column,
|
||||
max: column,
|
||||
width,
|
||||
custom_width,
|
||||
style: None,
|
||||
};
|
||||
let post = Col {
|
||||
min: column + 1,
|
||||
max,
|
||||
width,
|
||||
custom_width,
|
||||
style: cols[index].style,
|
||||
};
|
||||
cols.remove(index);
|
||||
if column != max {
|
||||
cols.insert(index, post);
|
||||
}
|
||||
if custom_width {
|
||||
cols.insert(index, col);
|
||||
}
|
||||
if column != min {
|
||||
cols.insert(index, pre);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_cell_style(
|
||||
&mut self,
|
||||
row: i32,
|
||||
@@ -368,12 +285,11 @@ impl Worksheet {
|
||||
|
||||
/// Changes the width of a column.
|
||||
/// * If the column does not a have a width we simply add it
|
||||
/// * If it has, it might be part of a range and we need to split the range.
|
||||
/// * If it has, it might be part of a range and we ned to split the range.
|
||||
///
|
||||
/// Fails if column index is outside allowed range or width is negative.
|
||||
pub fn set_column_width(&mut self, column: i32, width: f64) -> Result<(), String> {
|
||||
let style = self.get_column_style(column)?;
|
||||
self.set_column_width_and_style(column, width, style)
|
||||
self.set_column_width_and_style(column, width, None)
|
||||
}
|
||||
|
||||
pub(crate) fn set_column_width_and_style(
|
||||
@@ -393,7 +309,7 @@ impl Worksheet {
|
||||
min: column,
|
||||
max: column,
|
||||
width: width / constants::COLUMN_WIDTH_FACTOR,
|
||||
custom_width: width != constants::DEFAULT_COLUMN_WIDTH,
|
||||
custom_width: true,
|
||||
style,
|
||||
};
|
||||
let mut index = 0;
|
||||
@@ -403,9 +319,7 @@ impl Worksheet {
|
||||
let max = c.max;
|
||||
if min <= column && column <= max {
|
||||
if min == column && max == column {
|
||||
c.style = style;
|
||||
c.width = width / constants::COLUMN_WIDTH_FACTOR;
|
||||
c.custom_width = width != constants::DEFAULT_COLUMN_WIDTH;
|
||||
return Ok(());
|
||||
}
|
||||
split = true;
|
||||
@@ -469,23 +383,6 @@ impl Worksheet {
|
||||
Ok(constants::DEFAULT_COLUMN_WIDTH)
|
||||
}
|
||||
|
||||
/// Returns the column style index if present
|
||||
pub fn get_column_style(&self, column: i32) -> Result<Option<i32>, String> {
|
||||
if !is_valid_column_number(column) {
|
||||
return Err(format!("Column number '{column}' is not valid."));
|
||||
}
|
||||
|
||||
let cols = &self.cols;
|
||||
for col in cols {
|
||||
let min = col.min;
|
||||
let max = col.max;
|
||||
if column >= min && column <= max {
|
||||
return Ok(col.style);
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
// Returns non empty cells in a column
|
||||
pub fn column_cell_references(&self, column: i32) -> Result<Vec<CellReferenceIndex>, String> {
|
||||
let mut column_cell_references: Vec<CellReferenceIndex> = Vec::new();
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
linker = "aarch64-linux-musl-gcc"
|
||||
rustflags = ["-C", "target-feature=-crt-static"]
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
197
bindings/nodejs/.gitignore
vendored
197
bindings/nodejs/.gitignore
vendored
@@ -1,197 +0,0 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/node
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/macos
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/macos
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/windows
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=windows
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/windows
|
||||
|
||||
#Added by cargo
|
||||
|
||||
/target
|
||||
Cargo.lock
|
||||
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
*.node
|
||||
@@ -1,13 +0,0 @@
|
||||
target
|
||||
Cargo.lock
|
||||
.cargo
|
||||
.github
|
||||
npm
|
||||
.eslintrc
|
||||
.prettierignore
|
||||
rustfmt.toml
|
||||
yarn.lock
|
||||
*.node
|
||||
.yarn
|
||||
__test__
|
||||
renovate.json
|
||||
@@ -1 +0,0 @@
|
||||
nodeLinker: node-modules
|
||||
@@ -1,18 +0,0 @@
|
||||
[package]
|
||||
edition = "2024"
|
||||
name = "ironcalc_nodejs"
|
||||
version = "0.3.1"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
||||
napi = { version = "2.12.2", default-features = false, features = ["napi4", "serde-json"] }
|
||||
napi-derive = "2.12.2"
|
||||
ironcalc = { path = "../../xlsx", version = "0.3.0" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = "2.0.1"
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# IronCalc nodejs bindingds
|
||||
|
||||
|
||||
Example usage:
|
||||
|
||||
```javascript
|
||||
import { Model } from '@ironcalc/wasm';
|
||||
|
||||
const model = new Model("Workbook1", "en", "UTC");
|
||||
|
||||
model.setUserInput(0, 1, 1, "=1+1");
|
||||
const result1 = model.getFormattedCellValue(0, 1, 1);
|
||||
|
||||
console.log('Cell value', result1);
|
||||
|
||||
let result2 = model.getCellStyle(0, 1, 1);
|
||||
console.log('Cell style', result2);
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
import test from 'ava'
|
||||
|
||||
import { UserModel, Model } from '../index.js';
|
||||
|
||||
test('User Model smoke test', (t) => {
|
||||
const model = new UserModel("Workbook1", "en", "UTC");
|
||||
|
||||
model.setUserInput(0, 1, 1, "=1+1");
|
||||
t.is(model.getFormattedCellValue(0, 1, 1), '2');
|
||||
});
|
||||
|
||||
|
||||
test('Raw API smoke test', (t) => {
|
||||
const model = new Model("Workbook1", "en", "UTC");
|
||||
|
||||
model.setUserInput(0, 1, 1, "=1+1");
|
||||
model.evaluate();
|
||||
t.is(model.getFormattedCellValue(0, 1, 1), '2');
|
||||
});
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
extern crate napi_build;
|
||||
|
||||
fn main() {
|
||||
napi_build::setup();
|
||||
}
|
||||
Binary file not shown.
115
bindings/nodejs/index.d.ts
vendored
115
bindings/nodejs/index.d.ts
vendored
@@ -1,115 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
export declare class Model {
|
||||
constructor(name: string, locale: string, timezone: string)
|
||||
static fromXlsx(filePath: string, locale: string, tz: string): Model
|
||||
static fromIcalc(fileName: string): Model
|
||||
saveToXlsx(file: string): void
|
||||
saveToIcalc(file: string): void
|
||||
evaluate(): void
|
||||
setUserInput(sheet: number, row: number, column: number, value: string): void
|
||||
clearCellContents(sheet: number, row: number, column: number): void
|
||||
getCellContent(sheet: number, row: number, column: number): string
|
||||
getCellType(sheet: number, row: number, column: number): number
|
||||
getFormattedCellValue(sheet: number, row: number, column: number): string
|
||||
setCellStyle(sheet: number, row: number, column: number, style: unknown): void
|
||||
getCellStyle(sheet: number, row: number, column: number): unknown
|
||||
insertRows(sheet: number, row: number, rowCount: number): void
|
||||
insertColumns(sheet: number, column: number, columnCount: number): void
|
||||
deleteRows(sheet: number, row: number, rowCount: number): void
|
||||
deleteColumns(sheet: number, column: number, columnCount: number): void
|
||||
getColumnWidth(sheet: number, column: number): number
|
||||
getRowHeight(sheet: number, row: number): number
|
||||
setColumnWidth(sheet: number, column: number, width: number): void
|
||||
setRowHeight(sheet: number, row: number, height: number): void
|
||||
getFrozenColumnsCount(sheet: number): number
|
||||
getFrozenRowsCount(sheet: number): number
|
||||
setFrozenColumnsCount(sheet: number, columnCount: number): void
|
||||
setFrozenRowsCount(sheet: number, rowCount: number): void
|
||||
getWorksheetsProperties(): unknown
|
||||
setSheetColor(sheet: number, color: string): void
|
||||
addSheet(sheetName: string): void
|
||||
newSheet(): void
|
||||
deleteSheet(sheet: number): void
|
||||
renameSheet(sheet: number, newName: string): void
|
||||
getDefinedNameList(): unknown
|
||||
newDefinedName(name: string, scope: number | undefined | null, formula: string): void
|
||||
updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void
|
||||
deleteDefinedName(name: string, scope?: number | undefined | null): void
|
||||
testPanic(): void
|
||||
}
|
||||
export declare class UserModel {
|
||||
constructor(name: string, locale: string, timezone: string)
|
||||
static fromBytes(bytes: Uint8Array): UserModel
|
||||
canUndo(): boolean
|
||||
canRedo(): boolean
|
||||
pauseEvaluation(): void
|
||||
resumeEvaluation(): void
|
||||
flushSendQueue(): Array<number>
|
||||
applyExternalDiffs(diffs: Uint8Array): void
|
||||
getCellContent(sheet: number, row: number, column: number): string
|
||||
newSheet(): void
|
||||
deleteSheet(sheet: number): void
|
||||
hideSheet(sheet: number): void
|
||||
unhideSheet(sheet: number): void
|
||||
renameSheet(sheet: number, name: string): void
|
||||
setSheetColor(sheet: number, color: string): void
|
||||
rangeClearAll(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void
|
||||
rangeClearContents(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void
|
||||
insertRow(sheet: number, row: number): void
|
||||
insertColumn(sheet: number, column: number): void
|
||||
deleteRow(sheet: number, row: number): void
|
||||
deleteColumn(sheet: number, column: number): void
|
||||
setRowHeight(sheet: number, row: number, height: number): void
|
||||
setColumnWidth(sheet: number, column: number, width: number): void
|
||||
getRowHeight(sheet: number, row: number): number
|
||||
getColumnWidth(sheet: number, column: number): number
|
||||
setUserInput(sheet: number, row: number, column: number, input: string): void
|
||||
getFormattedCellValue(sheet: number, row: number, column: number): string
|
||||
getFrozenRowsCount(sheet: number): number
|
||||
getFrozenColumnsCount(sheet: number): number
|
||||
setFrozenRowsCount(sheet: number, count: number): void
|
||||
setFrozenColumnsCount(sheet: number, count: number): void
|
||||
updateRangeStyle(range: unknown, stylePath: string, value: string): void
|
||||
getCellStyle(sheet: number, row: number, column: number): unknown
|
||||
onPasteStyles(styles: unknown): void
|
||||
getCellType(sheet: number, row: number, column: number): number
|
||||
getWorksheetsProperties(): unknown
|
||||
getSelectedSheet(): number
|
||||
getSelectedCell(): Array<number>
|
||||
getSelectedView(): unknown
|
||||
setSelectedSheet(sheet: number): void
|
||||
setSelectedCell(row: number, column: number): void
|
||||
setSelectedRange(startRow: number, startColumn: number, endRow: number, endColumn: number): void
|
||||
setTopLeftVisibleCell(topRow: number, topColumn: number): void
|
||||
setShowGridLines(sheet: number, showGridLines: boolean): void
|
||||
getShowGridLines(sheet: number): boolean
|
||||
autoFillRows(sourceArea: unknown, toRow: number): void
|
||||
autoFillColumns(sourceArea: unknown, toColumn: number): void
|
||||
onArrowRight(): void
|
||||
onArrowLeft(): void
|
||||
onArrowUp(): void
|
||||
onArrowDown(): void
|
||||
onPageDown(): void
|
||||
onPageUp(): void
|
||||
setWindowWidth(windowWidth: number): void
|
||||
setWindowHeight(windowHeight: number): void
|
||||
getScrollX(): number
|
||||
getScrollY(): number
|
||||
onExpandSelectedRange(key: string): void
|
||||
onAreaSelecting(targetRow: number, targetColumn: number): void
|
||||
setAreaWithBorder(area: unknown, borderArea: unknown): void
|
||||
toBytes(): Array<number>
|
||||
getName(): string
|
||||
setName(name: string): void
|
||||
copyToClipboard(): unknown
|
||||
pasteFromClipboard(sourceSheet: number, sourceRange: unknown, clipboard: unknown, isCut: boolean): void
|
||||
pasteCsvText(area: unknown, csv: string): void
|
||||
getDefinedNameList(): unknown
|
||||
newDefinedName(name: string, scope: number | undefined | null, formula: string): void
|
||||
updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void
|
||||
deleteDefinedName(name: string, scope?: number | undefined | null): void
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
|
||||
const { platform, arch } = process
|
||||
|
||||
let nativeBinding = null
|
||||
let localFileExisted = false
|
||||
let loadError = null
|
||||
|
||||
function isMusl() {
|
||||
// For Node 10
|
||||
if (!process.report || typeof process.report.getReport !== 'function') {
|
||||
try {
|
||||
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
||||
return readFileSync(lddPath, 'utf8').includes('musl')
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
const { glibcVersionRuntime } = process.report.getReport().header
|
||||
return !glibcVersionRuntime
|
||||
}
|
||||
}
|
||||
|
||||
switch (platform) {
|
||||
case 'android':
|
||||
switch (arch) {
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(join(__dirname, 'nodejs.android-arm64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.android-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-android-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(join(__dirname, 'nodejs.android-arm-eabi.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.android-arm-eabi.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-android-arm-eabi')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Android ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'win32':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.win32-x64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.win32-x64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-win32-x64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'ia32':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.win32-ia32-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.win32-ia32-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-win32-ia32-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.win32-arm64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.win32-arm64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-win32-arm64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'darwin':
|
||||
localFileExisted = existsSync(join(__dirname, 'nodejs.darwin-universal.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.darwin-universal.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-darwin-universal')
|
||||
}
|
||||
break
|
||||
} catch {}
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(join(__dirname, 'nodejs.darwin-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.darwin-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-darwin-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.darwin-arm64.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.darwin-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-darwin-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'freebsd':
|
||||
if (arch !== 'x64') {
|
||||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
||||
}
|
||||
localFileExisted = existsSync(join(__dirname, 'nodejs.freebsd-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.freebsd-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-freebsd-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'linux':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-x64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-x64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-x64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-x64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-x64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-x64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-arm64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-arm64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-arm64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-arm64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-arm64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-arm64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-arm-musleabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-arm-musleabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-arm-musleabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-arm-gnueabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'riscv64':
|
||||
if (isMusl()) {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-riscv64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-riscv64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-riscv64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
} else {
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-riscv64-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-riscv64-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-riscv64-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
}
|
||||
break
|
||||
case 's390x':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'nodejs.linux-s390x-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./nodejs.linux-s390x-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@ironcalc/nodejs-linux-s390x-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
if (loadError) {
|
||||
throw loadError
|
||||
}
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { Model, UserModel } = nativeBinding
|
||||
|
||||
module.exports.Model = Model
|
||||
module.exports.UserModel = UserModel
|
||||
@@ -1,28 +0,0 @@
|
||||
import { UserModel, Model } from './index.js'
|
||||
|
||||
|
||||
function testUserModel() {
|
||||
const model = new UserModel("Workbook1", "en", "UTC");
|
||||
|
||||
model.setUserInput(0, 1, 1, "=1+1");
|
||||
let t = model.getFormattedCellValue(0, 1, 1);
|
||||
|
||||
console.log('From native', t);
|
||||
|
||||
let t2 = model.getCellStyle(0, 1, 1);
|
||||
console.log('From native', t2);
|
||||
}
|
||||
|
||||
function testModel() {
|
||||
const model = Model.fromXlsx("example.xlsx", "en", "UTC");
|
||||
const style = model.getCellStyle(0, 1, 6);
|
||||
console.log(style);
|
||||
|
||||
const quantum = model.getFormattedCellValue(0, 14, 4);
|
||||
console.log(quantum);
|
||||
|
||||
}
|
||||
|
||||
|
||||
testUserModel();
|
||||
testModel();
|
||||
@@ -1,3 +0,0 @@
|
||||
# `@ironcalc/nodejs-android-arm-eabi`
|
||||
|
||||
This is the **armv7-linux-androideabi** binary for `@ironcalc/nodejs`
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "@ironcalc/nodejs-android-arm-eabi",
|
||||
"version": "0.2.0",
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"main": "nodejs.android-arm-eabi.node",
|
||||
"files": [
|
||||
"nodejs.android-arm-eabi.node"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user