我构建了一个SOW模板生成器,用相关数据库字段中的Rich Text(使用html标记)内容替换Word Doc的邮件合并字段。一切都按预期工作,但我遇到了一些问题,试图让格式看起来正确。
我的两个主要问题是列表上的要点和自动换行。
为了获得我需要的项目符号样式,Word实际上使用了'o'并指定'courier new'作为字体。我无法指定字体,因为单词将始终覆盖文档样式。
Word在进行合并时似乎并不尊重列表项,因此一旦文本到达文档的边缘,它就会从文档的最左侧开始,而不是为项目符号选项卡。将word转换为html时生成的页面源具有每个列表和级别的特定样式和ID。我尝试使用内联样式等效来获得包装效果,但它不起作用。
任何人都有关于如何正确设置这些元素样式的建议,以便Word遵循格式化?
以下是我的标记示例,它保留了迄今为止最好的格式:
<p style="margin:0;">Here is a bunch of random text:</p>
<p style="margin:0 0 0 1in;">• Executive Summary</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Here is a lot more random text and stuff. Super fun.</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> More superfluous stuff. If I knew Latin I would do that instead.</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Summarized steps of nonsense.</p>
<p style="margin:0 0 0 1in;">• Stuff Description</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Description of the stuff and how the stuff was suppose to to meet the needs of the peoples in the places.</p>
<p style="margin:0 0 0 1in;">• Reporting and stuff</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Description of blah blah etc and more stuff. This is a lot of useless text.</p>
<p style="margin:0 0 0 1in;">• Scope of stuff and methodlogy of stuff</p>
<p style="margin:0 0 0 1in;">• Findings and Recommendations of stuff</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Scoring stuff and making sure people got the right stuff for the stuff. Keeping the stuff safe one day at a time. yay.</p>
<p style="margin:0;">Appendices: I had enough of this stuff so I'm going to stop typing.</p>
答案 0 :(得分:0)
您可以尝试将文档保存为.html网页,然后只使用生成的代码吗?我有类似的东西:
<p class=MsoNormal>Hello hello hello.</p>
<p class=MsoListParagraphCxSpFirst style='text-indent:-.25in;mso-list:l0 level1 lfo1'>
<![if !supportLists]><spanstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'>
<span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span>
<![endif]>Test</p>
<p class=MsoListParagraphCxSpMiddle style='text-indent:-.25in;mso-list:l0 level1 lfo1'>
<![if !supportLists]><spanstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'>
<span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span>
<![endif]>Test</p>
<p class=MsoListParagraphCxSpLast style='text-indent:-.25in;mso-list:l0 level1 lfo1'>
<![if !supportLists]><spanstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'>
<span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'> </span></span></span>
<![endif]>This is so much test that the line actually goes all the way to the right of the page and then wraps back around to the beginning of the bullet. Wow.</p>
<p class=MsoNormal>No more bullets.</p>
如果这样可行,您可以在此发布更多有关您的方法的内容吗?非常感兴趣!