Introduction #
SmartChart supports reading and writing Feishu (Lark) spreadsheet data as a data source. Access Feishu sheet data through the Feishu Open API, enabling data synchronization between SmartChart and Feishu.
Configuration #
Driver: feishu_sheet
Connection address: https://open.feishu.cn
Username: App ID
Password: App Secret
Usage #
Write query configuration in the dataset editor:
def dataset(*args, **kwargs):
sqlList = args[0]
config = args[1]
# Get tenant access token
import requests
token_url = f"{config['host']}/open-apis/auth/v3/tenant_access_token/internal"
token_resp = requests.post(token_url, json={
"app_id": config['user'],
"app_secret": config['password']
})
token = token_resp.json()['tenant_access_token']
# Read spreadsheet
sheet_token = sqlList[0]
range_str = sqlList[1] if len(sqlList) > 1 else "A1:Z1000"
url = f"{config['host']}/open-apis/sheets/v2/spreadsheets/{sheet_token}/values/{range_str}"
headers = {"Authorization": f"Bearer {token}"}
response = requests.get(url, headers=headers)
return response.json().get('data', {}).get('valueRange', {}).get('values', [])
Use Cases #
- Read Feishu sheet data for visualization
- Write SmartChart data back to Feishu sheets
- Synchronize data between Feishu and databases
Requires a Feishu app with appropriate API permissions (sheet:read, sheet:write).