streamlit-luckysheet


Namestreamlit-luckysheet JSON
Version 0.1.9 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-11-19 22:51:10
maintainerNone
docs_urlNone
authorTAN YI HAO
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # streamlit-luckysheet

2024 Aug 18 First Ever Streamlit luckysheet. Credit To TAN YIHAO

## Installation instructions

```sh
pip install streamlit-luckysheet
```

## Usage instructions

```python
import streamlit as st
from streamlit_luckysheet import streamlit_luckysheet
import base64
import os

st.set_page_config(layout="wide")
st.subheader("Component with constant args")

name = "Streamlit_Excelsheet"
key = "Streamlit_Excelsheet"
height = 1000
excel_path = r".\excel\Employee Sample Data.xlsx"
output_path = r".\excel\testing.xlsx"

def excel_to_file(path):
    try:
        if not os.path.exists(path):
            return ""
        with open(path, 'rb') as file:
            file_data = file.read()
            if file_data:
                return base64.b64encode(file_data).decode('utf-8')
            else:
                st.warning("File is empty or could not be read.")
                return ""
    except Exception as e:
        st.warning(f"An error occurred while processing the file: {e}")
        return ""

def base64_to_excel(base64_string, output_path):
    try:
        output_dir = os.path.dirname(output_path)
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        file_data = base64.b64decode(base64_string)
        with open(output_path, 'wb') as file:
            file.write(file_data)
        st.success(f"Excel file successfully created at: {output_path}")

    except Exception as e:
        st.warning(f"An error occurred while converting to Excel file: {e}")

encodedFile = excel_to_file(excel_path)

return_result = streamlit_luckysheet(name=name, height=height, encodedFile=encodedFile, key=key, default=[])
if isinstance(return_result, dict) and "incoming_save" in return_result:
    if return_result["incoming_save"]:
        base64_string = return_result["incoming_save"]
        base64_to_excel(base64_string, output_path)




```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "streamlit-luckysheet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "TAN YI HAO",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/c5/b7/cbfeb18e7db5d1f626d225a59727efbaa23ae2b7c895caa2c8686c1268b0/streamlit_luckysheet-0.1.9.tar.gz",
    "platform": null,
    "description": "# streamlit-luckysheet\r\n\r\n2024 Aug 18 First Ever Streamlit luckysheet. Credit To TAN YIHAO\r\n\r\n## Installation instructions\r\n\r\n```sh\r\npip install streamlit-luckysheet\r\n```\r\n\r\n## Usage instructions\r\n\r\n```python\r\nimport streamlit as st\r\nfrom streamlit_luckysheet import streamlit_luckysheet\r\nimport base64\r\nimport os\r\n\r\nst.set_page_config(layout=\"wide\")\r\nst.subheader(\"Component with constant args\")\r\n\r\nname = \"Streamlit_Excelsheet\"\r\nkey = \"Streamlit_Excelsheet\"\r\nheight = 1000\r\nexcel_path = r\".\\excel\\Employee Sample Data.xlsx\"\r\noutput_path = r\".\\excel\\testing.xlsx\"\r\n\r\ndef excel_to_file(path):\r\n    try:\r\n        if not os.path.exists(path):\r\n            return \"\"\r\n        with open(path, 'rb') as file:\r\n            file_data = file.read()\r\n            if file_data:\r\n                return base64.b64encode(file_data).decode('utf-8')\r\n            else:\r\n                st.warning(\"File is empty or could not be read.\")\r\n                return \"\"\r\n    except Exception as e:\r\n        st.warning(f\"An error occurred while processing the file: {e}\")\r\n        return \"\"\r\n\r\ndef base64_to_excel(base64_string, output_path):\r\n    try:\r\n        output_dir = os.path.dirname(output_path)\r\n        if not os.path.exists(output_dir):\r\n            os.makedirs(output_dir)\r\n\r\n        file_data = base64.b64decode(base64_string)\r\n        with open(output_path, 'wb') as file:\r\n            file.write(file_data)\r\n        st.success(f\"Excel file successfully created at: {output_path}\")\r\n\r\n    except Exception as e:\r\n        st.warning(f\"An error occurred while converting to Excel file: {e}\")\r\n\r\nencodedFile = excel_to_file(excel_path)\r\n\r\nreturn_result = streamlit_luckysheet(name=name, height=height, encodedFile=encodedFile, key=key, default=[])\r\nif isinstance(return_result, dict) and \"incoming_save\" in return_result:\r\n    if return_result[\"incoming_save\"]:\r\n        base64_string = return_result[\"incoming_save\"]\r\n        base64_to_excel(base64_string, output_path)\r\n\r\n\r\n\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.9",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d1c4a8efaa2a0d3ba34a3a8bf5787383cf18a64f73f9a35aab255de1e71801d",
                "md5": "97a05f24f0adef937cc198616d844a4d",
                "sha256": "590be42e4a0f95a92e659622927c09b445be18b820946ca269716603cfaa1778"
            },
            "downloads": -1,
            "filename": "streamlit_luckysheet-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97a05f24f0adef937cc198616d844a4d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 24887521,
            "upload_time": "2024-11-19T22:50:28",
            "upload_time_iso_8601": "2024-11-19T22:50:28.340227Z",
            "url": "https://files.pythonhosted.org/packages/7d/1c/4a8efaa2a0d3ba34a3a8bf5787383cf18a64f73f9a35aab255de1e71801d/streamlit_luckysheet-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5b7cbfeb18e7db5d1f626d225a59727efbaa23ae2b7c895caa2c8686c1268b0",
                "md5": "274f82fa6b24ee33521e900cef3270e1",
                "sha256": "7dc1ed7e8706f03e041dec7e6fcd6da0266c7d5da7db8e177e6b6692036dde62"
            },
            "downloads": -1,
            "filename": "streamlit_luckysheet-0.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "274f82fa6b24ee33521e900cef3270e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6074993,
            "upload_time": "2024-11-19T22:51:10",
            "upload_time_iso_8601": "2024-11-19T22:51:10.510295Z",
            "url": "https://files.pythonhosted.org/packages/c5/b7/cbfeb18e7db5d1f626d225a59727efbaa23ae2b7c895caa2c8686c1268b0/streamlit_luckysheet-0.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-19 22:51:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "streamlit-luckysheet"
}
        
Elapsed time: 1.54424s