Help to modify in Excel format

Hi

I ran some query in solaris machine and the result of the query is as below.

Result:

dn: uid=xxx,dc=example,dc=com
id: xxx
firstname: sam
lastname: nam

But my question is , how to get result in excel format in solaris and result attributes dn,id,firstname,lastname values should be in separate column in excel and not in separate rows.

Outputting it as CSV text like col1,col2,col3 should allow excel to import it natively. It can even handle tab-separated.

Show the output you want please.