" /> 美女视频黄是免费的,黄色免费av网站,xxxx18国产

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

在MVC2.0使用Lodop為WEB打印提出完美解決方案

  通過(guò)好友CallHot介紹Lodopweb打印控件。由于是國(guó)人開(kāi)發(fā)的,故這兩天認(rèn)真了研究下,打算在未來(lái)的項(xiàng)目中使用。現(xiàn)將學(xué)習(xí)成果與園友分享。如果存在不足的地方,希望您指出。

  具體的實(shí)現(xiàn)步驟如下:

  一、準(zhǔn)備工作

   1.MVC2.0 + jQuery1.4.1 開(kāi)發(fā)環(huán)境。

  2.Lodop web 打印控件,官方地址:http://mtsoftware.v053.gokao.NET/download.html  (注:國(guó)人開(kāi)發(fā),免費(fèi)軟件)。

  3.StringTemplate,C#開(kāi)源模板引擎。官方地址:http://www.stringtemplate.org。

  本文主要給出WEB下打印步驟實(shí)現(xiàn)方案,具體的技術(shù)實(shí)現(xiàn)細(xì)節(jié),請(qǐng)查看官方API。lodop,stringtemplate 官方已給出了詳盡的文檔說(shuō)明。

  二、MVC2.0使用StringTemplate構(gòu)造打印模板

  StringTemplate 文中簡(jiǎn)稱st。網(wǎng)絡(luò)上有相關(guān)文檔介紹st效率還不錯(cuò)。本文將st作為報(bào)表打印模板。在實(shí)際項(xiàng)目開(kāi)發(fā)中將繁雜的報(bào)表打印工作內(nèi)容,部分分配給美工來(lái)處理。而開(kāi)發(fā)人員只需提供數(shù)據(jù)源接口。使用st可以減輕開(kāi)發(fā)人員的工作量。并將報(bào)表開(kāi)發(fā)任務(wù)分工更細(xì)致。給項(xiàng)目帶來(lái)的好處就不多論了。具體實(shí)現(xiàn)如下:

  1.在MVC2.0項(xiàng)目中引用st核心dll:

  2.建立st的模板文件,template.st(st模板專用文件):

  也可以認(rèn)為st文件就是一個(gè)普通的html文件。該部分主要由美工負(fù)責(zé)處理,比如CSS。

  3.在MVC2.0 controller 內(nèi)建立提供數(shù)據(jù)源的 JsonResult:

public JsonResult Print()
{
//構(gòu)造打印數(shù)據(jù)
List<CustomerTest> list = new List<CustomerTest>();
for (int i = 0; i < 100; i++)
{
list.Add(
new CustomerTest { CustomerName = "candy" + i, CustomerAddress = "思明區(qū)" + i, CustomerPhone = "13148484855" + i });
list.Add(
new CustomerTest { CustomerName = "linda" + i, CustomerAddress = "湖里區(qū)" + i, CustomerPhone = "13847487545" + i });
list.Add(
new CustomerTest { CustomerName = "ellie" + i, CustomerAddress = "海昌區(qū)" + i, CustomerPhone = "1359984665" + i });
}

//StringTemplate 打印模板文件,實(shí)際項(xiàng)目中為提高程序效率,應(yīng)將打印模板文件緩存。
string serverPath = System.Web.HttpContext.Current.Server.MapPath("~");
string path = Path.Combine(serverPath, @"PrintTemplate/");

StringTemplateGroup group
= new StringTemplateGroup("myGroup", path, typeof(TemplateLexer));
StringTemplate st
= group.GetInstanceOf("template");
st.SetAttribute(
"customer", list);

//為打印提供html相關(guān)超文本內(nèi)容。
StringBuilder sb = new StringBuilder();
sb.Append(
@"<html xmlns='http://www.w3.org/1999/xhtml' lang='zh-CN'>");
sb.Append(
"<head>");
sb.Append(
@"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />");
sb.Append(
@"<meta http-equiv='Content-Language' content='zh-CN' />");
string cssContent = System.IO.File.ReadAllText(Path.Combine(serverPath, @"Content/CSS/CSSForPrint.css"));
sb.Append(
@"<style type='text/css'>");
sb.Append(cssContent);
sb.Append(
@"</style>");
sb.Append(
"</head>");
sb.Append(
"<body>");
sb.Append(st.ToString());
sb.Append(
" ");
sb.Append(
"</body>");
sb.Append(
"</html>");

return Json(new { success = true, data = sb.ToString() }, JsonRequestBehavior.AllowGet);
}

NET技術(shù)在MVC2.0使用Lodop為WEB打印提出完美解決方案,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: www.56.com| 热天午后| 无影侦察队电影完整版免费| 绿野仙踪手抄报| 胸曝光| 内蒙古电视台| 感恩简谱钟丽燕| 吻戏陈伟霆| 水晶的作用与功效| 小戏骨| 盲辉| 林祖辉| 八哥图库图谜| 草逼操| 狗叫声吸引狗| 吴添豪与凤行剧照| 被打屁股作文| 糟老头视频| 搜狐视频官网| 应晖是谁演的| 德川家康的地狱| 熊出没免费电影| 夜生活女王之霞姐| 前线1942| 贤惠好儿媳在线观看完整版| 美女写真视频高清福利| 宋景诗| 绝战电视剧免费观看40集完整版| 王雪华| 男士专用山水画图片| 禁忌的恋爱关系一部| 员工的秘密| 2025小升初真题卷英语| 沈敏| 西海情歌歌词全文| 浙江省全省地图| 福圆美里| 国家级期刊目录| 零食店加盟免费品牌| 李亚红| 色在线视频|