1

我构建了一个 SOW 模板生成器,它将 Word Doc 的邮件合并字段替换为来自相关数据库字段的富文本(使用 html 标记)内容。一切都按预期工作,但我遇到了一些问题,试图让格式看起来正确。

我的两个主要问题是列表中的项目符号和自动换行。

为了获得我需要的项目符号样式,Word 实际上使用了“o”并将“courier new”指定为字体。我无法指定字体,因为 word 将始终覆盖 doc 样式。

Word 在进行合并时似乎不尊重列表项,因此一旦文本到达文档的边缘,它就会从文档的最左侧开始,而不是为项目符号添加标签。word转换为html时生成的页面源对于每个列表和级别都有特定的样式和ID。我尝试使用内联样式等效项来获得换行效果,但它不起作用。

任何人都对如何正确设置这些元素的样式有建议,以便 Word 尊重格式?

这是我的标记示例,它保留了迄今为止最好的格式:

<p style="margin:0;">Here is a bunch of random text:</p>
<p style="margin:0 0 0 1in;">•&amp;nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;Summarized steps of nonsense.</p>

<p style="margin:0 0 0 1in;">•&amp;nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;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;">•&amp;nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;Description of blah blah etc and more stuff.  This is a lot of useless text.</p>

<p style="margin:0 0 0 1in;">•&amp;nbsp;&nbsp;&nbsp;&nbsp;Scope of stuff and methodlogy of stuff</p>

<p style="margin:0 0 0 1in;">•&amp;nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;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>
4

1 回答 1

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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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>

如果这可行,你能在这里发布更多关于你的方法的信息吗?很感兴趣!

于 2013-08-13T21:29:43.930 回答