This not a special way to export it, i use the <pre></pre> code of HTML, so the text will be diplayed into a html file in the same form you add it:
<html>
<head>
<title>Export File</title>
</head>
<body bgcolor="#fff">
<pre>
here the source code
</pre>
</body>
</html>