ver Dec29thv4
updated check_zoom
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
from .table import compare_table
|
from .table import compare_table
|
||||||
from .table import check_sheet_list, check_xlsx_freeze
|
from .table import check_sheet_list, check_xlsx_freeze, check_zoom
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ from openpyxl import Workbook
|
|||||||
from openpyxl.worksheet.worksheet import Worksheet
|
from openpyxl.worksheet.worksheet import Worksheet
|
||||||
|
|
||||||
from .utils import load_charts, load_sparklines
|
from .utils import load_charts, load_sparklines
|
||||||
|
import operator
|
||||||
|
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
|
from numbers import Number
|
||||||
|
|
||||||
|
|
||||||
def compare_table(actual: str, expected: str, **options) -> float:
|
def compare_table(actual: str, expected: str, **options) -> float:
|
||||||
@@ -104,11 +106,17 @@ def check_sheet_list(result: str, rules: List[Dict[str, Any]]) -> float:
|
|||||||
|
|
||||||
return float(passes)
|
return float(passes)
|
||||||
|
|
||||||
|
|
||||||
def check_xlsx_freeze(result: str, rules: Dict[str, str]) -> float:
|
def check_xlsx_freeze(result: str, rules: Dict[str, str]) -> float:
|
||||||
worksheet: Worksheet = openpyxl.load_workbook(filename=result).active
|
worksheet: Worksheet = openpyxl.load_workbook(filename=result).active
|
||||||
return float(worksheet.freeze_panes == rules["position"])
|
return float(worksheet.freeze_panes == rules["position"])
|
||||||
|
|
||||||
|
def check_zoom(result: str, rules: Dict[str, Union[str, Number]]) -> float:
|
||||||
|
worksheet = openpyxl.load_workbook(filename=result).active
|
||||||
|
zoom_scale: Number = worksheet.sheet_view.zoomScale or 100.
|
||||||
|
return float( getattr(operator, rules["relation"])( zoom_scale
|
||||||
|
, rules["ref_value"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# path1 = ""
|
# path1 = ""
|
||||||
@@ -146,12 +154,12 @@ if __name__ == '__main__':
|
|||||||
# ]
|
# ]
|
||||||
# print(check_sheet_list(path1, rule))
|
# print(check_sheet_list(path1, rule))
|
||||||
|
|
||||||
path1 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
#path1 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||||
path2 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
#path2 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
||||||
print(compare_table(path1, path2, features=["chart"], chart_props=["type", "direction"]))
|
#print(compare_table(path1, path2, features=["chart"], chart_props=["type", "direction"]))
|
||||||
|
|
||||||
path1 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold.xlsx"
|
#path1 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold.xlsx"
|
||||||
path2 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold3.xlsx"
|
#path2 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold3.xlsx"
|
||||||
#workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
#workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||||
#worksheet1: Worksheet = workbook1.active
|
#worksheet1: Worksheet = workbook1.active
|
||||||
#
|
#
|
||||||
@@ -163,4 +171,21 @@ if __name__ == '__main__':
|
|||||||
#print(worksheet1[position])
|
#print(worksheet1[position])
|
||||||
#print(worksheet1[position].value)
|
#print(worksheet1[position].value)
|
||||||
#print(worksheet1[position].number_format)
|
#print(worksheet1[position].number_format)
|
||||||
print(compare_table(path1, path2, features=["number_format"]))
|
#print(compare_table(path1, path2, features=["number_format"]))
|
||||||
|
|
||||||
|
path1 = "../../任务数据/LibreOffice Calc/Zoom_Out_Oversized_Cells_gold.xlsx"
|
||||||
|
path2 = "../../任务数据/LibreOffice Calc/Zoom_Out_Oversized_Cells.xlsx"
|
||||||
|
#workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||||
|
#worksheet1: Worksheet = workbook1.active
|
||||||
|
#print(worksheet1.sheet_view.zoomScale)
|
||||||
|
#print(type(worksheet1.sheet_view.zoomScale))
|
||||||
|
#
|
||||||
|
#import os
|
||||||
|
#import os.path
|
||||||
|
#for wb in filter( lambda f: f.endswith(".xlsx")
|
||||||
|
#, os.listdir("../../任务数据/LibreOffice Calc/")
|
||||||
|
#):
|
||||||
|
#path = os.path.join("../../任务数据/LibreOffice Calc/", wb)
|
||||||
|
#print(wb, openpyxl.load_workbook(filename=path).active.sheet_view.zoomScale)
|
||||||
|
print(check_zoom(path1, {"relation": "lt", "ref_value": 100}))
|
||||||
|
print(check_zoom(path2, {"relation": "lt", "ref_value": 100}))
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"id": "1334ca3e-f9e3-4db8-9ca7-b4c653be7d17",
|
||||||
|
"snapshot": "libreoffice_calc",
|
||||||
|
"instruction": "The cells are so big that I can not click on the cell I want, zoom out a little bit.",
|
||||||
|
"source": "https://techcommunity.microsoft.com/t5/excel/excel-workbook-top-way-too-big-can-t-see-rows-and-columns/m-p/4014694",
|
||||||
|
"config": [
|
||||||
|
{
|
||||||
|
"type": "download",
|
||||||
|
"parameters": {
|
||||||
|
"file": [
|
||||||
|
{
|
||||||
|
"url": "https://drive.usercontent.google.com/download?id=1Wkepf_vic9o7CZFiosZ4jZT_Hy2WbRPZ&export=download&authuser=0&confirm=t&uuid=bc2ce901-a6bb-433f-bcce-cbe42d813f18&at=APZUnTVQcGTcXjwqenmtSH6IMFkM:1703858853235",
|
||||||
|
"path": "/home/david/Zoom_Out_Oversized_Cells.xlsx"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "open",
|
||||||
|
"parameters": {
|
||||||
|
"path": "/home/david/Zoom_Out_Oversized_Cells.xlsx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"trajectory": "trajectories/1334ca3e-f9e3-4db8-9ca7-b4c653be7d17",
|
||||||
|
"related_apps": [
|
||||||
|
"libreoffice_calc"
|
||||||
|
],
|
||||||
|
"evaluator": {
|
||||||
|
"func": "check_zoom",
|
||||||
|
"result": {
|
||||||
|
"type": "vm_file",
|
||||||
|
"path": "/home/david/Zoom_Out_Oversized_Cells.xlsx",
|
||||||
|
"dest": "Zoom_Out_Oversized_Cells.xlsx"
|
||||||
|
},
|
||||||
|
"expected": {
|
||||||
|
"type": "rule",
|
||||||
|
"rules": {
|
||||||
|
"relation": "lt",
|
||||||
|
"ref_value": 260
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user