一个关于输出到记事本的问题 自己几个字符串常量,比如说private const string = "----"之类的来实现在对应的位置插入对应的字符串这个很容易呀不过建议用XML 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你数据库存的是什么啊!?varchar,char,text还是binary? 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); 再加一个else { newstr += " " + tmpstr.Substring(i,tmpstr.Length -1) + "\r\n"; } 如果是输出到记事本中,很难解决对齐的问题,建议输出到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; } jmail 邮件接收问题 电脑流量统计,通过代码如何统计,C#方面的,在线等 接口有什么用?为什么要用接口?什么时候该使用接口? schema.ini(ODBC Text Driver) 的问题 怎么样遍历表的一列的值 列出我的电脑下的东西 各位使用 C# 的,提个问题!!! 誰用过[地图.PrintMap(...)]语句,帮下忙 datagrid控件问题 各位大哥来帮帮小妹好吗~~~~很急呀~~~ .net 和 Sybase ,大侠救我啊。 请各位高手推荐基本经典的c#教程,最好比较全面的!
varchar,char,text还是binary?
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);
{
newstr += " " + tmpstr.Substring(i,tmpstr.Length -1) + "\r\n";
}
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; }