使用阿拉伯语内容将HTML表格导出到aspx页面中的Excel

时间:2016-10-10 09:30:27

标签: c# asp.net ajax excel

我使用Ajax / C#编写代码,将jQuery的数据附加到HTML表,这是表头:

table id='tblUsers' class='table table-striped table-condensed table-hover table-bordered table-responsive' >      
             <tr>
                   <th>Customer ID</th>
                   <th>Customer Name</th>
                   <th>File #</th>
                   <th>Territory</th>
                   <th>Start Date</th>
                   <th>Goods Desc</th>
                   <th>Custom Declaration</th>
                   <th>Quantity</th>
                   <th>Weight</th>
                   <th>Volumetric Weight</th>
                   <th>Mortage Amount</th>
                   <th>Invoice#</th>
                   <th>Invoice Amount</th>
             </tr>
     </table>    

这是Ajax Call:

 $.ajax({
                        url: "WebService.asmx/showResult",
                        type: "post",
                        data: JSON.stringify({
                            "dateFrom": $('#txtDateFrom').val(),
                            "dateTo": $('#txtDateTo').val(),
                            "ddlType": $("#ddlType").children("option").filter(":selected").val(),
                            "ddlTer": $("#ddlTer").children("option").filter(":selected").val(),
                            "ddlFilter": $("#filter").children("option").filter(":selected").val()
                        }), // parameters
                        beforeSend: function () {
                            $('#loader').html('<img src="Images/loading.gif" />');


                        },

                        contentType: "application/json; charset=utf-8",
                        success: function (result) {
                            $('#loader').html('');
                            document.getElementById('filter').style.display = 'inherit';
                            document.getElementById('logo').style.display = 'none';
                            document.getElementById('exp').style.display = 'inherit';
                            //To delete the whole tr except the first one.
                            $("#tblUsers").find("tr:gt(0)").remove();
                            $('#tblUsers').append(JSON.stringify(result));
                            if ($("#ddlType").val() != 0) {
                                document.getElementById('filter').style.display = 'none';

                            }

                        },
                        error: function () {
                            alert('error');
                        }


                    });

WebMethod:

      var sp = db.divideTypes(dateFrom, dateTo, ddlFilter).ToList();
      foreach (var u in sp)
      {
            result += "<tr>";

            result += "<td>" + u.custid + "</td>";
            result += "<td>" + u.custname + "</td>";
            result += "<td>" + u.depno + "</td>";
            result += "<td>" + u.Terr + "</td>";
            result += "<td>" + u.deidate + "</td>";
            result += "<td>" + u.gooddesc+ "</td>";
            result += "<td>" + u.custdec + "</td>";
            result += "<td>" + u.pkg + "</td>";
            result += "<td>" + u.wt + "</td>";
            result += "<td>" + u.vwt + "</td>";
            result += "<td>" + u.lcamt+ "</td>";
            result += "<td>" + u.invno + "</td>";
            result += "<td>" + u.invamt + "</td>";
            result += "<td></td>";

            result += "</tr>";
      }

我试图通过网络阅读文章,将excel表导出为ex​​cel文件,但是 使用JQuery,How to export HTML table data to excel sheet using Jquery

标题

并且有很多这样的文章都失败了,因为我想渲染阿拉伯字母,所以字母看起来很奇怪。

我注意到stackOverflow中有一篇文章:Export Data table With Arabic Data to Excel

谈论类似于我的情况,但我真的不知道如何实施它。

0 个答案:

没有答案