ver Feb20thv2

corrected several SheetCopilot tasks
fixed load_charts
This commit is contained in:
David Chang
2024-02-20 23:29:13 +08:00
parent 96e2c6ee34
commit 807818c9a2
7 changed files with 51 additions and 36 deletions

View File

@@ -144,7 +144,10 @@ def compare_table(result: str, expected: str = None, **options) -> float:
metric: bool = sheet1.equals(sheet2)
logger.debug("Sheet1: \n%s", str(sheet1))
logger.debug("Sheet2: \n%s", str(sheet2))
logger.debug("Sheet1 =v= Sheet2: \n%s", str(sheet1==sheet2))
try:
logger.debug("Sheet1 =v= Sheet2: \n%s", str(sheet1==sheet2))
except:
logger.debug("Sheet1 =/v= Sheet2")
logger.debug("Assertion: %s =v= %s - %s", r["sheet_idx0"], r["sheet_idx1"], metric)
# }}} Compare Sheet Data by Internal Value #

View File

@@ -119,22 +119,15 @@ def load_charts(xlsx_file: Workbook, sheet_name: str, **options) -> Dict[str, An
for ch in charts:
series: List[str] = []
for ser in ch.series:
value_num = ser.val.numRef.f \
if hasattr(ser.val, "numRef") and hasattr(ser.val.numRef, "f") \
else ""
value_str = ser.val.strRef.f \
if hasattr(ser.val, "strRef") and hasattr(ser.val.strRef, "f") \
else ""
categ_num = ser.cat.numRef.f \
if hasattr(ser.cat, "numRef") and hasattr(ser.cat.numRef, "f") \
else ""
categ_str = ser.cat.strRef.f \
if hasattr(ser.cat, "strRef") and hasattr(ser.cat.strRef, "f") \
else ""
series.append("{:},{:},{:},{:}".format(value_num, value_str
, categ_num, categ_str
)
)
if hasattr(ser.val, "numRef") and hasattr(ser.val.numRef, "f"):
value_str: str = ser.val.numRef.f
elif hasattr(ser.val, "strRef") and hasattr(ser.val.strRef, "f"):
value_str: str = ser.val.strRef.f
if hasattr(ser.cat, "numRef") and hasattr(ser.cat.numRef, "f"):
categ_str: str = ser.cat.numRef.f
elif hasattr(ser.cat, "strRef") and hasattr(ser.cat.strRef, "f"):
categ_str: str = ser.cat.strRef.f
series.append("{:},{:}".format(value_str, categ_str))
series: str = ";".join(series)
# TODO: maybe more aspects, like chart type

View File

@@ -1,7 +1,7 @@
{
"id": "035f41ba-6653-43ab-aa63-c86d449d62e5",
"snapshot": "libreoffice_calc",
"instruction": "Help me fill in the Gross profit column and set the results as accounting type. Then under column A named \"Year_Profit\" in a new sheet, display the Year Column in Sheet 1 as text appended by a \"_\" with the corresponding Gross Profit value.",
"instruction": "Help me fill in the Gross profit column. Then under column A named \"Year_Profit\" in a new sheet, display the Year Column in Sheet 1 as text appended by a \"_\" with the corresponding Gross Profit value.",
"source": "SheetCopilot@92",
"config": [
{

View File

@@ -73,8 +73,8 @@
"rules": [
{
"type": "sheet_data",
"sheet_idx0": 0,
"sheet_idx1": "EI0"
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2"
}
]
}

View File

@@ -1,7 +1,7 @@
{
"id": "28047f4a-d877-4bea-95f7-e42b1c919957",
"snapshot": "libreoffice_calc",
"instruction": "Summarize the sales for each product and illustrate it with a bar chart in a new sheet.",
"instruction": "Summarize the sales for each product and illustrate it with a bar chart in a new sheet (Sheet2).",
"source": "SheetCopilot@108",
"config": [
{
@@ -54,7 +54,7 @@
{
"type": "sleep",
"parameters": {
"seconds": 0.5
"seconds": 2.0
}
}
],
@@ -73,16 +73,16 @@
"rules": [
{
"type": "chart",
"sheet_idx0": 0,
"sheet_idx1": "EI0",
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2",
"chart_props": [
"type"
]
},
{
"type": "pivot_table",
"sheet_idx0": 0,
"sheet_idx1": "EI0",
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2",
"pivot_props": [
"col_fields",
"filter",

View File

@@ -73,19 +73,38 @@
"rules": [
{
"type": "sheet_data",
"sheet_idx0": 0,
"sheet_idx1": "EI0"
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2"
},
{
"type": "pivot_table",
"sheet_idx0": 0,
"sheet_idx1": "EI0",
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2",
"pivot_props": [
"col_fields",
"filter",
"row_fields",
"data_fields"
]
},
{
"type": "check_cell",
"sheet_idx": "RNSheet2",
"coordinate": "A1",
"props": {
"bgcolor": {
"method": "eq",
"ref": "FF0000FF"
},
"font_color": {
"method": "eq",
"ref": "FFFFFFFF"
},
"font_bold": {
"method": "eq",
"ref": true
}
}
}
]
}

View File

@@ -73,8 +73,8 @@
"rules": [
{
"type": "sheet_data",
"sheet_idx0": 0,
"sheet_idx1": "EI0"
"sheet_idx0": "RNSheet2",
"sheet_idx1": "ENSheet2"
}
]
}