使用FCKeditor将编辑好的内容存入数据库,如何生成word并下载

superzjd1 2010-01-14 09:53:21
使用FCKeditor将编辑好的内容存入数据库,怎么才能生成word,并且下载呢?
关键点1. FCKeditor将编辑好的内容里面有很多html标签,也存储在库中,生成word时怎么处理这些标签?
关键点2. FCKeditor将编辑好的内容中含有图片,而且是路径信息,该如何处理?
关键点3. 如果问题1和2能够解决,又如何实现批量下载呢,最好可以压缩为一个winrar文件?
请高手帮助,谢谢
...全文
414 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
l6022258 2011-11-02
  • 打赏
  • 举报
回复
不了解mark下以后研究
java5506113 2010-11-30
  • 打赏
  • 举报
回复
马克一下 ,今晚再看
zerolost0413 2010-08-23
  • 打赏
  • 举报
回复
学习了
superzjd1 2010-01-14
  • 打赏
  • 举报
回复
谢谢关注啊
XZerg 2010-01-14
  • 打赏
  • 举报
回复
1楼强悍,我不懂,帮顶
superzjd1 2010-01-14
  • 打赏
  • 举报
回复
首先,谢谢楼上大侠帮助啊,不过还有第2个和第3个问题没有思路啊
zzxap 2010-01-14
  • 打赏
  • 举报
回复
存入数据库只要 HttpUtility.HtmlEncode(FCKeditor1.Value);
显示 HttpUtility.HtmlDecode(FCKeditor1.Value);

生成word时用正则去掉html代码。
/// <Header> /// 去除 HTML tag
/// </Header>
/// <param name="HTML">源</param>
/// <returns>结果</returns>
public static string StripHTML(string HTML) //google "StripHTML" 得到
{ string[] Regexs =
{
@"<script[^>]*?>.*?</script>",
@"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
@"([\r\n])[\s]+",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(lt|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(cent|#162);",
@"&(pound|#163);",
@"&(copy|#169);",
@"&#(\d+);",
@"-->",
@"<!--.*\n"
};

string[] Replaces =
{
"",
"",
"",
"\"",
"&",
"<",
">",
" ",
"\xa1", //chr(161),
"\xa2", //chr(162),
"\xa3", //chr(163),
"\xa9", //chr(169),
"",
"\r\n",
""
};

string s = HTML;
for (int i = 0; i < Regexs.Length; i++)
{
s = new Regex(Regexs[i], RegexOptions.Multiline | RegexOptions.IgnoreCase).Replace(s, Replaces[i]);
}
s.Replace("<", "");
s.Replace(">", "");
s.Replace("\r\n", "");
return s;
}
}

一个批量下载图片的c#类

.Net 学习 2009-12-28 17:44 阅读38 评论0
字号: 大 中 小
using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6
7namespace DownloadImagebyXMLListFor2008
8{
9 public class HttpDownLoad
10 {
11 /**//// <summary>
12 /// HttpWebRequest Property
13 /// </summary>
14 /// <param name="fileName"></param>
15 /// <param name="url"></param>
16 /// <param name="localPath"></param>
17 /// <param name="timeout"></param>
18 public static void DownloadOneFileByURL(string fileName, string url, string localPath, int timeout)
19 {
20 System.Net.HttpWebRequest request = null;
21 System.Net.HttpWebResponse response = null;
22 request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url + fileName);
23 request.Timeout = timeout;//8000 Not work ?
24 response = (System.Net.HttpWebResponse)request.GetResponse();
25 Stream s = response.GetResponseStream();
26 BinaryReader br = new BinaryReader(s);
27 //int length2 = Int32.TryParse(response.ContentLength.ToString(), out 0);
28 int length2 = Int32.Parse(response.ContentLength.ToString());
29 byte[] byteArr = new byte[length2];
30 s.Read(byteArr, 0, length2);
31 if (File.Exists(localPath + fileName)) { File.Delete(localPath + fileName); }
32 if (Directory.Exists(localPath) == false) { Directory.CreateDirectory(localPath); }
33 FileStream fs = File.Create(localPath + fileName);
34 fs.Write(byteArr, 0, length2);
35 fs.Close();
36 br.Close();
37 }
38 /**//// <summary>
39 ///Web Client Method ,only For Small picture,else large please use FTP
40 /// </summary>
41 /// <param name="fileName"></param>
42 /// <param name="url"></param>
43 /// <param name="localPath"></param>
44 public static void DownloadOneFileByURLWithWebClient(string fileName, string url, string localPath)
45 {
46 System.Net.WebClient wc = new System.Net.WebClient();
47 if (File.Exists(localPath + fileName)) { File.Delete(localPath + fileName); }
48 if (Directory.Exists(localPath) == false) { Directory.CreateDirectory(localPath); }
49 wc.DownloadFile(url + fileName, localPath + fileName);
50 }
51 }
52}
53
需要注意点:

第一 DownloadOneFileByURL方法,有时会下载不了文件,如果文件大于40K就更明显,DownloadOneFileByURLWithWebClient则无此问题。当然,这个大文件也是相对的,如果真的large或huge,请参考FTP。


http://www.cnblogs.com/downmoon/archive/2008/01/29/1057726.html

第二 调用时请用Thread,给出一个示例
1 private void btnGet_Click(object sender, EventArgs e)
2 {
3 if (txtTempFile.Text.Trim().Length == 0)
4 {
5 ErrorStop("列表文件为空!"); return;
6 }
7 System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(DownloadAll));
8 thread.Start();
9 }
10 private void DownloadAll()
11 {
12 List<string> ls = GetStringsByFile(txtTempFile.Text.Trim());
13 if (null != ls)
14 {
15
16 foreach (string s in ls)
17 {
18 try
19 {
20 //HttpDownLoad.DownloadOneFileByURL(s, Globals.HttpPreUrl, Globals.LocalPrePath, 8000000);
21 HttpDownLoad.DownloadOneFileByURLWithWebClient(s, Globals.HttpPreUrl, Globals.LocalPrePath);
22 }
23 catch { continue; }
24 }
25 }
26 }
附 WebClient类的说明 
http://msdn.microsoft.com/zh-cn/library/system.net.webclient(VS.80).aspx

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧