<link href="../css/cssprint.css" rel="stylesheet" />
<script src="../Lodop/LodopFuncs.js"></script>
<style id="style1">
table {
font-size: 9pt;
font-weight: normal;
color: #000000 ;
text-decoration: none;
}
td {
font-size: 9pt;
font-weight: normal;
color: #000000 ;
text-decoration: none;
}
.printfont{ font-size: 9pt;
font-weight: normal;
color: #000000 ;
text-decoration: none; }
</style>
<script type="text/javascript">
var LODOP; //声明为全局变量 function PreviewMytable() {
LODOP = getLodop();
LODOP.PRINT_INIT("预览打印表格");
LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4"); LODOP.ADD_PRINT_TEXT(10, 410, 300, 30, "国 电 吉 林 热 电 厂")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1); LODOP.ADD_PRINT_TEXT(60, 20, 550, 50, "单位:<%=DropDownList1.SelectedItem.Text.ToString()%> (<%=numPerson%>人)")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1); LODOP.ADD_PRINT_TEXT(55, 370, 550, 50, "<%=DropDownList3.SelectedItem.Text.ToString()%> 年 <%=DropDownList4.SelectedItem.Text.ToString()%> 月 份 考 勤 记 录 簿")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 16);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1); LODOP.ADD_PRINT_TEXT(60, 800, 150, 30, "<%=DropDownList3.SelectedItem.Text.ToString()%>年 <%=DropDownList4.SelectedItem.Text.ToString()%>月<%=monthLastDay%>日")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1); LODOP.ADD_PRINT_TEXT(740, 80, 250, 30, "注:出勤“/”,串休“φ”。")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
LODOP.SET_PRINT_STYLEA(0, "Bold", 0); LODOP.ADD_PRINT_TEXT(740, 510, 120, 30, "单位领导:")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
LODOP.SET_PRINT_STYLEA(0, "Bold", 0); LODOP.ADD_PRINT_TEXT(740, 850, 120, 30, "考勤员:")
LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
LODOP.SET_PRINT_STYLEA(0, "Bold", 0); var strBodyStyle = "<style>" + document.getElementById("style1").innerHTML + "</style>";
var strFormHtml = strBodyStyle + "<body>" + document.getElementById("div1").innerHTML + "</body>";
LODOP.ADD_PRINT_TABLE(80, 15, "28cm", "17cm", strFormHtml);
LODOP.SET_PRINT_STYLEA(0, "TableHeightScope",1);
LODOP.PREVIEW();
}; </script>
关键这句
var strBodyStyle = "<style>" + document.getElementById("style1").innerHTML + "</style>";
var strFormHtml = strBodyStyle + "<body>" + document.getElementById("div1").innerHTML + "</body>"; 把样式带进来