日期:2014-05-16 浏览次数:20391 次
<html> <head><title></title></head> <body> <h1>js生成excel<h1> <script language=javascript> function preview() { window.clipboardData.setData("Text",document.all('table1').outerHTML); try { var ExApp = new ActiveXObject("Excel.Application") var ExWBk = ExApp.workbooks.add() var ExWSh = ExWBk.worksheets(1) ExApp.DisplayAlerts = false ExApp.visible = true } catch(e) { alert("您的电脑没有安装Microsoft Excel软件!") return false } ExWBk.worksheets(1).Paste; } </script> <table id="table1"> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td>6</td> <td>7</td> <td>8</td> <td>9</td> <td>0</td> </tr> <tr> <td>11</td> <td>12</td> <td>13</td> <td>14</td> <td>15</td> </tr> <tr> <td>16</td> <td>17</td> <td>18</td> <td>19</td> <td>20</td> </tr> <tr> <td>21</td> <td>22</td> <td>23</td> <td>24</td> <td>25</td> </tr> </table> <input type="button" value="生成" onclick="preview()"> </body> </html>