FineUI 官方论坛
标题:
建议搞个关于打印的事例
[打印本页]
作者:
舞柯庶
时间:
2016-1-26 16:32
标题:
建议搞个关于打印的事例
现在很多业务都需要打印出来,建议三石能够给个 打印的事例,
一般样式 上面是Form表头,显示几行数据,下面是grid明细
当然高手也可以给点指点,最好能有图片!
作者:
wx_F5391q87
时间:
2016-2-24 15:42
本帖最后由 wx_F5391q87 于 2016-2-24 15:53 编辑
<script type="text/javascript">
var lbtest = '<%=lbtest.ClientID%>';
var lbHaveNameText = '<%=lbHaveName.Text%>';
var lbOutTimeText = '<%=lbOutTime.Text%>';
var lbCreatByText = '<%=lbCreatBy.Text%>';
var lbInOutRemarkText = '<%=lbInOutRemark.Text%>';
var lbCheckNameText = '<%=lbCheckName.Text%>';
var lbCarCountText = '<%=lbCarCount.Text%>';
var lbCarCodeText = '<%=lbCarCode.Text%>';
var lbOutMadeNameText = '<%=lbOutMadeName.Text%>';
var lbNoText = '<%=lbNo.Text%>';
var Grid1ID = '<%=Grid1.ClientID%>';
var htmltable = '<%=htmGrid1.Text%>';
var lbDoorByText = '<%=lbDoorBy.Text%>';
var lbrowsnum = '<%=lbrowsNum.Text%>';
var lbtestid = '<%=lbtest.ClientID%>';
var LODOP=getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
var LODOP;
var linenum = 250;
var rows = linenum;
function myDesign() {
CreatePreview();
LODOP.PRINT_DESIGN();
};
function myPrint() {
CreatePreview();
LODOP.PREVIEW();
};
function SaveAsFile() {
CreatePreview();
LODOP.SET_SAVE_MODE("Orientation", 1); //Excel文件的页面设置:横向打印 1-纵向,2-横向;
LODOP.SET_SAVE_MODE("PaperSize", 9); //Excel文件的页面设置:纸张大小 9-对应A4
LODOP.SET_SAVE_MODE("Zoom", 90); //Excel文件的页面设置:缩放比例
LODOP.SET_SAVE_MODE("CenterHorizontally", true);//Excel文件的页面设置:页面水平居中
LODOP.SET_SAVE_MODE("CenterVertically", true); //Excel文件的页面设置:页面垂直居中
// LODOP.SET_SAVE_MODE("QUICK_SAVE",true);//快速生成(无表格样式,数据量较大时或许用到)
LODOP.SAVE_TO_FILE("新文件名.xls");
};
function CreatePreview() {
AddTitle();
var strBodyStyle = "<style>table {border: 1px solid #000000;border-collapse:collapse;}td {border: 1px solid #000000;border-collapse:collapse;width:200px;}</style>";
var strFormHtml = strBodyStyle+"<body>" + htmltable + "</body>";
LODOP.ADD_PRINT_HTM(250, "2%", "95%", 600, strFormHtml);
//window.setTimeout(LODOP.ADD_PRINT_HTM(88, 200, 350, 600, F(htmlGrid111)), 100);
AddBottom();
};
作者:
wx_F5391q87
时间:
2016-2-24 15:43
function AddTitle() {
LODOP.PRINT_INIT("物资出厂证打印");
LODOP.ADD_PRINT_TEXT(37, 96, 289, 28, "XXXXXXXXXXXXXXXX公司");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
LODOP.ADD_PRINT_TEXT(32, 385, 153, 42, "物资出厂证");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
LODOP.ADD_PRINT_BARCODE(10, 585, 100, 100, "QRCode", lbrowsnum);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
LODOP.SET_PRINT_STYLEA(0, "QRCodeVersion", 3);
LODOP.SET_PRINT_STYLEA(0, "DataCharset", "UTF-8");
LODOP.ADD_PRINT_TEXT(136, 9, 90, 26, "收货单位:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(162, 95, 163, 513, 0, 1);
LODOP.ADD_PRINT_TEXT(135, 102, 408, 26, lbHaveNameText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(133, 544, 40, 30, "NO.");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
LODOP.ADD_PRINT_TEXT(135, 587, 172, 26, lbNoText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(162, 581, 163, 759, 0, 1);
LODOP.ADD_PRINT_TEXT(173, 7, 90, 26, "发货货场:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(172, 100, 140, 26, lbOutMadeNameText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(199, 93, 200, 242, 0, 1);
LODOP.ADD_PRINT_TEXT(166, 573, 170, 26, "发货单位(盖章)");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(213, 7, 90, 26, "进出说明:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(212, 100, 659, 26, lbInOutRemarkText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(239, 93, 240, 756, 0, 1);
LODOP.ADD_PRINT_TEXT(173, 240, 61, 26, "车号:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(172, 302, 99, 26, lbCarCodeText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(199, 295, 200, 403, 0, 1);
LODOP.ADD_PRINT_TEXT(172, 402, 61, 26, "车数:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_TEXT(171, 464, 47, 26, "壹");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.ADD_PRINT_LINE(198, 457, 199, 516, 0, 1);
};
function AddBottom(){
LODOP.ADD_PRINT_TEXT(420, 19, 85, 30, "审核人:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_TEXT(420, 105, 95, 30, lbCheckNameText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_LINE(451, 101, 450, 201, 0, 1);
LODOP.ADD_PRINT_TEXT(420, 269, 85, 30, "创建者:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_TEXT(420, 355, 90, 30, lbCreatByText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_LINE(451, 347, 450, 447, 0, 1);
LODOP.ADD_PRINT_TEXT(420, 527, 106, 30, "门岗人员:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_TEXT(420, 634, 90, 30, lbDoorByText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_LINE(451, 626, 450, 726, 0, 1);
LODOP.ADD_PRINT_TEXT(464, 366, 106, 30, "发货日期:");
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_TEXT(464, 473, 283, 30, lbOutTimeText);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.ADD_PRINT_LINE(495, 465, 494, 757, 0, 1);
};
</script>
</body>
作者:
wx_F5391q87
时间:
2016-2-24 15:43
本帖最后由 wx_F5391q87 于 2016-2-24 15:54 编辑
private string GetGridTable()
{
StringBuilder sb = new StringBuilder();
//sb.AppendFormat("<div id={0}>", "div1");
sb.Append("<table>");
sb.Append("<tr>");
foreach (GridColumn column in Grid1.Columns)
{
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
}
sb.Append("</tr>");
foreach (GridRow row in Grid1.Rows)
{
sb.Append("<tr>");
foreach (GridColumn column in Grid1.Columns)
{
string html = row.Values[column.ColumnIndex].ToString();
sb.AppendFormat("<td>{0}</td>", html);
}
sb.Append("</tr>");
}
sb.Append("</table>");
//sb.Append("</div>");
return sb.ToString();
}
}
}
作者:
wx_F5391q87
时间:
2016-2-24 15:45
这个是我自己写的,用的是LODOP打印控件,可以实现你说的。代码写的不好,你可以自己改改!希望对你有帮助
作者:
狐狸猫
时间:
2016-3-18 20:25
wx_F5391q87 发表于 2016-2-24 15:45
这个是我自己写的,用的是LODOP打印控件,可以实现你说的。代码写的不好,你可以自己改改!希望对你有帮助 ...
你好 我要打印票据 例如 grid里有几列:票号 票型 票价 出票人 然后一共10行数据 打印的时候要一次打印这10张 每张的格式都一样 只是这几列的数据内容不一样 这个怎么搞 求助
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4