// Convert Excel parameters to the SpreadsheetControl's parameters. ParameterValue ConvertResultValue(dynamic value) { ParameterValue result; Array objArrayRes = value as Array; if (objArrayRes != null) { int height = objArrayRes.GetLength(0); int lowerY = objArrayRes.GetLowerBound(0); int width = objArrayRes.GetLength(1); int lowerX = objArrayRes.GetLowerBound(1); DevExpress.Spreadsheet.CellValue[,] arrayResult = new DevExpress.Spreadsheet.CellValue[height, width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { arrayResult[i, j] = ConvertResultValueCore(objArrayRes.GetValue(i + lowerY, j + lowerX)); } } result = arrayResult; } else { result = ConvertResultValueCore(value); } return(result); }
object[,] ConvertRefParameter(DevExpress.Spreadsheet.CellRange parameter) { int height = parameter.RowCount; int width = parameter.ColumnCount; object[,] result = (object[, ])Array.CreateInstance(typeof(object), new[] { height, width }, new[] { 1, 1 }); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { DevExpress.Spreadsheet.CellValue value = parameter[i, j].Value; result[i + 1, j + 1] = ConvertParameter(value); } } return(result); }
object[,] ConvertArrayParameter(DevExpress.Spreadsheet.CellValue[,] parameter) { int height = parameter.GetLength(0); int width = parameter.GetLength(1); object[,] result = (object[, ])Array.CreateInstance(typeof(object), new[] { height, width }, new[] { 1, 1 }); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { DevExpress.Spreadsheet.CellValue value = parameter[i, j]; if (value.IsEmpty) { result[i + 1, j + 1] = null; } else { result[i + 1, j + 1] = value; } } } return(result); }