#pragma rtGlobals=1 // Use modern global access method. // Fuction to read the raw data from Excel Sheets and concatenate all // columns in the same worksheet into a 2D wave (matrix) // It reads the wave names from the first row and uses them as dimension labels Function ExcelTo2DWave() // select the excel file do getfilefolderinfo/Q if (V_Flag<0) return -1 //User cacelled elseif (V_isFolder==1) //User selectes folder instead of file DoAlert/T="Message" 0, "Please choose a file not a folder" elseif (V_Flag==0 && V_isFile==1) // make sure a file is selected if (stringmatch(S_Path, "*.xls*")) // make sure it is an Excel file String filePath = S_Path // full file path else V_isFile = 0 DoAlert/T="Message" 0, "The selected file is not an Excel file. Please select an Excel file." endif endif while (V_isFile !=1) XLLoadWave/Q/J=1 filePath //use XLLoadWave/J=1 to get info (the worksheets) in the Excel file String wkShList = S_value // a : sepearted list of sheets in the Excel file // each excel file loads its worksheets in a seperate data folder // this is useful when loading multiple excel files that may contain repeated worksheet names // comment out the lines with dataFolder if not needed String savedDataFolder = GetDataFolder(1) String fileName = ParseFilePath(0,filePath,":",1,0) // get file name from full file path String extension = "." + ParseFilePath(4, fileName, ":", 0, 0) // e.g., ".xls" String dfName = RemoveEnding(fileName, extension) NewDataFolder/O/S :$dfName // loop for each worksheet in the excel file to load all columns in to a 2D wave Variable i, numWkSh i=0 numWkSh = ItemsInList(wkShList) // the number of worksheets String wkShLoad do wkShLoad =StringFromList(i,wkShList) //pick a worksheet to load wave from LoadTo2Dwave(filePath, wkShLoad) //pass the full file path and worksheet name to load waves i += 1 while (i