自己几个字符串常量,比如说private const string = "----"之类的来实现
在对应的位置插入对应的字符串
这个很容易呀
不过建议用XML

解决方案 »

  1.   

    你数据库存的是什么啊!?
    varchar,char,text还是binary?
      

  2.   

    string tmpstr = "文本..................................";
    string newstr = "";
    for (int i=0;i<tmpstr.Length;i++)
    {
    if (tmpstr.Length - 15 > 0)
    {
    newstr += "    " + tmpstr.Substring(i,15) + "\r\n";
    }
    }
    MessageBox.Show(newstr);
      

  3.   

    再加一个else
    {
    newstr += "    " + tmpstr.Substring(i,tmpstr.Length -1) + "\r\n";
    }
      

  4.   

    如果是输出到记事本中,很难解决对齐的问题,建议输出到Excel中
    1.       首先,产生一个文件夹来存放Excel文件private string genReportPath()         {              try              {                   string _path="..//ReportDoc//DRI";                                                       if (!Directory.Exists(Server.MapPath(_path)))                   {                                                   Directory.CreateDirectory(Server.MapPath(_path));                    }                       return _path;              }              catch(Exception er)              {                   throw er;              }         }2.确定Excel文件string reportpath=this.genReportPath()+"//"+_reportname+".xls";  3.生成Excel文件this.genExcel(ds_DRI,Server.MapPath(reportpath).ToString());4.生成函数(需要一个DataSet,还需要一个路径)private void genExcel(DataSet ds,string ReportPath)         {              try              {                   //删除重复的文件;                   if (File.Exists(ReportPath))                   {                        File.Delete(ReportPath);                   }                   FileStream fsobj=new FileStream(ReportPath,System.IO.FileMode.Create,FileAccess.ReadWrite);                                 //生成一个文件流                   StreamWrite     _sw=new StreamWriter(fsobj,System.Text.UnicodeEncoding.Unicode);//生成一个写入器//开始写入DataTable dt=ds.Tables[0];              for(int j=0;j<countMRD;j++)                   {                        _sw.Write(dt.Rows[j][0].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][1].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][2].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][3].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][4].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][5].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][6].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][7].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][8].ToString().Trim()+"\t");                        _sw.Write(dt.Rows[j][9].ToString().Trim()+"\t");}_sw.close();fsobj.close();     }     catch(Exception er)     {         throw er;     }