zoukankan      html  css  js  c++  java
  • OWCA学习一

    现阶段学习的是OWC。(owc:Microsoft office web components组件)
    OWC由四部份组成:CharpSpace(图表),Spreadsheet(电子表格),数据透视表,还有一种需确认后再写上来。
    下面介绍简单的操作步骤,此全凭本人边学边写的一个sample,还请各位看官多多指教!小女子不胜感激!
    1、引入OWC组件。(右键单击工程名在下拉菜单中选择“add Reference...”,在弹出界面选择"COM",选择"Microsoft Office web components11.0",点击“ok”, 即可。),完成以上后就可以在工程的Reference下看到“OWC11”了。
    2、在页面中添加“using Microsoft.Office.Interop.Owc11;”;
    3、现在就可以在页面中添加一个相应的对象了。例如Spreadsheet: <object id="Spreadsheet1" classid=""></Object>" 就可以了。当然也可以在code部份new一个对象:“ Microsoft.Office.Interop.Owc11.Spreadsheet dd = new Microsoft.Office.Interop.Owc11.Spreadsheet();(在code中还没研究会怎么个用法。)”;
    4、这一步是用js写的。只是初步形成一个有数据的表格。在js code中添加一个load(),load中添加:
    Spreadsheet1.Activesheet.Cells(1,1).Value="第一格";
    Spreadsheet1.Activesheet.Cells(2,1).Value="第二格";  
    Spreadsheet1.Activesheet.Cells(3,1).Value="第三格"; 
    然后在body中加入 onload="return load()" 即:<body onload="return load()"> ;
    生成即可。
    上面写的是最简单的一个sample。
    整体代码如下:
     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     <html xmlns="http://www.w3.org/1999/xhtml" >

    <head id="Head1" runat="server">

        <title>Untitled Page</title>

         <script language="javascript">  

      

       

     function   onload()   {  

     alert("start");  

     

       var   Spreadsheet1   =   document.all("Spreadsheet1");  

       alert(Spreadsheet1);

       Spreadsheet1.ActiveSheet.Cells(1,1).Value="0.13"

       Spreadsheet1.ActiveSheet.Cells(1,2).Value="0.23"

       Spreadsheet1.ActiveSheet.Cells(1,3).Value="0.33"

       Spreadsheet1.ActiveSheet.Cells(1,4).Value="0.43"

        Spreadsheet1.ActiveSheet.Cells(2,1).Value="2.13"

       Spreadsheet1.ActiveSheet.Cells(2,2).Value="2.23"

       Spreadsheet1.ActiveSheet.Cells(2,3).Value="2.33"

       Spreadsheet1.ActiveSheet.Cells(3,4).Value="2.43"

        

       alert(Spreadsheet1.XMLData);

     alert("End");  

     }  

     </script>  

    </head>

    <body onload="return onload()">

        <form id="form1" runat="server">

        <div>

       

        </div>

        </form>

         <OBJECT   id="Spreadsheet1"   classid="clsid:0002E559-0000-0000-C000-000000000046"   name="Spreadsheet1" style="100%;height:421px" >  

       

     </OBJECT>

    </body>

    </html>

  • 相关阅读:
    Java测试代码及原理
    mysql性能调优
    markdown
    nginx
    触发器实际使用时容易碰到的几个小坑
    redis
    log4j
    Json
    导入工程报错The import android cannot be resolved
    mybatis小记
  • 原文地址:https://www.cnblogs.com/yiyisawa/p/1003978.html
Copyright © 2011-2022 走看看