如何批量生成html文件? 用.net中system.io就是文件的操作完全可以实现你说的那些功能 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要生成的htm文件它的来源是哪? 不会只是拷贝吧? 假设你的数据是从数据库里面来的,这有一个例子:FileInfo htmFile;TextWriter outText=null; for(int i=0;i<100;i++) { htmName="test"+i.ToString()+".htm"; htmFile=new FileInfo(Server.MapPath(htmName)); outText=htmFile.CreateText(); remote.CreateHtm("selectPrint2",Convert.ToInt32("1"),strCssFile,"name","sex"); outText.WriteLine(remote.HtmCode); outText.Flush(); }public string CreateHtm(string process,int id,string cssFile,params string[] fields) { htmCode="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"; htmCode+="<link href="; htmCode+=cssFile; htmCode+=" rel=\"stylesheet\" type=\"text/css\">"; htmCode+="<body topmargin=\"0\" leftmargin=\"0\">"; htmCode+="<div class=\"block\"><table width='500' border='0' align='center' cellpadding='3' cellspacing='1'>"; try { SqlCommand cmdSelect=new SqlCommand(process,cnn); cmdSelect.CommandType = CommandType.StoredProcedure; cmdSelect.Parameters.Add("@id",Convert.ToInt32("1")); cnn.Open(); dr=cmdSelect.ExecuteReader(); while(dr.Read()) { foreach(string field in fields) { i++; } for(int j=0;j<m;) { htmCode+="<tr><td width=250>"; htmCode+=dr[fields[j].ToString()].ToString(); j++; htmCode+="</td><td width=250>"; htmCode+=dr[fields[j].ToString()].ToString(); j++; htmCode+="</td></tr>"; } htmCode+="</table></div></body>"; }//while } finally { cnn.Close(); } }//BuildTable就是用一个循环创建文件然后写入数据 shixueli(渴望成功),您的源码不是很全啊,能不能帖稍微完整些的。比如HtmCode是哪来的? ;;; -----------------------------------------------------------以上文字、图由易我秀输出,你也想这么酷吗?http://www.eoshow.com/download/install1.html 支付宝分成收益问题! repeater中循环单选按钮,如何实现单选按钮单选。 money类型 如何控制自定义用户控件的事件? gridview 编辑后,update失败. 求助!! 两个自定义控件放在发生冲突 用户登录的问题,大家帮忙啦! 客户端脚本怎么调用类库中的函数啊? 我是新手第一次请教大家这个网站免费api数据接口怎么调用 请问这是什么错误:无法在WEB服务器上启动调试。。。 鼠标右键屏蔽怎么不行?
FileInfo htmFile;
TextWriter outText=null;
for(int i=0;i<100;i++)
{
htmName="test"+i.ToString()+".htm";
htmFile=new FileInfo(Server.MapPath(htmName));
outText=htmFile.CreateText();
remote.CreateHtm("selectPrint2",Convert.ToInt32("1"),strCssFile,"name","sex");
outText.WriteLine(remote.HtmCode);
outText.Flush();
}public string CreateHtm(string process,int id,string cssFile,params string[] fields)
{
htmCode="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
htmCode+="<link href=";
htmCode+=cssFile;
htmCode+=" rel=\"stylesheet\" type=\"text/css\">";
htmCode+="<body topmargin=\"0\" leftmargin=\"0\">";
htmCode+="<div class=\"block\"><table width='500' border='0' align='center' cellpadding='3' cellspacing='1'>"; try
{
SqlCommand cmdSelect=new SqlCommand(process,cnn);
cmdSelect.CommandType = CommandType.StoredProcedure;
cmdSelect.Parameters.Add("@id",Convert.ToInt32("1"));
cnn.Open();
dr=cmdSelect.ExecuteReader(); while(dr.Read())
{
foreach(string field in fields)
{
i++;
} for(int j=0;j<m;)
{
htmCode+="<tr><td width=250>";
htmCode+=dr[fields[j].ToString()].ToString();
j++;
htmCode+="</td><td width=250>";
htmCode+=dr[fields[j].ToString()].ToString();
j++;
htmCode+="</td></tr>";
} htmCode+="</table></div></body>";
}//while
}
finally
{
cnn.Close();
}
}//BuildTable就是用一个循环创建文件然后写入数据
比如HtmCode是哪来的?
以上文字、图由易我秀输出,你也想这么酷吗?
http://www.eoshow.com/download/install1.html