c# 输出excel、word实例只需一行代码

第一、首先下载 WindICFrameNet.dll 下载地址:http://pan.baidu.com/s/1dDBqC9r

第二、前台代码

<div style="display: none;" runat="server" id="content">
            <table cellspacing="0" class="listable_table" border="0" width="95%">
                <tr>
                    <td style="height: 24px; font-weight: bold; font-size: 25; text-align: center;">
                         标题</td>
                </tr>
                <tr>
                    <td>
                        <asp:DataGrid ID="dgOutPut" runat="server" Width="100%" DataKeyField="column1" BorderStyle="None"
                            AllowSorting="true" HorizontalAlign="Center" AutoGenerateColumns="False" 
                            onitemdatabound="dgOutPut_ItemDataBound">
                            <AlternatingItemStyle Wrap="False" CssClass="datagrid_Aitem"></AlternatingItemStyle>
                            <ItemStyle Wrap="False" CssClass="datagrid_item"></ItemStyle>
                            <HeaderStyle CssClass="datagrid_head" Font-Bold="True"></HeaderStyle>
                            <Columns>
                                <asp:BoundColumn DataField="XingMing" HeaderText="姓名"></asp:BoundColumn>
                                <asp:BoundColumn DataField="YingShiYZ" HeaderText="应试语种"></asp:BoundColumn>
                            </Columns>
                        </asp:DataGrid>
                    </td>
                </tr>
            </table>
        </div>

三、后台代码

WindICFrameNet.Tools.Office.ToExcel(content, "ww.xls");

原文地址:https://www.cnblogs.com/honghong75042/p/3488782.html