将webform导出到MS Word

时间:2015-10-23 09:11:22

标签: c# asp.net webforms ms-word export-to-word

我一直在查看有关如何从asp.net导出到单词的教程和其他问题,但大多数我发现正在处理一个简单的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

1 个答案:

答案 0 :(得分:0)

最干净的是&#34;转换&#34;信息到Word可以打开和显示的有效文档类型。如果标准HTML可以提供所需的质量,您可以使用它。如果您需要更强大的功能,可以使用Open XML SDK编写WordOpenXML。

我想,一个很大的问题是,您是否真的需要显示表单控件或者信息是否足够好。