public static object GetFiles( [ExcelArgument(Description = "指定目录")] string strFolder, [ExcelArgument(Description = @"正则指定搜索条件,0为搜索xlsx文件,\S\.xlsx$ 表示")] string strRegesText, [ExcelArgument(Description = "是否搜索子文件夹,1搜索,0不搜索。默认不搜索")] bool blIsSearchSubfolder, [ExcelArgument(Description = "返回的结果是按【行】排列,true按行,false按列,默认按列")] bool blIsHorizontal) { string[] files; files = FileClass.GetAllFiles(strFolder, strRegesText, blIsSearchSubfolder); //if (Common.IsMissOrEmpty(containsText)) //{ // containsText = string.Empty; //} ////当isSearchAllDirectory为空或false,默认为只搜索顶层文件夹 //if (Common.IsMissOrEmpty(isSearchAllDirectory) || Common.TransBoolPara(isSearchAllDirectory) == false) //{ // files = Directory.EnumerateFiles(srcFolder).Where(s => isContainsText(s, containsText)).ToArray(); //} //else //{ // files = Directory.EnumerateFiles(srcFolder, "*", SearchOption.AllDirectories).Where(s => isContainsText(s, containsText)).ToArray(); //} ArrayResizer arrayResizer = new ArrayResizer(); //return arrayResizer.Resize(Common.ReturnDataArray(files, optAlignHorL)); return(arrayResizer.Resize(files, blIsHorizontal)); }
public static double[,] MakeArrayAndResizeDoubles(int rows, int columns) { double[,] result = MakeArrayDoubles(rows, columns); ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(result)); }
public static object GetSubFolders( [ExcelArgument(Description = "传入的顶层目录,最终返回的结果将是此目录下的文件夹或子文件夹")] string FileDirectory, [ExcelArgument(Description = "查找的文件夹中是否需要包含指定字符串,不传参数默认为返回所有文件夹,可传入复杂的正则表达式匹配。")] string optContainsText, [ExcelArgument(Description = "是否查找所有子文件夹,TRUE搜索子文件夹,fasle为否,默认为否")] bool optIsSearchAllDirectory = false, [ExcelArgument(Description = "返回的结果是按列排列还是按行排列,true按行,false按列,默认按列")] bool isHorizontal = false) { string[] subfolders; subfolders = FileClass.GetAllFolders(FileDirectory, optContainsText, optIsSearchAllDirectory); //if (Common.IsMissOrEmpty(optContainsText)) //{ // optContainsText = string.Empty; //} ////当isSearchAllDirectory为空或false,默认为只搜索顶层文件夹 //if (optIsSearchAllDirectory== false) //{ // subfolders = Directory.EnumerateDirectories(FileDirectory).Where(s => isContainsText(s, optContainsText)).ToArray(); //} //else //{ // subfolders = Directory.EnumerateDirectories(FileDirectory, "*", SearchOption.AllDirectories).Where(s => isContainsText(s, optContainsText)).ToArray(); //} ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(subfolders, isHorizontal)); }
// Makes an array, but automatically resizes the result public static object MakeArrayAndResize(int rows, int columns, string unused, string unusedtoo) { object[,] result = MakeArray(rows, columns); ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(result)); // Can also call Resize via Excel - so if the Resize add-in is not part of this code, it should still work // (though calling direct is better for large arrays - it prevents extra marshaling). // return XlCall.Excel(XlCall.xlUDF, "Resize", result); }
public static object VLOOKUPMERGE(double[,] s1, double[,] s2, double[,] s3) { int rows2 = s2.GetLength(0); int columns2 = s2.GetLength(1); int rows3 = s3.GetLength(0); int columns3 = s3.GetLength(1); if (rows2 != rows3 || columns2 != columns3) { return(ExcelError.ExcelErrorValue); } if (rows2 > 1 && columns2 > 1) { return(ExcelError.ExcelErrorValue); } Dictionary <string, string> dic = new Dictionary <string, string>(); if (rows2 > 1 && columns2 == 1) { for (int i = 0; i < rows2; i++) { string srid = s2[i, 0].ToString(); string srv = s3[i, 0].ToString(); if (dic.ContainsKey(srid)) { dic[srid] = dic[srid] + "," + srv; } else { dic.Add(srid, srv); } } } int rows = s1.GetLength(0); int columns = s1.GetLength(1); object[] ResultObject = new object[rows]; for (int i = 0; i < rows; i++) { ResultObject[i] = dic[s1[i, 0].ToString()]; } ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(ResultObject)); }
public static double[,] sumtest(double[,] s1, double[,] s2) { int rows = s1.GetLength(0); int columns = s1.GetLength(1); double[] s = new double[rows]; for (int i = 0; i < rows; i++) { s[i] = s1[i, 0] + s2[i, 0]; } ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(s)); }
public static object MakeMixedArrayAndResize(int rows, int columns) { object[,] result = new object[rows, columns]; for (int j = 0; j < columns; j++) { result[0, j] = "Col " + j; } for (int i = 1; i < rows; i++) { for (int j = 0; j < columns; j++) { result[i, j] = i + (j * 0.1); } } ArrayResizer arrayResizer = new ArrayResizer(); return(arrayResizer.Resize(result)); }