请教asp.net 导出word 怎样保留回车、换行?

fangma2001 2020-07-28 11:08:00

Dim str As String = ""
' str += "<html><head><title></title></head><body>"
'ye mian shi tu
str += "<html "
str += "xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office' "
str += "xmlns:w='urn:schemas-microsoft-com:office:word' xmlns:m='http://schemas.microsoft.com/office/2004/12/omml' "
str += "xmlns='http://www.w3.org/TR/REC-html40' "
str += " ><head> "
str += " <!--[if gte mso 9] "
str += "><xml><w:WordDocument><w:View>Print</w:View><w:TrackMoves>false</w:TrackMoves><w:TrackFormatting/><w:ValidateAgainstSchemas/><w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid><w:IgnoreMixedContent>false</w:IgnoreMixedContent><w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText><w:DoNotPromoteQF/><w:LidThemeOther>EN-US</w:LidThemeOther><w:LidThemeAsian>ZH-CN</w:LidThemeAsian><w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript><w:Compatibility><w:BreakWrappedTables/><w:SnapToGridInCell/><w:WrapTextWithPunct/><w:UseAsianBreakRules/><w:DontGrowAutofit/><w:SplitPgBreakAndParaMark/><w:DontVertAlignCellWithSp/><w:DontBreakConstrainedForcedTables/><w:DontVertAlignInTxbx/><w:Word11KerningPairs/><w:CachedColBalance/><w:UseFELayout/></w:Compatibility><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel><m:mathPr><m:mathFont m:val='Cambria Math'/><m:brkBin m:val='before'/><m:brkBinSub m:val='--'/><m:smallFrac m:val='off'/><m:dispDef/><m:lMargin m:val='0'/> <m:rMargin m:val='0'/><m:defJc m:val='centerGroup'/><m:wrapIndent m:val='1440'/><m:intLim m:val='subSup'/><m:naryLim m:val='undOvr'/></m:mathPr></w:WordDocument></xml><![endif]--> "
str += " <title></title></head><body>"

str += "<TABLE style='Z-INDEX: 101; LEFT: 21px; WIDTH: 600px; POSITION: absolute; TOP: 0px; HEIGHT: 556px'"
str += "id='Table0' border='0' cellSpacing='1' "
str += "cellPadding='1'>"
str += "<TR>"
str += "<TD style='HEIGHT: 38px' colSpan='4' align='center'><FONT style='FONT-WEIGHT: bolder; FONT-SIZE: 16px' face='宋体'>" & Tbyear.Text.Trim & "年" & Ddlpart.SelectedValue.Trim & "</FONT></TD>"
str += "</TR>"
str += "</Table>"
...全文
4895 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
E次奥 2020-08-03
  • 打赏
  • 举报
回复
用下边这个拼接,不要+++++++++++++++++

StringBuilder sb = new StringBuilder();
sb.AppendLine("xxxxxxxxx");
fangma2001 2020-07-28
  • 打赏
  • 举报
回复
从数据库中读数据,导出word,段落中的回车换行都不显示,格式比较乱。用server.htmldecode()后,请问再怎样处理?
threenewbee 2020-07-28
  • 打赏
  • 举报
回复
str += "123换行<br />\r\n345"
这样就换行了
danny_2020 2020-07-28
  • 打赏
  • 举报
回复
str += "</Table>\n\r" \n\r 表示回车换行

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧