Reputation: 65
I am working on a Windows Form application, and needs to export sql data to excel and to display multiple lines in one cell vertically. The sql query retrieves a series of comma separated status code, like "initiated, submitted, approved, completed", etc. When data is exported to excel file, the client would like it to be displayed vertically in a single cell, see screenshot above. Any help and suggestions would be appreciated very much!
Upvotes: 0
Views: 1839
Reputation: 4882
For Excel representation, you will have to convert your Status
column result into Excel formula, and use CHAR(10)
which is a new line character for excel. So your result will look like this:
="Initiated" & CHAR( 10 ) & "Submitted"`
Remember, in excel for a new line to be displayed in cell, the Wrap Text
option must be enabled.
Modify SQL query to concontenate result like below:
CaseID Status
1001 ="Initiated" & CHAR( 10 ) & "Submitted"
1002 ="Approved" & CHAR( 10 ) & "Completed"
Upvotes: 1