- ©«¤l
- 11
- ¥DÃD
- 3
- ºëµØ
- 0
- ¿n¤À
- 18
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-10-13
- ³Ì«áµn¿ý
- 2010-12-5
|
(«e´£¡G§An¤¹³\浏Äý¾¹³X°Ý¥»¦a)- <html>
- <head>
- <title>Untitled Page</title>
- </head>
- <script language="javascript" type="text/javascript">
- function importXLS(fileName)
- {
- objCon = new ActiveXObject("ADODB.Connection");
- objCon.Provider = "Microsoft.Jet.OLEDB.4.0";
- objCon.ConnectionString = "Data Source=" + fileName + ";Extended Properties=Excel 8.0;";
- objCon.CursorLocation = 1;
- objCon.Open;
- var strQuery;
- var strSheetName = "Sheet1$";
- var rsTemp = new ActiveXObject("ADODB.Recordset");
- rsTemp = objCon.OpenSchema(20);
- while(!rsTemp.EOF)
- {
- if (rsTemp("TABLE_TYPE")=="TABLE")
- {
- //alert(rsTemp("TABLE_NAME"));
- rsExcel = new ActiveXObject("ADODB.Recordset");
- strQuery = "SELECT * FROM [" + rsTemp("TABLE_NAME") + "]";
- rsExcel.ActiveConnection = objCon;
- rsExcel.Open(strQuery);
- mm=rsTemp("TABLE_NAME")+"ªí内®e<br><table border='1' cellspacing='0' cellpadding='0'>"
- for(i = 0;i<rsExcel.Fields.Count;++i)
- {
- mm=mm+"<td>"+rsExcel.Fields(i).name+"</td>";
- }
- while(!rsExcel.EOF)
- {
- mm=mm+"<tr>"
- for(i = 0;i<rsExcel.Fields.Count;++i)
- {
- mm=mm+"<td>"+rsExcel.Fields(i).value+"</td>";
- }
- mm=mm+"</tr>"
- rsExcel.MoveNext;
- }
- }
- document.write(mm+"</table><br>")
- mm=""
- rsExcel = null
- rsTemp.MoveNext;
- }
- objCon.Close;
- objCon =null;
- rsExcel = null;
- }
- </script>
- </head>
- <body>
- <input type="file" id="f" />
- <input type="button" id="b" value="Åã¥Ü¤u§@鷺®e" onClick="if(f.value=='')alert('½Ð¿ï¾Üxls¤å¥ó');else importXLS(f.value)" />
- </body>
- </html>
½Æ»s¥N½X |
|