OWC: 在網頁中用SpreadSheet控制元件顯示Excel檔案 (CopyFromRecordset方法)

ilikeitpub3發表於2007-09-30

xlsOleDBConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + fn + ";"
+ "Extended Properties='Excel 8.0;IMEX=1';";

try {
oCon= new ActiveXObject("ADODB.Connection");
oCon.ConnectionString = xlsOleDBConnectionString;
oCon.Open ();

var oRst = new ActiveXObject( "ADODB.Recordset");
oRst =oCon.Execute ( "SELECT * FROM [EXPORTED DATA$]");

apsheet.Rows.CopyFromRecordset (oRst);
maxcolumn = oRst.Fields.Count;
oRst.Close ();
oCon.Close();
apsheet.Columns(1).ColumnWidth=10;
apsheet.Columns(2).ColumnWidth=10;
apsheet.Columns(3).ColumnWidth=10;

} catch (e)
{
window.alert ( e.message );
}

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11445597/viewspace-974116/,如需轉載,請註明出處,否則將追究法律責任。

相關文章