Sending Email in Excel Format

Hello,
I am trying to send an email with the below attachment in .xls file format by default its opening everything in a single column in the email. How to display the column in a separate column in excel instead everything together.

2017/01/01 a 10
2017/01/01 b 20
2017/01/01 c 40
2017/01/01 a 60
2017/01/01 b 50
2017/01/01 c 40

I suspect you're not doing what you think you are. Show your code please.

That's not an e-mail issue but more like EXCEL. Open the file with the "text agent" or "text wizard" and select space as the column separator.

$ cat test
2017/01/01 a 10
2017/01/01 b 20
2017/01/01 c 40
2017/01/01 a 60
2017/01/01 b 50
2017/01/01 c 40
$echo | mailx  -s "Test Email" -a test xyz@xyz.com

That is not XLS, nor CSV, it's not even TXT as Windows understands it.

Try changing spaces to commas, adding carriage returns, and renaming it 'test.csv' so it will actually open in excel.

awk -v OFS="," '{ $1=$1 ; print $0 "\r" }' test > test.csv
mailx -s "Test Email" -a test.csv xyz@xyz.com

I am getting blank line after each line. How to get rid of that one?

---------- Post updated at 05:22 PM ---------- Previous update was at 04:58 PM ----------

It worked fine after removing the carriage return.

Your input file must have had carriage returns in the first place. Oh well.

1 Like