Esempio n. 1
0
        public void ExportToExcel(HttpContext context)
        {
            BalanceStatisticsQuery          dataQuery = this.GetDataQuery(context);
            IList <SupplierSettlementModel> balanceStatisticsExportData = BalanceHelper.GetBalanceStatisticsExportData(dataQuery);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("<th>联系电话</th>");
            stringBuilder.Append("<th>可提现金额</th>");
            stringBuilder.Append("<th>已冻结提现</th>");
            stringBuilder.Append("<th>已提现总额</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (SupplierSettlementModel item in balanceStatisticsExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SupplierName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Tel, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.CanDrawRequestBalance.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.FrozenBalance.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.BalanceOut.F2ToString("f2"), false));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SupplierSettlement" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }