SpreadJS学习笔记03-初始化、标签名、滚动条

2019-03-22  本文已影响0人  小FFF

初始化SpreadJS

//初始化Spread
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 2 });
    

表单

    /*------------------Spread表单--------------------------*/
    spread.addSheet(0);  
    console.log(spread.getSheetCount()); // 3
    spread.setSheetCount(1);
    console.log(spread.getSheetCount()); // 3 初始化时创建了两个
    var sheet = spread.getSheet(0);
    var sheet1 = spread.getSheetFromName('Sheet3'); 
    console.log (sheet == sheet1);  // 结果:True,此时我页面的 索引为0 的sheet 名字叫 Sheet3
    // spread.removeSheet(0); 
    // spread.clearSheets(); // 清空了,一片空白
    spread.setSheetCount(4);
    console.log(spread.getActiveSheetIndex()); // 获取活动表单索引
    spread.setActiveSheetIndex(3); // 设置活动表单


表单名称标签

    /*------------------表单名称标签--------------------------*/
    // spread.options.tabStripVisible = false; // 标签条 显示控制
    // spread.options.newTabVisible = false;
    var curSheet = spread.getActiveSheet();
    //curSheet.options.sheetTabColor = 'blue'; // 设置当前sheetTab 背景颜色,
    spread.options.tabEditable = true; // 双击是否可修改表单名称
    spread.options.allowSheetReorder = false; // 是否可通过拖拽调整表单顺序
    // spread.startSheetIndex(1); // 设置起始的sheet的索引
    spread.options.tabStripRatio = 0.8; // 设置TabStrip的宽度,取值0-1

滚动条

 /*------------------滚动条--------------------------*/
    //horizontal,vertical;both;none 拖动滚动条给出提示,默认none
    spread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal; 
    spread.options.showVerticalScrollbar = true; // 控制水平或竖直滚动条是否显示 showVerticalScrollbar,showHorizontalScrollbar 
    spread.options.scrollbarShowMax = true; // 是否基于表单全部的行列总数显示滚动条
    spread.options.scrollbarMaxAlign = true; //滚动条末尾是否对齐视图中表单的最后一行或一列 

背景

  /*------------------背景---------------------------*/
    //  spread.options.backColor = 'red';
    //spread.options.backgroundImage = 'img/bag.jpg';  //同时设置,图片优先
    //spread.options.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.stretch; //stretch,center,zoom,none
    spread.options.grayAreaBackColor = 'red';// 配合spread.options.scrollbarMaxAlign = false 使用

Spread事件

/*------------------Spread事件---------------------------*/
    var activeSheetChanged = GC.Spread.Sheets.Events.ActiveSheetChanged;
    spread.bind(activeSheetChanged,function(){
        console.log('activeSheetChanged');
    })
    // spread.suspendEvent(); // 暂停触发事件
    // spread.resumeEvent();  // 恢复触发事件
    var SelectionChanging = GC.Spread.Sheets.Events.SelectionChanging;
    spread.bind(SelectionChanging,function(){
        console.log('SelectionChanging');
    })
    var CellClick = GC.Spread.Sheets.Events.CellClick;
    spread.bind(CellClick,function(){
        console.log('CellClick');
    })
    var SelectionChanged = GC.Spread.Sheets.Events.SelectionChanged;
    spread.bind(SelectionChanged,function(){
        console.log('SelectionChanged');
    })
    var EditStarting = GC.Spread.Sheets.Events.EditStarting;
    spread.bind(EditStarting,function(){
        console.log('EditStarting');
    })
    var EditEnded = GC.Spread.Sheets.Events.EditEnded;
    spread.bind(EditEnded,function(){
        console.log('EditEnded');
    })
上一篇下一篇

猜你喜欢

热点阅读