prabhu p

prabhu p

  • 2k
  • 181
  • 98.1k

how to take print of div content in MVC

Feb 17 2018 6:05 AM
I am trying to take printout div content consist of many tables with <tr> <td> tags
it looke like table with row and column , but print preview coming with out column and row borders (i.e ) showing only data with out lines.
 
Please help on this 
 
View
//
 
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewTraveller</title>
<STYLE type="text/css">
table {
border: 1px solid black;
border-collapse: collapse;
width: 100%;
}
td {
border: 1px solid black;
border-collapse: collapse;
height: 20px;
#width:300px;
text-align: center;
font-size: 12px;
}
</STYLE>
<script type="text/javascript">
function PrintDiv() {
var divContents = document.getElementById("dvContents").innerHTML;
var printWindow = window.open('', '', 'height=200,width=400');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
}
</script>
</head>
<input type="button" onclick="PrintDiv();" value="Print" />
<div id="dvContents">
<BODY>
<table>
<table>
<tr>
<td width="150px"></td>
<td width="300px">@ViewBag.loadreport[0].STRESS_TEST - @ViewBag.loadreport[0].TEST_CODE </td>
<td width="456px">
@ViewBag.loadreport[0].STRESS_TEST
</td>
<td width="150px">SPEC: 25-00001</td>
</tr>
<tr>
</table>
<table>
<tr>
<td width="150px">REQUESTOR</td>
<td width="300px">REQUEST TYPE</td>
<td>ASSEMBLY LOT NO</td>
<td width="150px">MFG PART NO.</td>
<td width="150px">PACKAGE CODE</td>
<td width="150px">REL LAB ID</td>
</tr>
<tr>
<td width="150px">@ViewBag.loadreport[0].Requestor </td>
<td width="300px"> @ViewBag.loadreport[0].RequestorType </td>
<td width="150px">@ViewBag.loadreport[0].Assembly_LotNO </td>
<td width="150px">@ViewBag.loadreport[0].MFG_Part</td>
<td width="150px">@ViewBag.loadreport[0].Package_code</td>
<td width="150px"> @ViewBag.loadreport[0].Rel_LabId</td>
</tr>
<tr>
<td width="150px">EXTENSION# </td>
<td width="300px"> QTP/MONITOR# </td>
<td width="150px">INTERNAL DEVICE</td>
<td width="150px">MKT PART NO.</td>
<td width="150px">DATE</td>
<td> REQUEST NO.</td>
</tr>
<tr>
<td width="150px">@ViewBag.loadreport[0].TV</td>
<td width="300px">@ViewBag.loadreport[0].QTP</td>
<td width="150px">@ViewBag.loadreport[0].Internaldevice</td>
<td width="150px">@ViewBag.loadreport[0].MKT_part</td>
<td width="150px">@ViewBag.loadreport[0].date</td>S
<td>@ViewBag.loadreport[0].Request_NO </td>
</tr>
</table>
<table>
<tr>
<td width="150px">TEST_CONDITION</td>
<td width="412px">
<table>
@for (int i = 0; i < ViewBag.loadreport_TC.Count; i++)
{
<tr><td> @ViewBag.loadreport_TC[i].TEST_condition</td></tr>
}
@*<tr><td>CONDTION</td></tr>
<tr><td>VOLTAGE</td></tr>
<tr><td>CIRCUT_SPEC_NO</td></tr>
<tr><td>TEST_FLOW/MASTER_FILE</td></tr>*@
</table>
</td>
<td>
<table>
@for (int i = 0; i < ViewBag.loadreport_TC.Count; i++)
{
<tr><td> @ViewBag.loadreport_TC[i].TEST_value</td></tr>
}
@*<tr><td>@ViewBag.loadreport.condition</td></tr>
<tr><td>@ViewBag.loadreport.voltage</td></tr>
<tr><td>@ViewBag.loadreport.circuit_spec</td></tr>
<tr><td>@ViewBag.loadreport.TestFlowmaster_file</td></tr>*@
</table>
</td>
</tr>
</table>
<table>
<tr>
<td width="450px"></td>
<td width="150px">1</td>
<td width="150px">2</td>
<td width="150px">3</td>
<td width="150px">4</td>
</tr>
</table>
<table>
<tr>
<td width="150px">
<table>
<tr height="41"><td>DURATION / CYCLES</td></tr>
<tr height="41"><td>QUANTITY</td></tr>
<tr><td>STEPS_NAME</td></tr>
<tr><td>VERIFY_BOARDS</td></tr>
<tr height="40"><td>LOAD_BOARDS</td></tr>
<tr height="200"><td>RUN_EL_TEST</td></tr>
<tr height="40"><td>ELCTRICAL</td></tr>
<tr height="179"><td>CYCLED_DRB</td></tr>
</table>
</td>
<td>
<table>
<tr><td width="328px">CUMULATIVE READ POINT</td><td width="150px">READ_POINT_DURATION_1</td><td width="150px">READ_POINT_DURATION_2</td><td width="150px">READ_POINT_DURATION_3</td><td width="150px">READ_POINT_DURATION_4 </td></tr>
<tr><td width="328px">ACTUAL READ POINT</td><td width="150px"> VALUE=DURATION 1</td><td width="150px">VALUE=DURATION 2-DURATION 1</td><td width="150px">VALUE=DURATION 3-DURATION 2</td><td width="150px"> VALUE=DURATION 4-DURATION 3</td></tr>
<tr><td width="328px">TEST QUANTITY</td><td width="150px">QTY.</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">SAM QUANTITY</td><td width="150px">POST_CSAM_1_QTY</td><td width="150px">POST_CSAM_2_QTY</td><td width="150px">POST_CSAM_3_QTY</td><td width="150px">POST_CSAM_4_QTY</td></tr>
<tr><td width="328px">STEPS_CONDTIONS</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">BOARDS_VERIFIED_BY</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">UNITS_LOADED_BY</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ORIENTAION_CHK_BY</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">BOARD_TYPE</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">BOARD_NO.</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">SLOT_NO.</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">DRIVER_OR_CYCLER_NO</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">EQUIPMENT_NO.</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">MTS_SYSTEM_NO.</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ACTUAL_DATE_TIME_START</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">EMP_INTIALS_START</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ACTUAL_DATE_TIME_END</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">EMP_INTIALS_END</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">DB</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">FAILURE_MODE</td><td width="150px"></td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">RUN_CYCLED_DRB</td><td width="150px">DURATION / CYCLES</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">CYCLING</td><td width="150px">No._CYCLES_1</td><td width="150px">DATE/TIME START</td><td width="150px">DATE/TIME END</td><td width="150px">#END </td></tr>
<tr><td width="328px">ANNEAL_BAKE</td><td width="150px">BAKE_DURATION_1</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">CYCLING</td><td width="150px">No._CYCLES_2</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ANNEAL_BAKE</td><td width="150px">BAKE_DURATION_2</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">CYCLING</td><td width="150px">No._CYCLES_3</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ANNEAL_BAKE</td><td width="150px">BAKE_DURATION_3</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">CYCLING</td><td width="150px">No._CYCLES_4</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
<tr><td width="328px">ANNEAL_BAKE</td><td width="150px">BAKE_DURATION_4</td><td width="150px"></td><td width="150px"></td><td width="150px"> </td></tr>
</table>
</td>
</tr>
<table></table>
</td>
</tr>
</table>
</table>
</BODY>
</div>
</html>
// 
 

Answers (2)