¼ÐÃD:
[¤À¨É]
Àò¨úexcel¤º®e¨ì¶±
[¥´¦L¥»¶]
§@ªÌ:
HHAAMM
®É¶¡:
2010-10-19 21:13
¼ÐÃD:
Àò¨úexcel¤º®e¨ì¶±
(«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
§@ªÌ:
HHAAMM
®É¶¡:
2010-10-19 21:47
¦^´_
1#
HHAAMM
[attach]3290[/attach]
§@ªÌ:
oobird
®É¶¡:
2010-10-19 21:57
ÁÂÁ¡A«Ü¤£¿ù¡A¨CÓ¤u§@ªí¤º®e³£§ì¥X¨Ó¤F¡C
¥Ø«eÁÙ¤£ª¾¹D§@¦ó¨Ï¥Î¡A¤U¦¸¸I¨ì¦³·lÃa¤å¥ó®É¸Õ¸Õ¯à¤£¯à§ì¥X¨Ó¡C
§@ªÌ:
HHAAMM
®É¶¡:
2010-10-19 22:16
«e¦~¡A³æ¦ìÅý½s¼gÓ¦b¤ººôùبϥΪººô¯¸¡A¬ðÀ»¤F¨âÓ¬P´Áªºasp«áÁ`ºâ¬Oµ¹¹ï¥I¥X¨Ó¤F¡C¦b¾Ç²ß¤¤·P¨ì¡A¦h¥Î¤_«È¤áºÝªºjavascript¬½¦³·N«ä¡A¤S¦]爲³ßÅwexcel¡A©Ò¥H¸ÕµÛ±N¨âªÌµ²¦X°_¨Ó¡C³oÓÀ³¸Ó¨S¦³¤°麽¹ê¥Î»ùȪº¡A½sµ{«ä¸ô¬O¥ÎADO³X°Ý¼Æ¾Ú®w¡A¨ä¹ê¬O¬½Â²³æªº¡C
§@ªÌ:
oobird
®É¶¡:
2010-10-20 00:04
«Ü¦n©_¡A¦³¬Ý¨ìrsTemp = objCon.OpenSchema(20);¤ÎobjCon.Close;
¨ì©³excel¦³¨S¦³¥´¶}¡H
Y·lÃa¤F¥¿±`µLªk¶}±Òªº¤å¥ó¯à§_¨ú¨ì¼Æ¾Ú¡H
Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)