Removing carriage returns in report studio - cognos

I need to be able to remove carriage returns from a free text field in Report Studio so when its exported to CSV, its all on one line. I DO NOT have access to native SQL, this is locked out, I can only do this through report studio. I have tried replace combined with Char(13) + Char(10) and it just errors. Has anyone managed to do this with a data item, or text item?
Thanks in advance!

Related

office 365 excel csv hyperlink not displaying correctly when imported to excel [duplicate]

Can Excel interpret the URLs in my CSV as hyperlinks? If so, how?
You can actually do this and have Excel show a clickable link. Use this format in the CSV file:
=HYPERLINK("URL")
So the CSV would look like:
1,23.4,=HYPERLINK("http://www.google.com")
However, I'm trying to get some links with commas in them to work properly and it doesn't look like there's a way to escape them and still have Excel make the link clickable.
Does anyone know how?
With embedding the hyperlink function you need to watch the quotes. Below is an example of a CSV file created that lists an error and a link to view the documentation on the method that failed. (Bit esoteric but that's what I am working on)
"Details","Failing Method (click to view)"
"Method failed","=HYPERLINK(""http://some_url_with_documentation"",""Method_name"")"
I read all of these answers and some others but it still took a while to work it out in Excel 2014.
The result in the csv should look like this
"=HYPERLINK(""http://www.Google.com"",""Google"")"
Note: If you are trying to set this from MSSQL server then
'"=HYPERLINK(""http://www.' + baseurl + '.com"",""' + baseurl + '"")"' AS url
you can URL Encode your commas inside the URL so the URL is not split across multiple cells.
Just replace commas with %2c
http://www.xyz.com/file,comma.pdf
becomes
=hyperlink("http://www.xyz.com/file%2ccomma.pdf")
Yes, but it's not possible to link them automatically. CSV files are just text files - whatever opens and reads them is responsible for allowing you to click the link.
As to how Excel seems to handle CSV files - everything between commas is interpreted as if it already had been typed into the cell. Therefore, the CSV file containing ="http://google.com",=A1 will display as http://google.com,http://google.com in Excel. It's important to note, however, that hyperlinks in Excel are metadata, and not the result of anything in the actual cell (ie, a hyperlinked cell to Google still contains http://google.com not <a>http://google.com</a> or anything of that sort.)
Since that's the case, and all metadata is lost when converting to a CSV, it's impossible to tell Excel you wish for something to be hyperlinked merely by changing the cell value. Normally, Excel interprets your input when you hit 'Enter' and links URLs then, but since CSV data is not being entered, but rather already exists, this does not happen.
Your best bet is to write some sort of addon or macro to run when you open up a CSV which parses every cell and hyperlinks them if they match a URL format.
Use this format:
=HYPERLINK(""<URL>"";""<LABEL>"")
e.g.:
=HYPERLINK(""http://stackoverflow.com"";""I love stackoverflow!"")
P.S. The same format works in LibreOffice Calc as well.
"=HYPERLINK(\"\" " + "http://www.mywebsite.com"+ "\"\")"
use this format before writing to CSV.
As described above, "=HYPERLINK(""http://www.google.com"", ""Google"")" is what worked for me.
However, In Excel Version 2204 Click to Run, I couldn't have leading white space.
For example;
FirstName, "=HYPERLINK(""http://www.google.com"", ""Google"")" fails
FirstName,"=HYPERLINK(""http://www.google.com"", ""Google"")" success
The issue here for me was that because a .CSV by it's nature is Comma separated, any commas in the text file are interpreted as separators. It worked for me by using tab characters as separators, saving it as a .TXT file so that when opened in EXCEL you choose the TAB character rather than ','.
In the text file …
## ensure that the file is TAB separated
Item 1 A file Name data.txt
Item 2 Col 2 =HYPERLINK("http:\www.ilexuk.com","ILEX")
"ILEX" then is shown in the cell and "http:\www.ilexuk.com" is the hyperlink for the cell.

ssrs report export to excel - broken hyperlinks

I have large report and each row contains hyperlink.
Report containing 50k or more rows is exported to excel.
After export I try to open xlsx file and get message telling me that file contains error. It also suggests to do file recovery
After recovery message shows that hyperlinks were removed. I can open file but links are no longer working.
I tried to open exported file with c# openxml sdk library and got error message telling that file contains incomplete element but i was unable to find which element it is
However, when report has less than 49k rows, exported file is opened succesfully and all hyperlinks are working.
When report is exported to pdf or doc, hyperlinks are also working
I use report server vesion 12.0.2269.0
Does anyone know how to resolve this issue ?
Usually, when I have experienced this sort of issue after an Excel file exported from SSRS, I find there is something in the data that Excel has issue with. A hidden character, perhaps. The export works, opening the file is when the problem starts.
To deal with this situation I created a user defined function (UDF) in SQL Server to remove any characters that I know Excel will choke on. Below is an example of one I use.
CREATE FUNCTION [dbo].[udf_CleanData]
(
#data text
)
RETURNS varchar(max)
AS
BEGIN
DECLARE #cdata varchar(max) = #data
SELECT #cdata = REPLACE(#cdata, char(20), '') -- double quote
SELECT #cdata = REPLACE(#cdata, char(21), '') -- bullet
SELECT #cdata = REPLACE(#cdata, char(13), '') -- carriage return
SELECT #cdata = REPLACE(#cdata, char(10), '') -- line feed
SELECT #cdata = REPLACE(#cdata, char(18), '') -- single quote right
SELECT #cdata = REPLACE(#cdata, char(17), '') -- single quote left
SELECT #cdata = REPLACE(#cdata, char(22), '') -- dash
RETURN #cdata
END
You can adjust this any way you want to meet your need. This works for what I need, and that is removing all the strange characters in a text field that the dev team thought would be good to use for formatting on the front end application.
Usage:
SELECT dbo.udf_CleanData(Field1) AS CleanField1 FROM Table1
If the hyperlink you are reporting has anything unusual in it, this might remove that. If you are building the hyperlink from various pieces of data, some or all of the fields may need to be scrubbed. This is something where you will have to go through a bit of trial and error.
Other times when I have had this issue, there is an expression in the RDL that ends up calculating to either NaN, or Infinity. The Excel file after export seems to have issue with this except when exporting to an older version of Excel, like 2003.
The best way to handle this situation is adjust your expressions to check for the possibility that the final value could be out of whack, and default the value to something else, or round the value to something reasonable. This is similar to checking that a denominator is not zero before doing division.
=IIf(Fields!Total.Value > 0, Fields!Count.Value/Fields!Total.Value, 0)
There are plenty of questions about this type of thing with good solutions here on SO, so I won't list a bunch of expressions here related to data checking.
The other way to handle this is to always export to an earlier version of Excel, but that may not be any easy option, or an option at all. Usually, I only see that as an option on a report subscription, but not in the development tools.
Good luck to you!
I have also faced this issue when exporting SSRS reports to Excel. The reason in my case was that Excel can only handle 66530 hyperlinks -
https://support.office.com/en-us/article/Excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3#ID0EBABAAA=2016,_2013
Confirm again if you get this issue the moment you go over 50k (in which case the reason could be what R Richards suggests), or if it is 66530 links that cause the spreadsheet to break.
I havent found a way get around this limitation of Excel, so the only way I can think of to resolve this is to not have hyperlinks in the exported excel file at all.
If you can live without hyperlinks in the exported file, you can disable them in the report using the Globals!RenderFormat property of the SSRS report. The expression to use on the cells to not have hyperlinks if the requested format is EXCEL would be -
=IIF(Globals!RenderFormat.Name="EXCELOPENXML" ,True,False)

Opening CSV files in Excel 2016

I have a new install of Excel 2016, that hates CSV files. It opens them with everything in one column flagpole style, down column A, with commas and speech marks visible.
Salient points:
I have two machines, desktop and laptop, both running same version of Excel. Desktop works fine, opens the same problem files formatted correctly.
I can create CSV files on laptop, save those, open them again on laptop, and it's fine.
Even opening it in Notepad++, saving in the hope of some sort of file format normalisation, and still no good.
I have compared regional settings and almost all settings in Excel.
I tried renaming the file to TXT, it brought up the text file conversion dialogue, I chose comma delimited. First time it ignored that, still got everything in column A, second attempt, that actually worked, however, that is a pants solution, I want to be able to just natively open CSV files without saving as TXT, I use many different ones every day.
Anyone got any ideas?
Thanks in advance.
CSV files are character separated value files, not necessarily comma separated. For more than half the world the separator character is a semicolon (;), not a comma (,)
Excel 2016 properly respects your Windows regional settings, and uses the specified List Separator character
One solution is to change your regional settings for the List Separator attribute to the character you want Excel to default to using, e.g. a comma (,)
This can be changed in the operating system Control Panel, under Region settings, Additional Settings, List separator
For various reasons some people seem to have the incorrect regional settings for the culture they most commonly work in, and therefore have semicolon as the default separator
If you prefer not to change your operating system regional setting to what you think is normal for CSV files, you can change the default behavior in Excel with the Use system separators checkbox under the File/Options/Advanced menu
If you want custom options each time you open a CSV file, use the Data/From Text menu, but this becomes slow and awkward for lots of files
CSV References:
https://en.wikipedia.org/wiki/Decimal_separator (see map of world using comma as decimal point separator, it's very common, and hence CSV's often use semicolon separators)
https://data-gov.tw.rpi.edu/wiki/CSV_files_use_delimiters_other_than_commas
https://en.wikipedia.org/wiki/Comma-separated_values (spec point 3)
https://ec.europa.eu/esco/portal/escopedia/Comma-separated_values_%2528CSV%2529
https://parse-o-matic.com/parse/pskb/CSV-File-Format.htm
I've found a way of saving messy CSV files into a nice table format but I'm not sure if it will work for your case.
Data -> New Query -> From File -> From CSV
By opening the CSV file this way, a pop-up 'Query Editor' window will appear with a nicely organised table format where you can edit, save and load into your excel sheet.
I hope this helps.
For me the solution was to:
Data > From Text > Choose your csv file
Then you can define all the import settings for csv files.
I found another way to fix this, without changing your windows local settings.
In Excel, you go to File > Options > Advanced.
Un-check the "Use System Separators" within the Editing Options and change the Decimal separator with "," and the Thousands Separator ".".
Even it does look more like a bug than a feature of Excel 2016, it works without changing the Windows Local settings, and it's just a local Excel change.
Just had this same problem. Changing the file extension from csv to txt and opening in Excel brings up the classic wizard so you can map the strings to fields.
The correct answer is to edit your regional settings as suggested above (if a long term change in behavior is desired)
Control Panel -> Region -> Additional Settings -> List separator:
But for my purposes a simple Edit -> Find and Replace using Notepad to replace all commas with semi-colons was a quick and dirty solution that I preferred.
Despite the comment that csv means 'Character Separated Values', in Office 2016 my .csv file association to Excel still says 'Microsoft Excel Comma Separated Values File'.
I have quite a complex csv file where none of the suggestions worked out for me. So I ended up using LibreOffice Calc for the job. It worked like a dream.
I had the same problem, I fixed it in this way (Excel 2020)
Data -> Text to Columns
Now you can configure as you wish the CSV delimiters/endlines...
I had the same issue on Mac OS X El Captain. The answer given here worked for me. Reproducing it here in case the link doesnt work in future:
Close the Excel application
Click on the Apple button
Select System Preferences
Select Language and Region
Click Advanced
Change the Decimal separator from a comma (,) to a full stop (.)
Then click on Ok/Save
Test the Excel import again
When changing the list separator, make sure it doesn't overlap with the decimal symbol and the digit grouping characters. I had to change my list separator to (,) my decimal to (.) end my digit grouping to ('). Now .CSV opens lekker!!!
In my excel, it's: data> get data> from file> from text/csv
Try opening in excel, then using text to columns, based on commas.
You could probably create some simple vba to open it in that way too.

pentaho report excel output - leading '0' gets truncated

I have a format issue with my pentaho report excel/csv output.
My report output contains zip code column, which has leading zeroes if the zip code length is less than 5. the leading zeroes get truncated when i open the report output in excel file. I used 'textfield' for the zipcode column, i even tried concatenating zeroes in my xaction sql. everything works fine if i open the output in a text editor, but when we open it in excel file the zero got trimmed.
can we prevent this trimming issue or can we use other data fields in design instead of text field.
Change the extension of your csv to .txt so you get Excel's dialogue boxes for importing text files; there you can select the comma as your column delimiter. On the third screen (after you hit "next" twice), there is an option to choose the formatting of each column. Select you zip code column, change it from "General" to "Text" format, and your leading zeroes will be retained.
use text formatting in the Home-->Number-->Special
Cannt paste imapge--> i guess not enough points
Hope it helps
I don't know whether it is proper or not but enclose field in Double quotes or single which ever you prefer..
quotes will not display in excel file format but it will display in textpad or notepad..
So it you don't have any problem in adding this extra thing then it will solve your problem.
What is the original data format in your DB? Is it an INT?
In your sql statement, try something like this (adjust for the relevant sql dialect, if necessary):
lpad(cast(zip as CHAR(5)),5,'0') zip
where zip is your field name.
Then use text-field as you are already doing.

Importing CSV with line breaks in Excel 2007

I'm working on a feature to export search results to a CSV file to be opened in Excel. One of the fields is a free-text field, which may contain line breaks, commas, quotations, etc. In order to counteract this, I have wrapped the field in double quotes (").
However, when I import the data into Excel 2007, set the appropriate delimiter, and set the text qualifier to double quote, the line breaks are still creating new records at the line breaks, where I would expect to see the entire text field in a single cell.
I've also tried replacing CR/LF (\r\n) with just CR (\r), and again with just LF (\n), but no luck.
Has anyone else encountered this behavior, and if so, how did you fix it?
TIA,
-J
EDIT:
Here's a quick file I wrote by hand to duplicate the problem.
ID,Name,Description
"12345","Smith, Joe","Hey.
My name is Joe."
When I import this into Excel 2007, I end up with a header row, and two records. Note that the comma in "Smith, Joe" is being handled properly. It's just the line breaks that are causing problems.
Excel (at least in Office 2007 on XP) can behave differently depending on whether a CSV file is imported by opening it from the File->Open menu or by double-clicking on the file in Explorer.
I have a CSV file that is in UTF-8 encoding and contains newlines in some cells. If I open this file from Excel's File->Open menu, the "import CSV" wizard pops up and the file cannot be correctly imported: the newlines start a new row even when quoted. If I open this file by double-clicking on it in an Explorer window, then it opens correctly without the intervention of the wizard.
None of the suggested solutions worked for me.
What actually works (with any encoding):
Copy/paste the data from the csv-file (open in a text editor), then perform "text to columns" --> data gets transformed incorrectly.
The next stap is to go to the nearest empty column or empty worksheet and copy/paste again (same thing what you already have in your clipboard) --> automagically works now.
If you are doing this manually, download LibreOffice and use LibreOffice Calc to import your CSV. It does a much better job of stuff like this than any version of Excel I've tried, and it can save to XLS or XLSX as required if you need to transfer to Excel afterwards.
But if you're stuck with Excel and need a better fix, there seems to be a way. It seems to be locale dependent (which seems idiotic, in my humble opinion). I don't have Excel 2007, but I have Excel 2010, and the example given:
ID,Name,Description
"12345","Smith, Joe","Hey.
My name is Joe."
doesn't work. I wrote it in Notepad and chose Save as..., and next to the Save button you can choose the encoding. I chose UTF-8 as suggested, but with no luck. Changing the commas to semicolons worked for me, though. I didn't change anything else, and it just worked. So I changed the example to look like this, and chose the UTF-8 encoding when saving in Notepad:
ID;Name;Description
"12345";"Smith, Joe";"Hey.
My name is Joe."
But there's a catch! The only way it works is if you double-click the CSV file to open it in Excel. If I try to import data from text and chose this CSV, then it still fails on quoted newlines.
But there's another catch! The working field separator (comma in the original example, semicolon in my case) seems to depend on the system's Regional Settings (set under Control Panel -> Region and Language). In Norway, comma is the decimal separator. Excel seems to avoid this character and prefer a semicolon instead. I have access to another computer set to UK English locale, and on that computer, the first example with a comma separator works fine (only on doubleclick), and the one with semicolon actually fails! So much for interoperability. If you want to publish this CSV online and users may have Excel, I guess you have to publish both versions and suggest that people check which file gives the correct number of rows.
So all the details that I've been able to gather to get this to work are:
The file must be saved as UTF-8 with a BOM, which is what Notepad does when you chose UTF-8. I tried UTF-8 without BOM (can be switched easily in Notepad++), but then double-clicking the document fails.
You must use a comma or a semicolon separator, but not the one that is the decimal separator in your Regional Settings. Perhaps other characters work, but I don't know which.
You must quote fields that contain a newline with the " character.
I've used Windows line-endings (\r\n) both in the text field and as a record separator, that works.
You must double-click the file to open it, importing data from text doesn't work.
Hope this helps someone.
I have finally found the problem!
It turns out that we were writing the file using Unicode encoding, rather than ASCII or UTF-8. Changing the encoding on the FileStream seems to solve the problem.
Thanks everyone for all your suggestions!
Use Google Sheets and import the CSV file.
Then you can export that to use in Excel
Short Answer
Remove the newline/linefeed characters (\n with Notepad++). Excel will still recognise the carriage return character (\r) to separate records.
Long Answer
As mentioned newline characters are supported inside CSV fields but Excel doesn't always handle them gracefully. I faced a similar issue with a third party CSV that possibly had encoding issues but didn't improve with encoding changes.
What worked for me was removing all newline characters (\n). This has the effect of collapsing fields to a single record assuming that your records are separated by the combination of a carriage return and a newline (CR/LF). Excel will then properly import the file and recognise new records by the carriage return.
Obviously a cleaner solution is to first replace the real newlines (\r\n) with a temporary character combination, replacing the newlines (\n) with your seperating character of choice (e.g. comma in a semicolon file) and then replacing the temporary characters with proper newlines again.
If the field contains a leading space, Excel ignores the double quote as a text qualifier. The solution is to eliminate leading spaces between the comma (field separator) and double-quote. For example:
Broken:
Name,Title,Description
"John", "Mr.", "My detailed description"
Working:
Name,Title,Description
"John","Mr.","My detailed description"
If anyone stumbling across this thread and is looking for a definitive answer here goes (credit to the person mentioning LibreOffice:
1) Install LibreOffice
2) Open Calc and import file
3) My txt file had the fields separated by , and character fields enclosed in "
4) save as ODS file
5) Open ODS file in Excel
6) Save as .xls(x)
7) Done.
8) This worked perfectly for me and saved me BIGTIME!
+1 on J Ashley's comment. I ran into this problem also. It turns out that Excel requires:
A newline character("\n") in the quoted string
A carriage return and newline between each row.
E.g.
"Test", "Multiline item\n
multiline item"\r\n
"Test2", "Multiline item\n
multiline item"\r\n
I used notepad ++ to delimit each row properly and to only use newlines in the string. Discovered this by creating multiline entries in a blank excel doc and opening the csv in notepad ++.
Overview
Almost 10 years after the original post, Excel hasn't improved in importing CSV files. However, I found that it is much better in importing HTML tables. So, one can use Python to convert CSV to HTML and then import the resulting HTML to Excel.
The advantages of this approach are: (a) it works reliably, (b) you don't need to send your data to a third party service (e.g. Google sheets), (c) no extra "fat" installations required (LibreOffice, Numbers etc.) for most users, (d) higher level than meddling with CR/LF characters and BOM markers, (e) no need to fiddle with locale settings.
Steps
The following steps can be run on any bash-like shell as long as Python 3 is installed. Although Python can be used to directly read CSV, csvkit is used to do an intermediate conversion to JSON. This allows us to avoid having to deal with CSV intricacies in our Python code.
First, save the following script as json2html.py. The script reads a JSON file from stdin and dumps it as an HTML table:
#!/usr/bin/env python3
import sys, json, html
if __name__ == '__main__':
header_emitted = False
make_th = lambda s: "<th>%s</th>" % (html.escape(s if s else ""))
make_td = lambda s: "<td>%s</td>" % (html.escape(s if s else ""))
make_tr = lambda l, make_cell: "<tr>%s</tr>" % ( "".join([make_cell(v) for v in l]) )
print("<html><body>\n<table>")
for line in json.load(sys.stdin):
lk, lv = zip(*line.items())
if not header_emitted:
print(make_tr(lk, make_th))
header_emitted = True
print(make_tr(lv, make_td))
print("</table\n</body></html>")
Then, install csvkit in a virtual environment and use csvjson to feed the input file to our script. It is a good idea to disable cell type guessing with the -I argument:
$ virtualenv -p python3 pyenv
$ . ./pyenv/bin/activate
$ pip install csvkit
$ csvjson -I input.csv | python3 json2html.py > output.html
Now output.html can be imported in Excel. Line breaks in cells will have been preserved.
Optionally, you may want to cleanup your Python virtual environment:
$ deactivate
$ rm -rf pyenv
Multiline CSV can be imported easily in Excel versions with Power Query using following steps (tested in Excel 365 version 2207):
Go to Data-tab
Click "From Text/CSV" on the ribbon
Select file and click Import
Click "Transform Data" to open Power Query Editor
Click "Data source settings" on the Power Query Editor ribbon
Click "Change Source"
Select "Ignore quoted line breaks" from the "Line breaks" dropdown.
Click OK -> Close -> Close & Load
Paste into Notepad++, select Encoding > Encode in ANSI, copy all again and paste into Excel :)
I had a similar problem. I had some twitter data in MySQL. The data had Line feed( LF or \n) with in the data. I had a requirement of exporting the MySQL data into excel. The LF was messing up my import of csv file. So I did the following -
1. From MySQL exported to CSV with Record separator as CRLF
2. Opened the data in notepad++
3. Replaced CRLF (\r\n) with some string I am not expecting in the Data. I used ###~###! as replacement of CRLF
4. Replaced LF (\n) with Space
5. Replaced ###~###! with \r\n, so my record separator are back.
6. Saved and then imported into Excel
NOTE- While replacing CRLF or LF dont forget to Check Excended (\n,\r,\t... Checkbox [look at the left hand bottom of the Dialog Box)
My experience with Excel 2010 on WinXP with French regional settings
the separator of your imported csv must correspond to the list separator of your regional settings (; in my case)
you must double click on the file from the explorer. don't open it from Excel
On MacOS try using Numbers
If you have access to Mac OS I have found that the Apple spreadsheet Numbers does a good job of unpicking a complex multi-line CSV file that Excel could not handle. Just open the .csv with Numbers and then export to Excel.
Excel is incredibly broken when dealing with CSVs. LibreOffice does a much better job. So, I found out that:
The file must be encoded in UTF-8 with BOM, so consider this for all the points below
The best result, by far, is achieved by opening it from File Explorer
If you open it from within Excel there are two possible outcomes:
If it has only ASCII characters, it will most likely work
If it has non-ASCII characters, it will mess your line breaks
It seems to be heavily dependent on the decimal separator configured in the
OS's regional settings, so you have to select the right one
I would bet that it may also behave differently depending on OS and
Office version
This is for Excel 2016:
Just had the same problem with line breaks inside a csv file with the Excel Wizard.
Afterwards I was trying it with the "New Query" Feature:
Data -> New Query -> From File -> From CSV -> Choose the File -> Import -> Load
It was working perfectly and a very quick workaround for all of you that have the same problem.
With Excel 2019 I had a similar problem when working with CSV files via Data -> Import from text file / CSV. Once the connection is made and the data is synced, it reported xx error(s) because of shifted columns caused by the line breaks.
I managed to solve this by
Edit the query (Query -> Edit)
This opens the Power Query Editor
Go to Start -> Advanced Editor
This opens the query in text format, where line #2 had an instruction like
Source = Csv.Document(File.Contents("my.csv"),[Delimiter=",", .... , QuoteStyle=QuoteStyle.None]),
Change QuoteStyle.None to QuoteStyle.Csv
Click Finish
Apply & close
Documentation found here: https://learn.microsoft.com/en-us/powerquery-m/csv-document
NB. I since found where this is "hidden" in the UI. In the Power Query-editor, click Data source settings, Change source (bottom left), and the Line breaks combo should say Ignore line breaks between quotes.
NB2. Working from Dutch Excel here so my above-mentioned translations of button captions etc. may be a little off.
What just worked for me, importing into Excel directly provided that the import is done as a text format instead as csv format.
M/
just create a new sheet with cells with linebreak, save it to csv then open it with an editor that can show the end of line characters (like notepad++). By doing that you will notice that a linebreak in a cell is coded with LF while a "real" end of line is code with CR LF. Voilà, now you know how to generate a "correct" csv file for excel.
I also had this problem: ie., csv files (comma delimited, double quote delimited strings) with LF in quoted strings. These were downloaded Square files. I did a data import but instead of importing as text files, imported as "from HTML". This time it ignored the LF's in the quoted strings.
This worked on Mac, using csv and opening the file in Excel.
Using python to write the csv file.
data= '"first line of cell a1\r 2nd line in cell a1\r 3rd line in cell a1","cell b1","1st line in cell c1\r 2nd line in cell c1"\n"first line in cell a2"\n'
file.write(data)
In my case opening CSV in notepad++ and adding SEP="," as the first line allows me open CSV with line breaks and utf-8 in Excel without issues
Replace the separator with TAB(\t) instead of comma(,).
Then open the file in your editor (Notepad etc.), copy the content from there, then paste it in the Excel file.
It appears that this is much easier in more recent versions of Excel:
Go to "Data" -> "Get Data (Power Query)"
In the dialogue that opens, select "Text / CSV" on the right
Search for the file and then click "Next" and follow the recommendations (in my case, Excel now correctly realized it's UTF8 and that cells were separated by ";" and the text identifier were double quotes (")
You're done!
This took a little moment to load but afterwards I had an auto-formatted table that looked really nice and that did understand that multi-line entries were still part of the same entry.
If you want the multi-lines to show correctly, simply format the cells and under "Alignment", click the checkbox for "Wrap text". That should solve the last of your issues.
Good luck! ;-)

Resources