diff --git a/ExternData/Examples/package.mo b/ExternData/Examples/package.mo index 588c3806..de92ee73 100644 --- a/ExternData/Examples/package.mo +++ b/ExternData/Examples/package.mo @@ -55,6 +55,7 @@ package Examples "Test examples" Modelica.Blocks.Math.Gain gain1(k=jsonfile.getReal("set1.gain.k")) annotation(Placement(transformation(extent={{-15,60},{5,80}}))); Modelica.Blocks.Math.Gain gain2(k=Modelica.Utilities.Strings.scanReal(jsonfile.getString("set2.gain.k"))) annotation(Placement(transformation(extent={{-15,30},{5,50}}))); Modelica.Blocks.Sources.Clock clock annotation(Placement(transformation(extent={{-50,60},{-30,80}}))); + parameter Integer m = jsonfile.getArrayRows2D("table1") "Number of rows in 2D array"; Modelica.Blocks.Sources.TimeTable timeTable(table=jsonfile.getRealArray2D("table1", 3, 2)) annotation(Placement(transformation(extent={{-50,30},{-30,50}}))); equation connect(clock.y,gain1.u) annotation(Line(points={{-29,70},{-17,70}}, color={0,0,127})); @@ -77,6 +78,7 @@ package Examples "Test examples" Modelica.Blocks.Math.Gain gain1(k=xlsfile.getReal("B2", "set1")) annotation(Placement(transformation(extent={{-15,60},{5,80}}))); Modelica.Blocks.Math.Gain gain2(k=Modelica.Utilities.Strings.scanReal(xlsfile.getString("B2", "set2"))) annotation(Placement(transformation(extent={{-15,30},{5,50}}))); Modelica.Blocks.Sources.Clock clock annotation(Placement(transformation(extent={{-50,60},{-30,80}}))); + parameter Integer m = xlsfile.getArrayRows2D("table1") "Number of rows in 2D array"; Modelica.Blocks.Sources.TimeTable timeTable(table=xlsfile.getRealArray2D("A1", "table1", 3, 2)) annotation(Placement(transformation(extent={{-50,30},{-30,50}}))); parameter Real sumB = computeColSum(xlsfile, "B") "Sum of column B"; function computeColSum "Compute column sum" @@ -116,6 +118,7 @@ package Examples "Test examples" Modelica.Blocks.Math.Gain gain1(k=xlsxfile.getReal("B2", "set1")) annotation(Placement(transformation(extent={{-15,60},{5,80}}))); Modelica.Blocks.Math.Gain gain2(k=Modelica.Utilities.Strings.scanReal(xlsxfile.getString("B2", "set2"))) annotation(Placement(transformation(extent={{-15,30},{5,50}}))); Modelica.Blocks.Sources.Clock clock annotation(Placement(transformation(extent={{-50,60},{-30,80}}))); + parameter Integer m = xlsxfile.getArrayRows2D("table1") "Number of rows in 2D array"; Modelica.Blocks.Sources.TimeTable timeTable(table=xlsxfile.getRealArray2D("A1", "table1", 3, 2)) annotation(Placement(transformation(extent={{-50,30},{-30,50}}))); parameter Real sumB = computeColSum(xlsxfile, "B") "Sum of column B"; function computeColSum "Compute column sum" diff --git a/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSFile.def b/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSFile.def index e46a2ab4..26c43271 100644 --- a/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSFile.def +++ b/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSFile.def @@ -5,3 +5,4 @@ EXPORTS ED_getStringFromXLS ED_getIntFromXLS ED_getDoubleArray2DFromXLS + ED_getArray2DDimensionsFromXLS diff --git a/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSXFile.def b/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSXFile.def index d31da946..469be395 100644 --- a/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSXFile.def +++ b/ExternData/Resources/BuildProjects/VisualStudio2010/ED_XLSXFile.def @@ -5,3 +5,4 @@ EXPORTS ED_getStringFromXLSX ED_getIntFromXLSX ED_getDoubleArray2DFromXLSX + ED_getArray2DDimensionsFromXLSX diff --git a/ExternData/Resources/C-Sources/ED_JSONFile.c b/ExternData/Resources/C-Sources/ED_JSONFile.c index 0de57449..e0e9b591 100644 --- a/ExternData/Resources/C-Sources/ED_JSONFile.c +++ b/ExternData/Resources/C-Sources/ED_JSONFile.c @@ -49,7 +49,8 @@ typedef struct { ED_LOCALE_TYPE loc; } JSONFile; -void* ED_createJSON(const char* fileName, int verbose) { +void* ED_createJSON(const char* fileName, int verbose) +{ JSONFile* json = (JSONFile*)malloc(sizeof(JSONFile)); if (json == NULL) { ModelicaError("Memory allocation error\n"); @@ -83,7 +84,8 @@ void* ED_createJSON(const char* fileName, int verbose) { return json; } -void ED_destroyJSON(void* _json) { +void ED_destroyJSON(void* _json) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json->fileName != NULL) { @@ -96,7 +98,8 @@ void ED_destroyJSON(void* _json) { } } -double ED_getDoubleFromJSON(void* _json, const char* varName, int* exist) { +double ED_getDoubleFromJSON(void* _json, const char* varName, int* exist) +{ double ret = 0.; JSONFile* json = (JSONFile*)_json; if (json != NULL) { @@ -136,7 +139,8 @@ double ED_getDoubleFromJSON(void* _json, const char* varName, int* exist) { return ret; } -const char* ED_getStringFromJSON(void* _json, const char* varName, int* exist) { +const char* ED_getStringFromJSON(void* _json, const char* varName, int* exist) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { *exist = 1; @@ -163,7 +167,8 @@ const char* ED_getStringFromJSON(void* _json, const char* varName, int* exist) { return ""; } -int ED_getIntFromJSON(void* _json, const char* varName, int* exist) { +int ED_getIntFromJSON(void* _json, const char* varName, int* exist) +{ long ret = 0; JSONFile* json = (JSONFile*)_json; if (json != NULL) { @@ -203,7 +208,8 @@ int ED_getIntFromJSON(void* _json, const char* varName, int* exist) { return (int)ret; } -int ED_getBooleanFromJSON(void* _json, const char* varName, int* exist) { +int ED_getBooleanFromJSON(void* _json, const char* varName, int* exist) +{ int ret = 0; JSONFile* json = (JSONFile*)_json; if (json != NULL) { @@ -241,8 +247,10 @@ int ED_getBooleanFromJSON(void* _json, const char* varName, int* exist) { return ret; } -void ED_getArray1DDimensionFromJSON(void* _json, const char* varName, int* n) { +void ED_getArray1DDimensionFromJSON(void* _json, const char* varName, int* n) +{ JSONFile* json = (JSONFile*)_json; + *n = 0; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { const JSON_Array* jsonArray = json_object_dotget_array(json->root, varName); @@ -255,8 +263,11 @@ void ED_getArray1DDimensionFromJSON(void* _json, const char* varName, int* n) { } } -void ED_getArray2DDimensionsFromJSON(void* _json, const char* varName, int* m, int* n) { +void ED_getArray2DDimensionsFromJSON(void* _json, const char* varName, int* m, int* n) +{ JSONFile* json = (JSONFile*)_json; + *m = 0; + *n = 0; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { const JSON_Array* jsonArray = json_object_dotget_array(json->root, varName); @@ -280,7 +291,8 @@ void ED_getArray2DDimensionsFromJSON(void* _json, const char* varName, int* m, i } } -void ED_getDoubleArray1DFromJSON(void* _json, const char* varName, double* a, size_t n) { +void ED_getDoubleArray1DFromJSON(void* _json, const char* varName, double* a, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -328,7 +340,8 @@ void ED_getDoubleArray1DFromJSON(void* _json, const char* varName, double* a, si } } -void ED_getStringArray1DFromJSON(void* _json, const char* varName, char** a, size_t n) { +void ED_getStringArray1DFromJSON(void* _json, const char* varName, char** a, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -361,7 +374,8 @@ void ED_getStringArray1DFromJSON(void* _json, const char* varName, char** a, siz } } -void ED_getIntArray1DFromJSON(void* _json, const char* varName, int* a, size_t n) { +void ED_getIntArray1DFromJSON(void* _json, const char* varName, int* a, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -413,7 +427,8 @@ void ED_getIntArray1DFromJSON(void* _json, const char* varName, int* a, size_t n } } -void ED_getBooleanArray1DFromJSON(void* _json, const char* varName, int* a, size_t n) { +void ED_getBooleanArray1DFromJSON(void* _json, const char* varName, int* a, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -459,7 +474,8 @@ void ED_getBooleanArray1DFromJSON(void* _json, const char* varName, int* a, size } } -void ED_getDoubleArray2DFromJSON(void* _json, const char* varName, double* a, size_t m, size_t n) { +void ED_getDoubleArray2DFromJSON(void* _json, const char* varName, double* a, size_t m, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -513,7 +529,8 @@ void ED_getDoubleArray2DFromJSON(void* _json, const char* varName, double* a, si } } -void ED_getStringArray2DFromJSON(void* _json, const char* varName, char** a, size_t m, size_t n) { +void ED_getStringArray2DFromJSON(void* _json, const char* varName, char** a, size_t m, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -549,7 +566,8 @@ void ED_getStringArray2DFromJSON(void* _json, const char* varName, char** a, siz } } -void ED_getIntArray2DFromJSON(void* _json, const char* varName, int* a, size_t m, size_t n) { +void ED_getIntArray2DFromJSON(void* _json, const char* varName, int* a, size_t m, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -607,7 +625,8 @@ void ED_getIntArray2DFromJSON(void* _json, const char* varName, int* a, size_t m } } -void ED_getBooleanArray2DFromJSON(void* _json, const char* varName, int* a, size_t m, size_t n) { +void ED_getBooleanArray2DFromJSON(void* _json, const char* varName, int* a, size_t m, size_t n) +{ JSONFile* json = (JSONFile*)_json; if (json != NULL) { if (json_object_dothas_value_of_type(json->root, varName, JSONArray)) { @@ -659,7 +678,8 @@ void ED_getBooleanArray2DFromJSON(void* _json, const char* varName, int* a, size } } -static JSON_Value_Type json_array_get_type(const JSON_Array *array) { +static JSON_Value_Type json_array_get_type(const JSON_Array *array) +{ JSON_Value_Type type = JSONNull; size_t i; size_t n = json_array_get_count(array); @@ -675,7 +695,8 @@ static JSON_Value_Type json_array_get_type(const JSON_Array *array) { return type; } -static JSON_Value_Type json_array_get_type2D(const JSON_Array *array) { +static JSON_Value_Type json_array_get_type2D(const JSON_Array *array) +{ JSON_Value_Type type = JSONNull; if (JSONArray == json_array_get_type(array)) { size_t i; @@ -693,7 +714,8 @@ static JSON_Value_Type json_array_get_type2D(const JSON_Array *array) { return type; } -static int json_array_check_dimensions2D(const JSON_Array *array) { +static int json_array_check_dimensions2D(const JSON_Array *array) +{ int n = 0; if (JSONArray == json_array_get_type(array)) { size_t i; diff --git a/ExternData/Resources/C-Sources/ED_XLSFile.c b/ExternData/Resources/C-Sources/ED_XLSFile.c index 43b636db..3ad7a58c 100644 --- a/ExternData/Resources/C-Sources/ED_XLSFile.c +++ b/ExternData/Resources/C-Sources/ED_XLSFile.c @@ -423,3 +423,18 @@ void ED_getDoubleArray2DFromXLS(void* _xls, const char* cellAddress, const char* } } } + +void ED_getArray2DDimensionsFromXLS(void* _xls, const char* sheetName, int* m, int* n) +{ + XLSFile* xls = (XLSFile*)_xls; + *m = 0; + *n = 0; + if (xls != NULL) { + char* _sheetName = (char*)sheetName; + const xlsWorkSheet* pWS = findSheet(xls, &_sheetName); + if (NULL != pWS) { + *m = pWS->rows.lastrow + 1; + *n = pWS->rows.lastcol; + } + } +} diff --git a/ExternData/Resources/C-Sources/ED_XLSXFile.c b/ExternData/Resources/C-Sources/ED_XLSXFile.c index 30380566..25d8d95e 100644 --- a/ExternData/Resources/C-Sources/ED_XLSXFile.c +++ b/ExternData/Resources/C-Sources/ED_XLSXFile.c @@ -375,7 +375,7 @@ static void findBlankCell(WORD row, WORD col, XmlNodeRef root, int* isBlank) const XmlNodeRef dim = XmlNode_findChild(root, "dimension"); *isBlank = 0; if (NULL != dim) { - const char* ref = XmlNode_getAttributeValue(dim, "ref"); + char* ref = XmlNode_getAttributeValue(dim, "ref"); if (NULL != ref) { char* colon = strchr(ref, ':'); if (NULL != colon) { @@ -398,7 +398,7 @@ double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sh XLSXFile* xlsx = (XLSXFile*)_xlsx; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; - XmlNodeRef root = findSheet(xlsx, &_sheetName); + const XmlNodeRef root = findSheet(xlsx, &_sheetName); if (root != NULL) { char* token = findCellValue(xlsx, cellAddress, root, _sheetName); *exist = 1; @@ -439,7 +439,7 @@ const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const cha XLSXFile* xlsx = (XLSXFile*)_xlsx; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; - XmlNodeRef root = findSheet(xlsx, &_sheetName); + const XmlNodeRef root = findSheet(xlsx, &_sheetName); if (root != NULL) { char* token = findCellValue(xlsx, cellAddress, root, _sheetName); *exist = 1; @@ -478,7 +478,7 @@ int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetNam XLSXFile* xlsx = (XLSXFile*)_xlsx; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; - XmlNodeRef root = findSheet(xlsx, &_sheetName); + const XmlNodeRef root = findSheet(xlsx, &_sheetName); if (root != NULL) { char* token = findCellValue(xlsx, cellAddress, root, _sheetName); *exist = 1; @@ -517,7 +517,7 @@ void ED_getDoubleArray2DFromXLSX(void* _xlsx, const char* cellAddress, const cha XLSXFile* xlsx = (XLSXFile*)_xlsx; if (xlsx != NULL) { char* _sheetName = (char*)sheetName; - XmlNodeRef root = findSheet(xlsx, &_sheetName); + const XmlNodeRef root = findSheet(xlsx, &_sheetName); if (root != NULL) { WORD row = 0, col = 0; WORD i, j; @@ -555,3 +555,29 @@ void ED_getDoubleArray2DFromXLSX(void* _xlsx, const char* cellAddress, const cha } } } + +void ED_getArray2DDimensionsFromXLSX(void* _xlsx, const char* sheetName, int* m, int* n) +{ + XLSXFile* xlsx = (XLSXFile*)_xlsx; + *m = 0; + *n = 0; + if (xlsx != NULL) { + char* _sheetName = (char*)sheetName; + const XmlNodeRef root = findSheet(xlsx, &_sheetName); + if (root != NULL) { + const XmlNodeRef dim = XmlNode_findChild(root, "dimension"); + if (NULL != dim) { + char* ref = XmlNode_getAttributeValue(dim, "ref"); + if (NULL != ref) { + char* colon = strchr(ref, ':'); + if (NULL != colon) { + WORD row = 0, col = 0; + rc(++colon, &row, &col); + *m = (int)row; + *n = (int)col; + } + } + } + } + } +} diff --git a/ExternData/Resources/Include/ED_XLSFile.h b/ExternData/Resources/Include/ED_XLSFile.h index df5e416c..251a35ca 100644 --- a/ExternData/Resources/Include/ED_XLSFile.h +++ b/ExternData/Resources/Include/ED_XLSFile.h @@ -35,5 +35,6 @@ double ED_getDoubleFromXLS(void* _xls, const char* cellAddress, const char* shee const char* ED_getStringFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist); int ED_getIntFromXLS(void* _xls, const char* cellAddress, const char* sheetName, int* exist); void ED_getDoubleArray2DFromXLS(void* _xls, const char* cellAddress, const char* sheetName, double* a, size_t m, size_t n); +void ED_getArray2DDimensionsFromXLS(void* _xls, const char* sheetName, int* m, int* n); #endif diff --git a/ExternData/Resources/Include/ED_XLSXFile.h b/ExternData/Resources/Include/ED_XLSXFile.h index 46aa9ae3..1915be73 100644 --- a/ExternData/Resources/Include/ED_XLSXFile.h +++ b/ExternData/Resources/Include/ED_XLSXFile.h @@ -35,5 +35,6 @@ double ED_getDoubleFromXLSX(void* _xlsx, const char* cellAddress, const char* sh const char* ED_getStringFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist); int ED_getIntFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, int* exist); void ED_getDoubleArray2DFromXLSX(void* _xlsx, const char* cellAddress, const char* sheetName, double* a, size_t m, size_t n); +void ED_getArray2DDimensionsFromXLSX(void* _xlsx, const char* sheetName, int* m, int* n); #endif diff --git a/ExternData/package.mo b/ExternData/package.mo index 187c2f4e..96053d82 100644 --- a/ExternData/package.mo +++ b/ExternData/package.mo @@ -112,6 +112,8 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc final function getStringArray2D = Functions.JSON.getStringArray2D(final json=json) "Get 2D array String value from JSON file" annotation(Documentation(info="")); final function getArraySize1D = Functions.JSON.getArraySize1D(final json=json) "Get the size of a 1D array in a JSON file" annotation(Documentation(info="")); final function getArraySize2D = Functions.JSON.getArraySize2D(final json=json) "Get the size of a 2D array in a JSON file" annotation(Documentation(info="")); + final function getArrayRows2D = Functions.JSON.getArrayRows2D(final json=json) "Get first dimension of 2D array in JSON file" annotation(Documentation(info="")); + final function getArrayColumns2D = Functions.JSON.getArrayColumns2D(final json=json) "Get second dimension of 2D array in JSON file" annotation(Documentation(info="")); annotation( Documentation(info="

Record that wraps the external object ExternJSONFile and the JSON read functions for data access of JSON files.

See Examples.JSONTest for an example.

"), defaultComponentName="jsonfile", @@ -164,6 +166,9 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc final function getInteger = Functions.XLS.getInteger(final xls=xls) "Get scalar Integer value from Excel XLS file" annotation(Documentation(info="")); final function getBoolean = Functions.XLS.getBoolean(final xls=xls) "Get scalar Boolean value from Excel XLS file" annotation(Documentation(info="")); final function getString = Functions.XLS.getString(final xls=xls) "Get scalar String value from Excel XLS file" annotation(Documentation(info="")); + final function getArraySize2D = Functions.XLS.getArraySize2D(final xls=xls) "Get the size of a 2D array in a Excel XLS file" annotation(Documentation(info="")); + final function getArrayRows2D = Functions.XLS.getArrayRows2D(final xls=xls) "Get first dimension of 2D array in Excel XLS file" annotation(Documentation(info="")); + final function getArrayColumns2D = Functions.XLS.getArrayColumns2D(final xls=xls) "Get second dimension of 2D array in Excel XLS file" annotation(Documentation(info="")); annotation( Documentation(info="

Record that wraps the external object ExternXLSFile and the XLS read functions for data access of Excel XLS files.

See Examples.XLSTest for an example.

"), defaultComponentName="xlsfile", @@ -202,6 +207,9 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc final function getInteger = Functions.XLSX.getInteger(final xlsx=xlsx) "Get scalar Integer value from Excel XLSX file" annotation(Documentation(info="")); final function getBoolean = Functions.XLSX.getBoolean(final xlsx=xlsx) "Get scalar Boolean value from Excel XLSX file" annotation(Documentation(info="")); final function getString = Functions.XLSX.getString(final xlsx=xlsx) "Get scalar String value from Excel XLSX file" annotation(Documentation(info="")); + final function getArraySize2D = Functions.XLSX.getArraySize2D(final xlsx=xlsx) "Get the size of a 2D array in a Excel XLSX file" annotation(Documentation(info="")); + final function getArrayRows2D = Functions.XLSX.getArrayRows2D(final xlsx=xlsx) "Get first dimension of 2D array in Excel XLSX file" annotation(Documentation(info="")); + final function getArrayColumns2D = Functions.XLSX.getArrayColumns2D(final xlsx=xlsx) "Get second dimension of 2D array in Excel XLSX file" annotation(Documentation(info="")); annotation( Documentation(info="

Record that wraps the external object ExternXLSXFile and the XLSX read functions for data access of Excel XLSX files.

See Examples.XLSXTest for an example.

"), defaultComponentName="xlsxfile", @@ -544,7 +552,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc input Types.ExternJSONFile json "External JSON file object"; output Integer m "Number of rows in array"; protected - Integer n "Number of columns in array"; + Integer n[1] "Number of columns in array"; external "C" ED_getArray2DDimensionsFromJSON(json, varName, m, n) annotation( __iti_dll = "ITI_ED_JSONFile.dll", __iti_dllNoExport = true, @@ -558,7 +566,7 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc input Types.ExternJSONFile json "External JSON file object"; output Integer n "Number of columns in array"; protected - Integer m "Number of rows in array"; + Integer m[1] "Number of rows in array"; external "C" ED_getArray2DDimensionsFromJSON(json, varName, m, n) annotation( __iti_dll = "ITI_ED_JSONFile.dll", __iti_dllNoExport = true, @@ -672,6 +680,47 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc Include = "#include \"ED_XLSFile.h\"", Library = "ED_XLSFile"); end getString; + + function getArraySize2D "Get dimensions of 2D array in Excel XLS file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSFile xls "External Excel XLS file object"; + output Integer m "Number of rows in array"; + output Integer n "Number of columns in array"; + external "C" ED_getArray2DDimensionsFromXLS(xls, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSFile.h\"", + Library = "ED_XLSFile"); + end getArraySize2D; + + function getArrayRows2D "Get first dimension of 2D array in Excel XLS file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSFile xls "External Excel XLS file object"; + output Integer m "Number of rows in array"; + protected + Integer n[1] "Number of columns in array"; + external "C" ED_getArray2DDimensionsFromXLS(xls, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSFile.h\"", + Library = "ED_XLSFile"); + end getArrayRows2D; + + function getArrayColumns2D "Get second dimension of 2D array in Excel XLS file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSFile xls "External Excel XLS file object"; + output Integer n "Number of columns in array"; + protected + Integer m[1] "Number of rows in array"; + external "C" ED_getArray2DDimensionsFromXLS(xls, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSFile.h\"", + Library = "ED_XLSFile"); + end getArrayColumns2D; annotation(Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={Text(lineColor={128,128,128},extent={{-90,-90},{90,90}},textString="f")})); end XLS; @@ -748,6 +797,47 @@ package ExternData "Library for data I/O of CSV, INI, JSON, MATLAB MAT, TIR, Exc Include = "#include \"ED_XLSXFile.h\"", Library = {"ED_XLSXFile", "bsxml-json", "expat", "zlib"}); end getString; + + function getArraySize2D "Get dimensions of 2D array in Excel XLSX file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; + output Integer m "Number of rows in array"; + output Integer n "Number of columns in array"; + external "C" ED_getArray2DDimensionsFromXLSX(xlsx, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSXFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSXFile.h\"", + Library = {"ED_XLSXFile", "bsxml-json", "expat", "zlib"}); + end getArraySize2D; + + function getArrayRows2D "Get first dimension of 2D array in Excel XLSX file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; + output Integer m "Number of rows in array"; + protected + Integer n[1] "Number of columns in array"; + external "C" ED_getArray2DDimensionsFromXLSX(xlsx, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSXFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSXFile.h\"", + Library = {"ED_XLSXFile", "bsxml-json", "expat", "zlib"}); + end getArrayRows2D; + + function getArrayColumns2D "Get second dimension of 2D array in Excel XLSX file" + extends Modelica.Icons.Function; + input String sheetName="" "Sheet name"; + input Types.ExternXLSXFile xlsx "External Excel XLSX file object"; + output Integer n "Number of columns in array"; + protected + Integer m[1] "Number of rows in array"; + external "C" ED_getArray2DDimensionsFromXLSX(xlsx, sheetName, m, n) annotation( + __iti_dll = "ITI_ED_XLSXFile.dll", + __iti_dllNoExport = true, + Include = "#include \"ED_XLSXFile.h\"", + Library = {"ED_XLSXFile", "bsxml-json", "expat", "zlib"}); + end getArrayColumns2D; annotation(Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={Text(lineColor={128,128,128},extent={{-90,-90},{90,90}},textString="f")})); end XLSX;