报表控件操作的一些代码(以备忘记)

 1.插入表

//(在当前的表后面插入)

function WebAddSheet()
            {
              try{
                var Sheets = webform.WebOffice.WebObject.Application.Sheets;
               Sheets(1).Select();
               Sheets.Add(null,Sheets(Sheets.Count));

                //下面是移动表到某个表后面
               // Sheets(Sheets.Count).Select();
               //Sheets(1).Move(null,Sheets(Sheets.Count));
              }
              catch(e){
                alert(e.description);
              }
            }

//在前面插入

function AddSheet()
            {
            //Sheets("Sheet1").Select
                //var After;
                for(var i=0;i<10;i++)
                {
                    webform.WebOffice.WebObject.Sheets.Add();
               
                    webform.WebOffice.WebObject.ActiveSheet.Name="表"+ i;
                }
            }

2. 插入行

function InsertRow()
            {
                webform.WebOffice.WebObject.Application.Range("5:5").Select();
                webform.WebOffice.WebObject.Application.Selection.EntireRow.Insert();
            }

3.复制单元格或某区域

function CopyCell()
            {
               
               webform.WebOffice.WebObject.Sheets("Sheet1").Select;
               webform.WebOffice.WebObject.Application.Range("A1:M50").Select;
               // Range("F9").Activate
               webform.WebOffice.WebObject.Application.Selection.Copy;
               // webform.WebOffice.WebObject.Selection.Copy;
                webform.WebOffice.WebObject.Sheets("Sheet2").Select;
                webform.WebOffice.WebObject.ActiveSheet.Paste;
                
            }

4.选择某个SHEET

function SelSheet(num)
            {
                webform.WebOffice.WebObject.sheets(num).select;
            }

5.拷贝某个表并复制为最后一个SHEET

function CopySheet()
            {
                var Sheets = webform.WebOffice.WebObject.Application.Sheets;
                webform.WebOffice.WebObject.Sheets(Sheets.Count).Select();
                webform.WebOffice.WebObject.Sheets(Sheets.Count).Copy(null,Sheets(Sheets.Count));
            }

6.图表

 function WebCreateCharts(){
              try{
               for(var i=7;i<20;i++)
                {
                    webform.WebOffice.WebObject.Application.Range("C"+i).Select;
                    webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 =i+"段"; 
                    webform.WebOffice.WebObject.Application.Range("D"+i).Select;
                    webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 =i;  
                }
                var Charts = webform.WebOffice.WebObject.Application.Charts;
                webform.WebOffice.WebObject.Application.Charts.Add;
               
                var ActiveChart = webform.WebOffice.WebObject.Application.ActiveChart;

                webform.WebOffice.WebObject.Application.ActiveChart.ChartType = 51;
                webform.WebOffice.WebObject.Application.ActiveChart.SetSourceData(webform.WebOffice.WebObject.Application.Sheets.Item("Sheet2").Range("C7:D19"),2);
                webform.WebOffice.WebObject.Application.ActiveChart.Location(2,"Sheet2");
                 webform.WebOffice.WebObject.Application.ActiveChart.HasTitle = true;
                webform.WebOffice.WebObject.Application.ActiveChart.ChartTitle.Characters.Text = "测试图表";
                webform.WebOffice.WebObject.Application.ActiveChart.Axes(1, 1).HasTitle = false;
                webform.WebOffice.WebObject.Application.ActiveChart.Axes(2, 1).HasTitle = false;
              }
              catch(e){
                alert(e.description);
              }
            }

具体功能尚未测试

你可能感兴趣的:(报表控件操作的一些代码(以备忘记))