Ejemplo n.º 1
0
        public static object[,] fUtilityDataTableSortAndGet(string handle, object[] headers, object SortAscending, object noHeadersInput)
        {
            var table  = PersistentObjects.GetFromMap <DataTable>(handle, "DATATABLE");
            var output = ExcelFriendlyConversion.ConvertDataTableToObjectArray(table);

            return(fUtilityTableSortByHeader(output, headers, SortAscending, noHeadersInput));
        }
Ejemplo n.º 2
0
        public static object[,] fUtilityGetDataTable(string handle, object noHeadersInput)
        {
            bool noHeaders = Optional.Check(noHeadersInput, false);

            if (ExcelDnaUtil.IsInFunctionWizard())
            {
                return(new object[0, 0]);
            }
            else
            {
                var output = PersistentObjects.GetFromMap <DataTable>(handle, "DATATABLE");
                return(ExcelFriendlyConversion.ConvertDataTableToObjectArray(output, noHeaders));
            }
        }
Ejemplo n.º 3
0
        public static object[,] fUtilityTableSortByHeader(object[,] table, object[] headers, object SortAscending, object noHeadersInput)
        {
            bool ascending = Optional.Check(SortAscending, true);
            bool noHeaders = Optional.Check(noHeadersInput, false);

            var dataTable = ExcelFriendlyConversion.ConvertObjectArrayToDataTable("TEMPTABLE", table);
            var header    = "";

            for (int i = 0; i < headers.Length - 1; i++)
            {
                header = headers[i].ToString() + ", " + header;
            }

            header = header + headers[headers.Length - 1];

            var direction = (ascending) ? "ASC" : "DESC";

            dataTable.DefaultView.Sort = header + " " + direction;

            return(ExcelFriendlyConversion.ConvertDataTableToObjectArray(dataTable.DefaultView.ToTable()));
        }
Ejemplo n.º 4
0
        public static object[,] fUtilityQueryDataTable(string sqlStringOrHandle, object noHeadersInput)
        {
            string sql = ObjectInfo.DetermineIfSqlHandleOrSqlQuery(sqlStringOrHandle);

            object[,] output;
            bool noHeaders   = Optional.Check(noHeadersInput, false);
            var  tableHandle = ParsingFunctionality.GetTableNameFromSqlQuery(sql);

            if (PersistentObjects.ContainsKey(tableHandle, "DATATABLE") == false)
            {
                string errorMessage = "ERROR: DataTable + " + tableHandle + " does not exist in the object map.";
                output       = new object[1, 1];
                output[0, 0] = errorMessage;
                return(output);
            }
            else
            {
                var newTable = QueryCSV.QueryDataTable(sql, PersistentObjects.CsvPath);
                output = ExcelFriendlyConversion.ConvertDataTableToObjectArray(newTable, noHeaders);
                return(output);
            }
        }