|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <title>Export To Excel with pure JavaScript</title> |
| 5 | + <link rel="icon" href="https://cdn0.iconfinder.com/data/icons/fatcow/32x32/table_excel.png" /> |
| 6 | + <link rel="stylesheet" href="style.css" /> |
| 7 | + </head> |
| 8 | + <body> |
| 9 | + <div> |
| 10 | + <table id="exTable" border="2"> |
| 11 | + <thead class="lockedRecordsBg"> |
| 12 | + <tr bgcolor='#87AFC6' style='height: 75px; text-align: center; width: 250px'> |
| 13 | + <th style="width:40px">S#</th> |
| 14 | + <th>name</th> |
| 15 | + <th>Email</th> |
| 16 | + <th>Phone</th> |
| 17 | + <th>Country</th> |
| 18 | + </tr> |
| 19 | + </thead> |
| 20 | + <tbody> |
| 21 | + <tr> |
| 22 | + <th>1</th> |
| 23 | + <td>Sudhir K Gupta</td> |
| 24 | + <td>test@test.com</td> |
| 25 | + <td>+91 45********</td> |
| 26 | + <td>India</td> |
| 27 | + </tr> |
| 28 | + <tr> |
| 29 | + <th style="height:0px">2</th> |
| 30 | + <td style="height:0px">This row will be hidden in excel</td> |
| 31 | + <td style="font-style:italic">Right click and unhide in excel</td> |
| 32 | + <td style="height:0px">+91 29********</td> |
| 33 | + <td style="height:0px">Denmark</td> |
| 34 | + </tr> |
| 35 | + <tr> |
| 36 | + <th>3</th> |
| 37 | + <td>Test 123</td> |
| 38 | + <td style="text-decoration: line-through;">line through text</td> |
| 39 | + <td style="background-color:blue;color:white" colspan="2"> bg = blue and color = white and merged column</td> |
| 40 | + </tr> |
| 41 | + <tr> |
| 42 | + <th>4</th> |
| 43 | + <td style="height: 150px"> |
| 44 | + <img |
| 45 | + src="https://avatars0.githubusercontent.com/u/4952560?s=460&v=4" |
| 46 | + height="85" |
| 47 | + width="100" |
| 48 | + alt="sample image" |
| 49 | + /> |
| 50 | + </td> |
| 51 | + <td style="font-weight:bold">test@gmail.com</td> |
| 52 | + <td></td> |
| 53 | + <td>USA</td> |
| 54 | + </tr> |
| 55 | + <tr> |
| 56 | + <th>5</th> |
| 57 | + <td>sp char - !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~</td> |
| 58 | + <td style="text-decoration: line-through;">like through text</td> |
| 59 | + <td>+91 29********</td> |
| 60 | + <td>Switzerland</td> |
| 61 | + </tr> |
| 62 | + <tr> |
| 63 | + <th>6</th> |
| 64 | + <td> |
| 65 | + Lorem Ipsum只是印刷和排版行业的伪文本<br /> |
| 66 | + Lorem Ipsum - просто фиктивный текст в полиграфии и вёрстке.<br /> |
| 67 | + Lorem Ipsum to po prostu fikcyjny tekst branży drukarskiej i składu. |
| 68 | + Lorem Ipsumは、印刷および植字業界の単なるダミーテキストです。 |
| 69 | + </td> |
| 70 | + <td>test@gmail.com</td> |
| 71 | + <td rowspan="2">Merge row 2 and 3</td> |
| 72 | + <td>India</td> |
| 73 | + </tr> |
| 74 | + <tr> |
| 75 | + <th>7</th> |
| 76 | + <td>Sudhir K Gupta</td> |
| 77 | + <td>test@gmail.com</td> |
| 78 | + <td style="color:red">Canada (color = red)</td> |
| 79 | + </tr> |
| 80 | + </tbody> |
| 81 | + </table> |
| 82 | + <input type="button" value="export" onclick="exportToExcel('exTable')" /> |
| 83 | + </div> |
| 84 | + <script src="exportToExcel.js" defer></script> |
| 85 | + </body> |
| 86 | +</html> |
0 commit comments