Skip to main content

Reflex wrapper for FortuneSheet with Excel import/export (FortuneExcel)

Project description

reflex-fortune-sheet

PyPI Python

Reflex wrapper for FortuneSheet with Excel import/export via FortuneExcel.

Reflex 封装的 FortuneSheet 表格组件,并通过 FortuneExcel 支持 Excel 导入/导出。

English · 中文 · Framework docs (EN) · PyPI


English

Features

  • Spreadsheet UI powered by @fortune-sheet/react
  • Excel/CSV import & export toolbar (FortuneExcel), with localized tooltips
  • on_change — full workbook snapshot (save / persist)
  • on_op — fine-grained Op stream (audit / collaboration hooks)
  • revision — explicit reload control (avoids controlled-data loops)
  • Built-in StrictMode on_op dedupe (safe default for library consumers)

Requirements

  • Python >=3.10
  • Reflex >=0.9.0

Install

pip install reflex-fortune-sheet

Or with uv:

uv add reflex-fortune-sheet

From this repository (development):

pip install -e .

Frontend packages (@fortune-sheet/react, @corbe30/fortune-excel) are declared as Reflex lib_dependencies and install automatically when the app compiles.

Quick start

import reflex as rx
from reflex_fortune_sheet import fortune_sheet


class State(rx.State):
    sheets: list[dict] = [
        {
            "name": "Sheet1",
            "row": 36,
            "column": 18,
            "celldata": [
                {"r": 0, "c": 0, "v": {"v": "Hello", "m": "Hello"}},
            ],
        }
    ]
    revision: int = 0

    @rx.event
    def on_change(self, data: list[dict]):
        # Snapshot only — do NOT bump revision here.
        self.sheets = data

    @rx.event
    def on_op(self, ops: list[dict]):
        # Fine-grained ops for audit / sync.
        print(ops)

    @rx.event
    def reload(self):
        # Force Workbook remount with current `sheets`.
        self.revision += 1


def index():
    return fortune_sheet(
        data=State.sheets,
        revision=State.revision,
        lang="en",
        height="70vh",
        width="100%",
        on_change=State.on_change,
        on_op=State.on_op,
    )


app = rx.App()
app.add_page(index)

Run the demo in this repo

git clone https://github.com/JiaLiangChen99/reflex_fortune_sheet.git
cd reflex_fortune_sheet
pip install -e .
reflex run

App module: reflex_fortune_sheet_demo.

Data contract (important)

Prop / event Role
data Initial / revision-scoped input only
revision Bump to force-reload Workbook from data
on_change Content snapshot (selection ignored)
on_op Op[] from FortuneSheet (onOp)

Changing data without bumping revision does not remount the sheet. That prevents feedback loops when you persist on_change back into state.

Documentation

Full English framework docs:

Upstream:

Links


中文

功能

  • 基于 @fortune-sheet/react 的在线表格
  • 通过 FortuneExcel 提供 Excel/CSV 导入导出工具栏(工具提示可随 lang 本地化)
  • on_change:整表快照(适合保存/持久化)
  • on_op:细粒度 Op 流(适合审计/协同同步)
  • revision:显式控制重载(避免受控数据回环)
  • 默认开启 StrictMode 下的 on_op 去重(面向库用户的安全默认)

环境要求

  • Python >=3.10
  • Reflex >=0.9.0

安装

pip install reflex-fortune-sheet

或使用 uv

uv add reflex-fortune-sheet

本仓库开发安装:

pip install -e .

前端依赖(@fortune-sheet/react@corbe30/fortune-excel)已在组件的 lib_dependencies 中声明,应用编译时会自动安装。

快速开始

import reflex as rx
from reflex_fortune_sheet import fortune_sheet


class State(rx.State):
    sheets: list[dict] = [
        {
            "name": "Sheet1",
            "row": 36,
            "column": 18,
            "celldata": [
                {"r": 0, "c": 0, "v": {"v": "你好", "m": "你好"}},
            ],
        }
    ]
    revision: int = 0

    @rx.event
    def on_change(self, data: list[dict]):
        # 只存快照 —— 这里不要 bump revision。
        self.sheets = data

    @rx.event
    def on_op(self, ops: list[dict]):
        print(ops)

    @rx.event
    def reload(self):
        self.revision += 1


def index():
    return fortune_sheet(
        data=State.sheets,
        revision=State.revision,
        lang="zh",
        height="70vh",
        width="100%",
        on_change=State.on_change,
        on_op=State.on_op,
    )


app = rx.App()
app.add_page(index)

运行本仓库 Demo

git clone https://github.com/JiaLiangChen99/reflex_fortune_sheet.git
cd reflex_fortune_sheet
pip install -e .
reflex run

应用名:reflex_fortune_sheet_demo

数据契约(重要)

属性 / 事件 作用
data 仅作为初始 / revision 作用域输入
revision 递增后强制用当前 data 重载 Workbook
on_change 内容快照(忽略选区等 UI 状态)
on_op FortuneSheet onOp 产出的 Op[]

只改 data增加 revision不会重挂载表格。这样你把 on_change 写回 State 时不会形成受控回环。

文档

英文框架文档:

上游文档:

链接

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reflex_fortune_sheet-0.1.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reflex_fortune_sheet-0.1.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file reflex_fortune_sheet-0.1.1.tar.gz.

File metadata

  • Download URL: reflex_fortune_sheet-0.1.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for reflex_fortune_sheet-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a438989b0ec345e729b30d99fe946c118bdccff13a0b1050a72c55209c6b0da6
MD5 7666619ce003a2614a0438d9c82ec015
BLAKE2b-256 32d12d29034affa05657107c43e65f0da7afeb2dba5b33d49c1a1c579ec50b2a

See more details on using hashes here.

File details

Details for the file reflex_fortune_sheet-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for reflex_fortune_sheet-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59b904af3919496f3830f88f8a63ae5323299c747ba7a34cd43a8cb8c0f9d68d
MD5 0b6989aaa8521ab73e8e8c009cf46e87
BLAKE2b-256 677912e56d404af4970bee120499fe1fbdfdcf6b89776f7da15e8316c778d0de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page