wfwt3000 2010-10-14 12:20
浏览 383
已采纳

数据导入到txt中怎么没有换行,程序中的“/n”不管用,怎么回去?求解?

public void ToTxtAll(string userid)
{
try
{
DataSet ds = AppClient.App.HRUserManager.toText(userid);
string excelString = "编号\t姓名\t起始时间\t\t终止时间\t\t工作单位\t职务\t职级\n";
foreach (DataRow dr in ds.Tables[0].Rows)
{
excelString += dr["id"].ToString() + "\t" + dr["username"].ToString() + "\t" + dr["startdate"].ToString() + "\t";
excelString += dr["enddate"].ToString() + "\t" + dr["company"].ToString() + "\t" + dr["duty"].ToString() + "\t";
excelString += dr["post"].ToString() + "\n";
}

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("工作简历信息.txt"));
            HttpContext.Current.Response.ContentType = "text/plain";
            this.EnableViewState = false;
            HttpContext.Current.Response.Write(excelString.ToString());
            HttpContext.Current.Response.End();



        }
        catch (Exception ex)
        {
            ClientScript.RegisterClientScriptBlock(Page.GetType(), "提示", "<script>alert('导出数据出现错误!')</script>");
        }
    }
  • 写回答

2条回答 默认 最新

  • ayling520 2010-10-15 13:54
    关注

    解决了,居然不给分。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀