salve. Ho la necessità di creare un file .csv da una tabella HTML. Ho trovato in rete del codice che sembra fare al caso mio:
ho caricato questa pagina nel server (si tratta di un plc, e la cartella /user/web è l'unica cui ho accesso per caricare le mie pagine web personali).codice:<html> <head> <script type="text/javascript"> function WriteCSVFile() { var x = myTable.rows var ForWriting = 2 var ForAppending = 8 var TriStateFalse = 0 var fsObj = new ActiveXObject("Scripting.FileSystemObject") var newFile = fsObj.OpenTextFile("/user/web/ClientSideJScriptFile.csv", ForWriting, true, TriStateFalse) for (i = 0; i < x.length; i++) { var y = x[i].cells var strTmp = y[0].innerText if (y.length > 0) { for (j = 1; j < y.length; j++) { strTmp = strTmp + "," + y[j].innerText } } newFile.WriteLine(strTmp) } newFile.Close() } </script> </head> <body lang=EN-US background="back.gif" link=blue vlink=purple> <form> <input type="button" onclick="WriteCSVFile()" value="Create CSV File"> </form> <% Put any table here, your little ol heart desireth If you change the id, you gotta change it in the script %> <table id="myTable" border="1"> <tr> <td>Abe </td> <td>23</td> </tr> <tr> <td>Betty </td> <td>34</td> </tr> <tr> <td>Carol </td> <td>56</td> </tr> <tr> <td>David </td> <td>24</td> </tr> <tr> <td>Edward</td> <td>16</td> </tr> <tr> <td>Floyd </td> <td>19</td> </tr> <tr> <td>Gary </td> <td>38</td> </tr> <tr> <td>Harold</td> <td>28</td> </tr> </table> </body> </html>
quando la eseguo, si verifica un errore: mi dice che non può creare l'oggetto ActiveX (Automation Server Can't create object). come posso risolvere il problema?

Rispondi quotando
