0

我一直在研究如何从 asp.net 导出到 word 的教程和其他问题,但我发现大多数都是处理一个简单的 html 表,这不是我需要的或涉及昂贵的扩展。

我有一个用户填写并提交的网络表单。提交后,我想让他们选择将其导出到 Word(见屏幕截图)。

我已经尝试右键单击并另存为测试,看看它是如何出现的,它一点也不整洁(见截图)。

当我打印预览时,由于汉堡侧栏(见截图),页面也是一团糟,这两个问题有关系吗?

关于让 doc 看起来与网页相似的任何提示?

我的代码示例:

<!--Section 4 - Health & Safety-->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseFour">Health & Safety</a>
        </h3>
    </div>
    <div id="collapseFour" class="panel-collapse collapse in">
        <div class="panel-body">
            <p>Have their been any changes to Health and Safety issues since the last assessment?</p>
            <label class="radio-inline">
                <span class="checkableBox checkableBox-radio">
                    <asp:RadioButton class="validate[required]" ID="rbtnHealthYes" runat="server" value="Y" Text="Yes" GroupName="HealthAndSafetyChanges" />
                </span>
            </label>
            <label class="radio-inline">
                <span class="checkableBox checkableBox-radio">
                    <asp:RadioButton class="validate[required]" ID="rbtnHealthNo" runat="server" value="N" Text="No" GroupName="HealthAndSafetyChanges" />
                </span>
            </label>
            <br /><br />
            <p><i>If the answer to the above is yes, please give more details below and complete a new Health and Safety Assessment.</i></p>
            <asp:TextBox class="form-control input-sm auto-size m-b-10" ID="txtHealthDetails" runat="server" TextMode="MultiLine"
                placeholder="This could include things such as new renovations to the house or measures which have since broken.  (This text box will grow as you fill it)"></asp:TextBox>
            <hr class="whiter m-t-20" />
            <br />
            <br />
            <p>Additional Comments:</p>
            <asp:TextBox class="form-control input-sm auto-size m-b-10" ID="txtHealthComments" runat="server" TextMode="MultiLine"
                placeholder="(This text box will grow as you fill it)"></asp:TextBox>

        </div>
        <!--Body End -->
    </div>
    <!--Collapse 4 End -->
</div>
<!--Section 4 End -->

http://joshcoopster.tumblr.com/image/131738484325

http://joshcoopster.tumblr.com/image/131738526900

http://joshcoopster.tumblr.com/image/131738596840

4

1 回答 1

0

Cleanest would be to "transform" the information to a valid document type that Word can open and display. If standard HTML can give you the required quality, you can use that. If you need something more powerful you can use write WordOpenXML using the Open XML SDK.

One big question is, I suppose, whether you really need to show the form controls or whether just the information is good enough.

于 2015-10-23T16:30:53.247 回答