Hi @jchen ,
I’m glad it’s working for you and that I could help.
There are several ways to achieve, something at least close to, what you ask. However, this does go slightly beyond the design scope of this plugin or ImageJ, since neither claims to be a spreadsheet manager.
Despite the above disclaimer, one approach is to open the file as a results table in ImageJ. If the file is .xlsx then you may need to resave it as .csv. Once the data is loaded into an ImageJ table you can do whatever you like to it before exporting it back (replacing the old file or creating a new one). This option does not require the ‘Read and Write Excel’ plugin to open and manipulate the data (including adding ‘variables to the end’). You can optionally include the plugin to save the data to .xlsx format, even appending/updating the same output file, or just use the .csv save function of ImageJ if you don’t need to update the same file every time (there are ways to update the same file using the .csv save function as well which you can maybe work out by appreciating this answer altogether).
The above approach is not compatible with original files made up of multiple sheets or tabs.
Another approach depends somewhat on the regularity of layout of your files to be edited and upon whether you need to use the contents of the edited files to populate the new cells. The RaWE plugin has a little advertised function that allows an ImageJ results table to be inserted to a user specified location:
run("Read and Write Excel", "file=[C:/Users/antinos/Desktop/My_file.xlsx] sheet=banana cell_ref=[U69]");
So, you could create a custom table in ImageJ that contains only the value you wish to add to the end of your spreadsheet. So long as this table is named ‘Results’, then the plugin will export it to the specified file, sheet, and cell location. Of course, as I intimated at, this approach only really makes sense when applied iteratively if the files to be edited are of a known and repetitive layout (such that you know which cell references to feed to the plugin with a macro).
There are some good reasons to avoid using the ‘cell_ref=’ approach, including the fact that the plugin does not care what may already exist at the specified location when this function is called. Normally the plugin tries to append files without overwriting pre-existing data.
Another more mundane way to interpret your question(s) is ‘can I add a variable to the end of each of my data exports?’. I didn’t think this is what you meant, but the answer is yes. This is the most straightforward and conventional approach. The value/variable would simply be added to the end of the Results table prior to export.
Another easy answer to a fourth interpretation, is to use the ‘file=’ (maybe in conjunction with the ‘sheet=’) argument to specify each file you wish to update. This approach works best when you have separate files or data-sheets within the same file containing each set of data.
Writing all these out now, I realise that I don’t know enough about your actual request to suggest whether a reasonable solution is possible. If I haven’t already answered you, if you would like to give the exact requirement, with an example analysis pipeline, then I can try to make some time this weekend to look over your query.