caxlsr.gms : Test Connect agent ExcelReader

Description

This test ensures the correctness of the Connect agent ExcelReader.

Contributor: Clemens Westphal, December 2023


Small Model of Type : GAMS


Category : GAMS Test library


Main file : caxlsr.gms   includes :   caxlsr_tests.inc [html]

$title 'Test Connect agent ExcelReader' (CAXLSR,SEQ=950)

$onText
This test ensures the correctness of the Connect agent ExcelReader.

Contributor: Clemens Westphal, December 2023
$offText


$log --- Using Python library %sysEnv.GMSPYTHONLIB%

$log Start testing xlsx
$include caxlsr_tests.inc

$if not errorfree $abort Errors in xlsx tests

$log Start testing xlsb
$callTool win32.msappavail Excel
$if errorlevel 1 $abort.noError "No Excel available"

$log Converting caxlsr.xlsx to caxlsr.xlsb
$onEmbeddedCode Python:
import xlwings as xw
from pathlib import Path

# convert caxlsr.xlsx to caxlsr.xlsb
app = xw.App(visible=False, add_book=False)
try:
    app.display_alerts = False
    p_src = Path.cwd() / "caxlsr.xlsx"
    p_dst = Path.cwd() / "caxlsr.xlsb"
    wb = app.books.open(str(p_src), update_links=False, read_only=False)
    wb.save(str(p_dst))
    wb.close()
finally:
    app.quit()

# convert caxlsr_tests.inc to caxlsr_tests_b.inc
p_src = Path.cwd() / "caxlsr_tests.inc"
p_dst = Path.cwd() / "caxlsr_tests_b.inc"
with open(p_src, "r") as f:
    s = f.read()
s = s.replace("caxlsr.xlsx", "caxlsr.xlsb")
with open(p_dst, "w") as f:
    f.write(s)

$offEmbeddedCode

$include caxlsr_tests_b.inc