ver Dec29thv4
updated check_zoom
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
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 .utils import load_charts, load_sparklines
|
||||
import operator
|
||||
|
||||
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:
|
||||
@@ -104,11 +106,17 @@ def check_sheet_list(result: str, rules: List[Dict[str, Any]]) -> float:
|
||||
|
||||
return float(passes)
|
||||
|
||||
|
||||
def check_xlsx_freeze(result: str, rules: Dict[str, str]) -> float:
|
||||
worksheet: Worksheet = openpyxl.load_workbook(filename=result).active
|
||||
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__':
|
||||
# path1 = ""
|
||||
@@ -146,12 +154,12 @@ if __name__ == '__main__':
|
||||
# ]
|
||||
# print(check_sheet_list(path1, rule))
|
||||
|
||||
path1 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||
path2 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
||||
print(compare_table(path1, path2, features=["chart"], chart_props=["type", "direction"]))
|
||||
#path1 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
|
||||
#path2 = "../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
|
||||
#print(compare_table(path1, path2, features=["chart"], chart_props=["type", "direction"]))
|
||||
|
||||
path1 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold.xlsx"
|
||||
path2 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold3.xlsx"
|
||||
#path1 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold.xlsx"
|
||||
#path2 = "../../任务数据/LibreOffice Calc/Represent_in_millions_billions_gold3.xlsx"
|
||||
#workbook1: Workbook = openpyxl.load_workbook(filename=path1)
|
||||
#worksheet1: Worksheet = workbook1.active
|
||||
#
|
||||
@@ -163,4 +171,21 @@ if __name__ == '__main__':
|
||||
#print(worksheet1[position])
|
||||
#print(worksheet1[position].value)
|
||||
#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}))
|
||||
|
||||
Reference in New Issue
Block a user