C# .Response.Write 导出报表修改文本格式

base.Response.Clear();
                base.Response.ContentEncoding = Encoding.UTF8;
              
                base.Response.ContentType = "Application/ms-excel";
                
                
                base.Response.AppendHeader("Content-Disposition", "attachment;filename=\"Export_" + DateTime.Now.ToString("yyyymmddhhmm") + "_" + base.RandKey(4) + ".xls\"");
                if ((table != null) && (table.Rows.Count > 0))
                {
                    base.Response.Write("");
                    base.Response.Write("");
                    base.Response.Write("");
                    base.Response.Write("
订单列表
"); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; //根据mainId 获取到商户的信息 DataSet posuserDS = BasePage.BindAgeData("SELECT * FROM [posplat].[dbo].[PosUser] where mainid = '" + row["mainid"].ToString() + "'"); DataTableCollection posusertables = posuserDS.Tables; if (posuserDS.Tables.Count == 1) { DataTable theTable = posusertables[0]; DataRowCollection therows = theTable.Rows; DataRow therow = therows[0]; string combankname1 = therow["combankname1"].ToString(); //商户银行卡开户行名称 string zhihangming = therow["combanksort2"].ToString();//支行名 string lianhanghao = therow["combank2"].ToString();//联行号 string combankcarnum1 = therow["combankcarnum1"].ToString();//银行卡号 string combankcarname1 = therow["combankcarname1"].ToString();//shou kuan ren string isT0 = therow["postdayid"].ToString().Equals("6") ? "是" : "否"; //是否T0代付 base.Response.Write(""); base.Response.Write("".Replace("{TEXT}", BasePage.TimeStr(row["addtime"].ToString()))); base.Response.Write("".Replace("{TEXT}", row["systr"].ToString())); base.Response.Write("".Replace("{TEXT}", row["mainid"].ToString())); base.Response.Write("".Replace("{TEXT}", row["niname"].ToString())); base.Response.Write("".Replace("{TEXT}", row["serid"].ToString())); base.Response.Write("".Replace("{TEXT}", this.GetTradeType(row["tradesort"].ToString()))); base.Response.Write("".Replace("{TEXT}", BasePage.PosTradeState(row["tradestate"].ToString()))); base.Response.Write("".Replace("{TEXT}", row["total"].ToString())); double jiesuanJinEr = Convert.ToDouble(row["total"]) - Convert.ToDouble(row["tax"]); base.Response.Write("".Replace("{TEXT}", jiesuanJinEr.ToString())); base.Response.Write("".Replace("{TEXT}", row["rate"].ToString())); base.Response.Write("".Replace("{TEXT}", row["tax"].ToString())); base.Response.Write("".Replace("{TEXT}", combankname1)); base.Response.Write("".Replace("{TEXT}", zhihangming)); base.Response.Write("".Replace("{TEXT}", lianhanghao)); base.Response.Write("".Replace("{TEXT}", combankcarnum1)); base.Response.Write("".Replace("{TEXT}", combankcarname1)); base.Response.Write("".Replace("{TEXT}", BasePage.CardDis(row["carnum"].ToString())));//支付卡号 base.Response.Write("".Replace("{TEXT}", row["carorg"].ToString()));//支付卡号 base.Response.Write("".Replace("{TEXT}", isT0));//是否T0代付 base.Response.Write("".Replace("{TEXT}", BasePage.TimeStr(row["jiesuantime"].ToString())));//结算时间 base.Response.Write(""); } else { MessageBox.Show(this, "导出失败,获取商户信息失败!"); return; } } base.Response.Write("
交易时间订单号商户号商户简称终端号交易类型交易状态交易金额结算金额执行费率(%)手续费收款行支行名行联行号收款帐户收款人支付卡号卡片类型是否T0商户结算时间
{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}{TEXT}
"); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write("".Replace("{PrintTime}", DateTime.Now.ToString())); base.Response.Write(""); base.Response.Write(""); base.Response.Write(""); base.Response.Write("
导出时间: {PrintTime}
"); } base.Response.Flush(); base.Response.Close(); base.Response.End(); }

你可能感兴趣的:(C# .Response.Write 导出报表修改文本格式)