I’m sure this hasn’t been asked before as this seems like a strange question perhaps.
I have a program which essentially prints out some important data to the console. I then want to simply copy this data and paste it into excel. When I copy and paste it, it appears on new rows on the document, I need this to be in new columns. For example instead of:
Data1
Data2
Data3
I need
Data1 | Data 2 | Data3
Currently I am printing these to the console using:
System.out.println(“Data1”);
However, I can use print instead of println, but I guess there must be some character which is required to seperate these. I tried \r but this didn’t seem to work.
Strangely, I also cannot simply paste transposed. In order to get the “transposed” option in excel, I need to paste the cells, and then copy them to the clipboard again and paste. I suppose if there was a way to see what is on the clipboard when you copy a set of cells next to each other I would know what I need to output to have the same results.
I don’t even need to use System.out.print, I am happy to copy these directly to the clipboard using java if this makes the solution easier.
The issue is that this task is going to be so many times, it makes sense to not have to copy/paste into excel, then copy it again and paste as transposed.
Thanks,
\rshould be a carriage return, so I suppose that’s why it doesn’t work with that. Have you tried\tfor a tab?Or
System.out.println("Data1,Data2,Data3")to get comma-delimited, if you can be sure that there are no commas in your data?