/* Save Results as temporary file so that it can be opened in Excel or program associated with XLS files v190116 first version. v211109 sets default ASC IO prefs. v230803: Replaced getDir for 1.54g10. */ macroL = "Open_Results_In_Excel_v230803.ijm"; if (nResults==0) exit("Sorry, the Results table is empty"); os = getInfo("os.name"); if (startsWith(os, "Linux")) exit("Sorry, I don't know the Linux commands for this"); if (!checkForPluginNameContains("Read_and_Write_Excel")) exit("Read_and_Write_Excel plugin not found"); sWidth = screenWidth(); t = getTitle(); extN = lastIndexOf(t,"."); if(extN>0) fileName = substring(t,0,extN); else fileName = t; saveDir = getDirectory("image"); if (saveDir=="") saveDir = File.directory; if (saveDir=="") saveDir = getInfo("image.directory"); if (saveDir=="") saveDir = getDirectory("home"); Dialog.create("File save options: " + macroL); Dialog.addDirectory("Select directory:", saveDir); Dialog.addString("Filename \(prefix\):",fileName,minOf(sWidth-50,maxOf(lengthOf(fileName)+10,lengthOf(saveDir)))); Dialog.addRadioButtonGroup("Output file type:",newArray("xlsx","csv","both"),1,3,"csv"); Dialog.show(); saveDir = Dialog.getString; fileName = Dialog.getString; output = Dialog.getRadioButton(); resultsPath = saveDir + fileName; if (output=="xlsx" || output=="both"){ if (!File.exists(resultsPath+".xlsx")) run("Read and Write Excel", "file=["+resultsPath+".xlsx]"); else { overWriteFile=getBoolean("Do you want to overwrite " + resultsPath + ".xlsx?"); if(overWriteFile) run("Read and Write Excel", "file=["+resultsPath+"xlsx]"); } } if (output=="csv" || output=="both"){ saveSettings(); run("Input/Output...", "jpeg=85 gif=-1 file=.csv copy_column copy_row save_column save_row"); /* Default ASC IO, edit to your preference */ if (!File.exists(resultsPath+".csv")) saveAs("Results", resultsPath+".csv"); else { overWriteFile=getBoolean("Do you want to overwrite " + resultsPath + ".csv?"); if(overWriteFile) saveAs("Results", resultsPath+".csv"); } } wait(100); if (output=="csv") resultsPath += ".csv"; else resultsPath += ".xlsx"; if (startsWith(os, "Win")) exec("cmd", "/c", "start", resultsPath); else exec("open", resultsPath); /* ( 8(|) ( 8(|) All ASC Functions @@@@@:-) @@@@@:-) */ function checkForPluginNameContains(pluginNamePart) { /* v180831 1st version to check for partial names so avoid versioning problems ... v220722 Uses File.separator and adds .class v230912 This version is case insensitive and does NOT require restoreExit. NOTE: underlines are NOT converted to spaces in names */ pluginCheck = false; pluginNamePart = toLowerCase(pluginNamePart); fS = File.separator; pluginDir = getDirectory("plugins"); if (pluginDir == "") IJ.log("Failure to find any plugins!"); else { pluginFolderList = getFileList(pluginDir); subFolderList = newArray(); pluginList = newArray(); for (l=0; l=0) pluginCheck = true; } /* If not in the root try the subfolders */ if (!pluginCheck) { for (i=0; i=0) pluginCheck = true; } } } } return pluginCheck; }