if you save the html code from the aspx page as a html page on the server, and try to access it, what do you see?

解决方案 »

  1.   

    还是不好用!!!文件内容如下
    <HTML>
    <HEAD>
    <STYLE>
    <!--
    BODY  {font-family:TAHOMA}
    -->.btnItem {
       cursor: hand;
       font-size: 12;
       font-style: normal;
       background-color: DARKBLUE;
       color: khaki
     }.Selection{
       cursor:hand;
       font-size: 12;
       color: DARKBLUE;
    }.Desc{
       font-size: 12;
       color: DARKBLUE;
    }.Hilite{
       cursor:hand;
       font-size:12;
       color: IndianRed;
    }</STYLE>
    </HEAD>
    <BODY><TITLE>Microsoft Office Development Samples</TITLE><TABLE BORDER=0 WIDTH="100%">
    <TR>
    <TD WIDTH=100 VALIGN=TOP><FONT COLOR=DARKBLUE SIZE=2>
    Subject:</TD>
    <TD VALIGN=TOP><FONT COLOR=DARKBLUE SIZE=2><! --- ENTER SUBJECT HERE --- !>
    Loading and Saving Data with the Spreadsheet Component</TD>
    <TD ID="btnComments" CLASS=btnItem WIDTH="11%" ALIGN=CENTER><B>Comments</B></TD>
    </TR>
    <TR>
    <TD WIDTH=100 VALIGN=TOP><FONT SIZE=2 COLOR=DARKBLUE>Description:</TD>
    <TD VALIGN=TOP><FONT SIZE=2 COLOR=DARKBLUE><! --- ENTER DESCRIPTION HERE --- !>
    This sample demonstrates several methods for loading data into the Spreadsheet and saving the data in the Spreadsheet. Click <B>Comments</B> for more details on the methods illustrated in this sample.</TD>
    </TR>
    </TABLE><BR>
    <HR COLOR=DARKBLUE NOSHADE>
    <BR>
    <TABLE WIDTH="100%">
    <TR>
       <TD WIDTH="40%" COLSPAN=2 Class=Desc><B>Try the Following Methods for Loading Data: </B></TD>
       <TD WIDTH="10%"></TD>
       <TD WIDTH="50%" ROWSPAN=9><OBJECT classid=clsid:0002E510-0000-0000-C000-000000000046 
           id=Spreadsheet1 style="width=100%"></OBJECT></TD>
    </TR>
    <TR>
       <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
       <TD Class=Selection onclick="LoadData(0)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Load HTML data from a URL using the <B>HTMLURL</B> method.</TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="LoadData(1)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Load HTML data from a string using the <B>HTMLData</B> method.</TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="LoadData(2)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Load CSV data from a URL using the <B>CSVURL</B> method.</TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="LoadData(3)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Load CSV data from a string using the <B>CSVData</B> method.</TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="LoadData(4)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Load Text from a tab-delimited text file using the <B>LoadText</B> method.</TD>
    </TR>
    <TR>
       <TD COLSPAN=2 Class=Desc><B>Try the Following Methods for Saving Data: </B></TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="SaveData(0)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Save the Spreadsheet in an XML format using the <B>HTMLData</B> method and the FileSystemObject.</TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Selection onclick="SaveData(1)" onmouseover="MakeHilite()" onmouseout="MakeNormal()">Export the Spreadsheet to Excel using the <B>Export</B> method.
        </TD>
    </TR>
    <TR>
       <TD></TD>
       <TD Class=Desc> <I>Note: The <B>Export</B> method requires that Microsoft Excel 2000 be installed at the client.</I></TD>
    </TABLE><BR>
    <BR>
    <FONT COLOR=DARKBLUE SIZE=1><DIV ALIGN=RIGHT>Sample Provided by Microsoft Developer Support</DIV></FONT>
    </BODY><script language=vbscript>Dim strData
    Dim cSub Window_onLoad()     set c = Spreadsheet1.Constants
        Spreadsheet1.Cells.Clear
        Spreadsheet1.TitleBar.Caption = "Loading & Saving Data"End Sub'    This code runs any time the datasource type drop list is changed.
    '    It reloads the sheet with the selected type of DataSub LoadData(nDataType)
            
        Spreadsheet1.Cells.Clear
        sDBPath = window.showModalDialog("FindMDB.htm",, _
                        "dialogHeight:160px;dialogWidth:400px")       'If user hit Cancel, the sDBPath variable will be an empty string
             if len(sDBPath) = 0 then
             msgbox "你必须选择文件" & _
                   "及正确的文件类型.", vbcritical
            
             exit sub
            
             end if 'len(sDBPath) = 0
             
             
        ' Switch on the new data type
        select case nDataType

            case 0
         ' Load Data from html file specified in URL
         Spreadsheet1.DataType = "HTMLURL"
         Spreadsheet1.HTMLURL = (sDBPath) 
            case 1
         ' Load Data using HTMLData
         Spreadsheet1.DataType = "HTMLData"
         Spreadsheet1.HTMLData = "<TABLE>" & _
                                         "<TR>" & _
                                         "   <TD><B>Bold</B></TD><TD><I>Italic</I></TD>" & _
                                         "</TR>" & _
                                         "<TR>" & _
                                         "   <TD><U>Underline</U></TD><TD>Normal</TD>" & _
                                         "</TR>" & _
                                         "</TABLE>"
    case 2
         ' Load Data using a CSV file on the server
         Spreadsheet1.DataType = "CSVURL"
         Spreadsheet1.CSVURL = "..\data\csvdata.csv"        case 3
         ' Load Data using csv data by supplying hardcoded values 
         Spreadsheet1.DataType = "CSVData"
         Spreadsheet1.CSVData = "CSVData1" & ",CSVData2" & vbCrLf _
                                        & "CSVData3" & ",CSVData4" & vbCrLf _
                                        & "CSVData5" & ",CSVData6" 
        
            case 4
         ' Load Text from Tab delimited text file
         Spreadsheet1.DataType = "CSVURL"
         Spreadsheet1.LoadText "..\data\textFile.txt", vbTab

        end select    ' AutoFit the column widths for the new data
        Spreadsheet1.Refresh
        Spreadsheet1.ActiveSheet.UsedRange.AutoFitColumns
        Spreadsheet1.Range("A1").SelectEnd Sub Function SaveData(nDataType)    Select Case nDataType    Case 0:
            ' Save data using HTMLData to an xls file
            Dim ofs        'FileSystemObject
            Dim oTs        'TextStream
            Set ofs = CreateObject("Scripting.FileSystemObject")
            Set oTs = ofs.CreateTextFile("C:\HTMLData.xls")
            oTs.WriteLine Spreadsheet1.HTMLData
            oTs.Close
            Set oTs = Nothing
            Set fs = Nothing    
            MsgBox "Saved sheet as C:\HTMLData.xls"    Case 1:
            'Save the data using the Export method and display
            'the results in Excel
            On Error Resume Next
            SpreadSheet1.ActiveSheet.Export "C:\HTMLData.xls", c.ssExportActionOpenInExcel
            If Err<>0 Then
               MsgBox "Unable to Export to Excel."
            End If
            On Error GoTo 0
        End SelectEnd FunctionFunction btnComments_onclick()
       window.showmodaldialog "LoadSave_Comments.htm",,"dialogWidth:50em;help:no;status:no"
    End FunctionFunction MakeNormal() 
       Set src = window.event.fromElement
       if src.classname = "Hilite" then src.classname = "Selection"
    End functionFunction MakeHilite() 
       Set src = window.event.toElement
       if src.classname = "Selection" then src.classname = "Hilite"
    End Function</script></HTML>
      

  2.   

    主要是其中的LoadData(nDataType)函数。用于加载文件选择对话框中路径中的table.htm
    文件中的数据。 当你点击  “ Load HTML data from a URL using the HTMLURL method. “
    时开始执行。
                  Spreadsheet1.DataType = "HTMLURL"
         Spreadsheet1.HTMLURL = (sDBPath) 
    他在保存为单独的htm文件中时好用,但将相同的代码。也就是LoadData(nDataType)函数和Activex控件加到aspx页中就不好用了。加载的htm文件如下:格式不能变
      

  3.   

    **************加载的数据文件  table.htm************************
    <TABLE>
    <TR>
       <TD><FONT SIZE=3><B>Heading 1</B></FONT></TD>
       <TD><FONT SIZE=3><B>Heading 2</B></FONT></TD>
    </TR>
    <TR>
       <TD>Table Entry 1</TD>
       <TD>Table Entry 2</TD>
    </TR>
    <TR>
       <TD>Table Entry 3</TD>
       <TD>Table Entry 4</TD>
    </TR>
    </TABLE>
      

  4.   

    FindMDB.htm  内容是什么?
      

  5.   

    主文件存成aspx试了,可以用http://www.shufe.edu.cn/netedu/compapp/htmldoc/owc/Chap08/下载的吧?
      

  6.   

    FindMDB.htm  的内容如下:
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE>Open File</TITLE>
    </HEAD>
    <BODY style="background-color:buttonface;margin-left:5px;margin-right:5px;font-family:verdana;font-size=10pt"><P>Enter the file path to the Timesheets MDB file:</P>
    <p><INPUT size=40 type="file" id=txtPath></p><P align=right>
    <INPUT type="button" value="OK" id=btnOK style="WIDTH: 70px">
    <INPUT type="button" value="Cancel" id=btnCancel style="WIDTH: 70px">
    </p><script language=vbscript>
    Sub btnOK_onClick()
        window.returnValue = txtPath.value
        window.close 
    End SubSub btnCancel_onClick()
        window.returnValue = ""
        window.close 
    End SubSub txtPath_onKeyDown()
        select case window.event.keyCode
            case 13
                btnOK_onClick()
            case 27
                btnCancel_onClick()
                
        end select
    End Sub
    </script>
     
    </BODY>
    </HTML>
      

  7.   

    我的主文件存成aspx不可用,提示“不能读取别的主机的数据”快乐王子:你的怎么行了?
      

  8.   

    上次我不知道不能连续发送三个以上的回复无法写上FindMDB.htm  文件的内容。sorry sorry!!!
      

  9.   

    most likely,  ActiveX security settings on the client machine don't allow you
      

  10.   

    不允许ActiveX控件,进行这类操作