我试图仅在一个单元格中保留换行符,但是在我执行下面的更改并将其导出为excel后,它仍然无法正常工作。
更改是用"< br style =" mso-data-placement:same-cell; />" 替换列表的结尾
var reUselessTags = /(<.{0,1}body|<.{0,1}FONT|<.{0,1}TEXTFORMAT|<img|<.{0,1}div|<.{0,1}list).{0,}?>/g;
var reRemoveScript = /<script.{0,}?<\/script>/g;
var reList = /<LI.{0,}?>/g;
var reListParagraphStart = /<(LI|P).{0,}?>/g;
var reListParagraphEnd = /<(\/LI|\/P).{0,}?>/g;
var reBreak = /<BR.{0,}?>/g;
var reDoubleLineBreak = /\r+/g;
var reOpenLineBreak = /^\r/g;
var resStr = row["DESCRIPTION"];
resStr = resStr.replace(reUselessTags,'');
resStr = resStr.replace(reRemoveScript,'');
resStr = resStr.replace(reBreak,'');
resStr = resStr.replace(reDoubleLineBreak,'');
resStr = resStr.replace(reOpenLineBreak,'');
resStr = resStr.replace(newLine, '');
resStr = resStr.replace(reList, '');
resStr = resStr.replace(reListParagraphStart,'');
resStr = resStr.replace(reListParagraphEnd,'<br style="mso-data-placement:same-cell;" />');
result