Login  Register

Append new results to excel file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Append new results to excel file

Adam Hacking
28 posts
Hi,
I'm looking for an example macro to update an excel file (append row after row) to a worksheet as results are generated. I can't find any exmaples on the ImageJ site.
Many thanks
Adam



     
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Append new results to excel file

Wayne Rasband
1011 posts
On Jun 7, 2009, at 12:30 PM, Adam Hacking wrote:

> Hi,
> I'm looking for an example macro to update an excel file (append row
> after row) to a worksheet as results are generated. I can't find any
> exmaples on the ImageJ site.
> Many thanks

You can append a row to a spreadsheet-compatible, tab-delimited text
file using the File.append() macro function. Here is an example that
adds 10 rows, each containing 5 numbers, to an existing text file:

  for (i=0; i<10; i++) {
      row = "";
      for (j=0; j<5; j++)
          row = row + d2s(random,2) + "\t";
      File.append(row, getDirectory("home")+"results.xls");
      wait(5000);
  }

The file is created if it does not already exist.

-wayne