How to get sheet name from EXCEL file in Compose


Answers
-
Compose natively support reading and write to excel files, but the functionality is limited.
If you need more extensive operations on excel worksheet, you can choose other python packages that read/write excel and get the data back to Compose workspace
There are two steps:
First, cd to Compose install directory in a dos prompt <Compose root>\common\python\python3.4\win64
Run following command to upgrade pip and install python package openpyxl
python.exe -m pip install --upgrade pip
python.exe -m pip install openpyxlNext, in Compose, create an empty python file, and run following commands to load an excel file, query the sheets, etc.
Detailed usage of openpyxl can be found at their wiki site https://openpyxl.readthedocs.io/en/stable/
from openpyxl.reader.excel import load_workbook
wb=load_workbook('C:/Users/ganhai/Desktop/tmp/example.xlsx')
sheets = wb.get_sheet_names()
exporttooml('sheets', 'sheets')In Compose oml command window, you can check the variable named sheets hold the values sent from python workspace
> sheets
sheets =
{
[1,1] Sheet1
[1,2] Sheet2
[1,3] Sheet3
[1,4] Sheet4
}In Compose documentation reference guide, we provide following functions to interface to python world
0 -
I will share the sample script 'stc_xlsheet.oml' which uses simple calling python function 'python_call.oml'.
0