Converting Text to HTML

Hey Easy Morph Team/Community,

Anyone ever have to convert a text field to HTML before uploading into a SQL Dbase? So what I’m trying to do, I’m reading values from an XLSX sheet. The data in the XLS sheet has some line breaks and lets say bullets. I need this data from the XLSX to be converted to HTML code (with

etc) from the data that in the cell before I upload it into SQL.

Any ideas? Feature?

Thanks
Flowy

Hi Flowy,

The typical approach would be to construct HTML in EasyMorph using expressions and text function. For instance you can replace line breaks with the <br/> tag as follows:

replace([Text], linebreak(), '<br/>')

To wrap a value as an HTML paragraph:

'<p>' & [Text] & '</p>'

Etc.

Awesome! Thanks Dmitry! Let me give this a try!!!

Flowy

Hey Dmitry,

Is there some setting or formatting to allow this to happen? This is a sample of the data in the cell. When I try to execute it basically using a calculate a create new column. I call the replace ([text],linebreak(), ‘
’). I even tried based on the sample as Replace([text], linebreak(), ‘’). But both of these does nothing. Its almost like it can’t find the line break instead of my sample.

SampleText: (below)

This is a sample textdocument. Need to figure out why this is not working and why the cell when ready and calculating it won’t replace the line breaks.

Pros:
• How easy is it to use
• Interesting how this is not working
• Line is calculated and does nothing

Can you attach a sample file?

Sure let me create one. I basically just took an excel document (xlsx) and had a column with text in it and it had spaces and new lines in one cell.

but let me attach.

Text Import Test.xlsx (29.6 KB)

attaching sample file.

thanks Dmitry!

Dmitry,
this is what I was using. Calculating new column to do the replace…
image

Thanks. Here is what worked:

 replace([Text:], char(10), '<br/>')

I’ve also added an example of producing HTML from text. It converts a bulleted list into a proper ul and li HTML elements.

build-html.morph (8.1 KB)

Thanks Dmitry! Worked great! Should it have worked with linebreak()? i saw you had another example somewhere that also referenced using that instead of the ascii number. I’m going to look over your sample too cause i"m sure I’ll need to add other html formatting to my list.

Flowy

There are 3 types of line breaks - CR, LF and CRLF. It turned out that Excel uses LF, while linebreak() generates CRLF.