I have a question regarding Excel and how it saves/exports its worksheet as html.
If I have a long text in an unmerged cell of a worksheet, and when I export the worksheet as wep page, why does the text of the cell break into multiple lines in the html source code?
For example, Cell A1 has text Select X and Y, and run XYZ code to blah blah blah. When the worksheet is saved as a web page, the source code looks like:
<tr height=20 style='height:15.0pt'>
<td height=20 class=xl1511698 colspan=5 style='height:15.0pt'>Select X and Y,
and run XYZ code to blah blah blah</td>
</tr>
Select X and Y, in one line, and and run XYZ code to blah blah blah into another. Is there a way to prevent this? Some VBA code, or built-in settings?
I need this information because I have a macro code that scans each line of the exported html file to search for some text. If the text appears broken in the html file, the macro couldn’t find it.
It appears that the lines in the HTML text file wrap at around 80 characters. I don’t see any obvious way to change it and suspect that since line breaks like this aren’t usually significant in HTML, it can’t be changed. If I insert a line feed in my Excel cell (using
Alt+Enter) it’s reproduced in the HTML output as a<br>.You asked this:
.. and the answer isn’t very useful, I’m afraid: “because it’s made that way”.
You made a not unreasonable assumption about the way that the file would look: unfortunately in this case the assumption proved to be incorrect. Can you make your code smarter, so that it looks for text within
<td>and</td>tags across physical lines in the file?