如何使用asp.net为单词生成代码? [英] how to generate code for word using asp.net?
本文介绍了如何使用asp.net为单词生成代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的先生,
如何使用asp.net生成Word文档(.doc)的代码?
答案给我.
通过解决方案
,我已经完成了一项任务,用于将上传的URL列表保存在文档中.希望对您有所帮助.
受保护的 void btnUpload_Click(对象发送者,EventArgs e) { 尝试 { // 获取HttpFileCollection HttpFileCollection hfc = Request.Files; for ( int i = 0 ; i < hfc.Count; i ++) { HttpPostedFile hpf = hfc [i]; 如果(hpf.ContentLength> 0 ) { hpf.SaveAs(Server.MapPath(" )+ " + System.IO.Path.GetFileName(hpf.FileName)); Response.Write(" + hpf.FileName + " + hpf.ContentLength + " + hpf.ContentType + " ); StreamWriter st = File.AppendText(" ); st.WriteLine(" + hpf.FileName + " ); st.WriteLine(" + hpf.ContentLength + " ); st.WriteLine(" + hpf.ContentType + " ); st.WriteLine(" + DateTime.Now.ToString()+ " ); st.WriteLine(" ); st.Close(); } } Response.Write(" + DateTime.Now.ToString()+ ); } 捕获(例外) { } }
dear sir,
how to generate code for word document(.doc) using asp.net?
Answer give me.
By mohan
解决方案
I have done one task for saving the list of uploaded files url inside a doc. I hope this might help you.
protected void btnUpload_Click(object sender, EventArgs e) { try { // Get the HttpFileCollection HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("MyFiles") + "\\" + System.IO.Path.GetFileName(hpf.FileName)); Response.Write("<b>File: </b>" + hpf.FileName + " <b>Size:</b> " + hpf.ContentLength + " <b>Type:</b> " + hpf.ContentType + "<br/>"); StreamWriter st = File.AppendText("C:\\SaveLink.doc"); st.WriteLine("File : " + hpf.FileName + ""); st.WriteLine("Size : " + hpf.ContentLength + ""); st.WriteLine("Type : " + hpf.ContentType + ""); st.WriteLine("Saved on : " + DateTime.Now.ToString()+""); st.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------------------------"); st.Close(); } } Response.Write("<br/>The link(s) saved successfully in <b> C:\\SaveLink.doc </b> on <b>" + DateTime.Now.ToString() + "</b> "); } catch (Exception ex) { } }
这篇关于如何使用asp.net为单词生成代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文