Работа с функцией выделения GridJs

Работа с функцией выделения GridJs

Мы поддерживаем указанные ниже API JS для функции выделения.

  • Включите выделение и установите стиль выделения. Все API выделения вступят в силу только после того, как стиль выделения будет установлен на активном листе.
xs.sheet.showHighlights(style)
 // the parameter is:
 style: the style for highlight ,currently only support color
 for example: {'color':'rgba(85, 57, 47, 0.08)'}
  • обновить стиль выделения, установленный на активном листе
xs.sheet.updateHighlightStyle(style)
 // the parameter is:
 style: the style for highlight ,currently only support color
 for example: {'color':'rgba(85, 57, 47, 0.08)'}
  • Отключить выделение на активном листе
xs.sheet.hideHighlights()
  • Добавьте текст ячейки, который нужно выделить на активном листе.
xs.sheet.addHighlightText(row,col,startpostion,endposition)
    // the parameters are:
	row:row index 
	col:column index
	startpostion: highlight start postion in cell text 
	endpostion: highlight end postion in cell text 
    //it support multiple range postion inside one cell
  • Удалить выделение текста ячейки в массиве на активном листе
xs.sheet.removeHighlightText(row,col,startpostion,endposition)
    // the parameters are:
	row:row index 
	col:column index
	startpostion: highlight start postion in cell text 
	endpostion: highlight end postion in cell text 
  • Получить массив для выделения текста ячейки на активном листе
xs.sheet.getHighlightTexts()
  • Добавьте диапазон ячеек, чтобы выделить его на активном листе.
xs.sheet.addHighlightRange(sri,sci,eri,eci)
    // the parameters are:
	sri:start row index of cell range
	sci:start column index of cell range
	eri:end row index of cell range
	eci:end column index of cell range
  • Удалить выделение диапазона ячеек в массиве на активном листе
xs.sheet.removeHighlightRange(sri,sci,eri,eci)
     // the parameters are:
	sri:start row index of cell range
	sci:start column index of cell range
	eri:end row index of cell range
	eci:end column index of cell range
  • Получить массив для выделения диапазона ячеек на активном листе
xs.sheet.getHighlightRanges()
  • Установить диапазон ячеек для инвертирования выделения на активном листе
xs.sheet.setHighlightInverseRange(sri,sci,eri,eci)
    // the parameters are:
	sri:start row index of cell range
	sci:start column index of cell range
	eri:end row index of cell range
	eci:end column index of cell range
  • Удалить выделение для инвертирования выделения на активном листе
xs.sheet.removeHighlightInverseRange()
     
  • Получить диапазон ячеек обратного выделения на активном листе
xs.sheet.getHighlightInverseRange()
  • Добавьте фигуру, чтобы выделить массив на активном листе
xs.sheet.addHighlightShape(shapeid)
    // the parameters are:
    shapeid: the id of shape, can be find in xs.sheet.data.shapes
  • Удалить форму выделения в массиве на активном листе
xs.sheet.removeHighlightShape(shapeid)
     // the parameters are:
    shapeid: the id of shape, can be find in xs.sheet.data.shapes
  • Получить массив для выделения формы на активном листе
xs.sheet.getHighlightShaps()
  • Добавьте текстовое поле для выделения, текстовое поле — это особый вид фигуры, свойство типа которого: «TextBox» на активном листе.
xs.sheet.addHighlightTextBox(shapeid, startpostion, endposition)
    // the parameters are:
    shapeid: the id of shape, can be find in xs.sheet.data.shapes whose type is 'TextBox'
    startpostion: highlight start postion in the text of textbox
    endpostion: highlight end postion in the text of textbox
    //it support multiple range postion inside one textbox
  • Удалить диапазон выделения в текстовом поле. Текстовое поле — это особый вид фигуры, свойство типа которого: «TextBox» на активном листе.
xs.sheet.removeHighlightTextBox(shapeid, startpostion, endposition)
    // the parameters are:
    shapeid: the id of shape, can be find in xs.sheet.data.shapes whose type is 'TextBox'
    startpostion: highlight start postion in the text of textbox
    endpostion: highlight end postion in the text of textbox
    //it support multiple range postion inside one textbox
  • Добавьте изображение, чтобы выделить массив на активном листе
xs.sheet.addHighlightImage(imageid)
    // the parameters are:
    imageid: the id of image, can be find in xs.sheet.data.images
  • Удалить выделенное изображение в массиве на активном листе
xs.sheet.removeHighlightImage(imageid)
     // the parameters are:
    imageid: the id of image, can be find in xs.sheet.data.images
  • Получить массив для выделения изображения
xs.sheet.getHighlightImages()
  • установите, следует ли выделять все объекты на активном листе, включать все фигуры и изображения, а также всю область рабочего листа
xs.sheet.setHighlightAll(ishighlightall,isrerender=true)
   // the parameters are:
   ishighlightall: true or false,whether to highlight all
   isrerender: true or false,whether to reRender
  • Установить функцию выделения пользовательского изображения
xs.sheet.setCustomHighlightImgFunc(func)
   // the parameters are:
   func: the custom highlight image function, it shall take two parameters ,first is ishighlight,the second one is the fabric image object 
   //we use fabric js to manage image object, please refer to http://fabricjs.com/image-filters to check more info
   below is an example for the decleare function: 
   const customHighlightImage = (ishighlight, imgobj) => {
            imgobj.filters[0] = ishighlight ? new fabric.Image.filters.Sepia() : false;
            imgobj.applyFilters();
        }
    
  • очистить настройку выделения для активного листа
xs.sheet.clearHighlights()

Выделение объекта текстового поля

текстовое поле — это особый вид фигуры, свойство типа которого: «TextBox», например: приведенный ниже код покажет, какая фигура является текстовым полем

for (let shape of xs.sheet.data.shapes) {
    if (shape.type === 'TextBox') {
        console.log(shape.id + ' is a textbox');
    }
}
  • Добавить выделение для объекта текстового поля
    addHighlight(startpostion,endposition)
    // the parameters are:
	startpostion: highlight start postion in textbox
	endpostion: highlight end postion in textbox

//for example,we assume shape 0 is a textbox object
const textbox=xs.sheet.data.shapes[0];
//first we shall add to highlight shape to enable the highlight for the textbox shape object,it support multiple range postion 
 xs.sheet.addHighlightShape(textbox.id);
 textbox.addHighlight(5,10);
 textbox.addHighlight(18,28);
  • Удалить выделение объекта текстового поля
    removeHighlight(startpostion,endposition)
    // the parameters are:
	startpostion: highlight start postion in textbox
	endpostion: highlight end postion in textbox
    //for example,we assume shape 0 is a textbox object
     const textbox=xs.sheet.data.shapes[0];
     textbox.removeHighlight(5,10);
  • Получить выделение для объекта текстового поля
    getHighlight()
    //for example,we assume shape 0 is a textbox object
     const textbox=xs.sheet.data.shapes[0];
     textbox.getHighlight();
  • Изменить цвет фона для объекта текстового поля
    setBackgroundColor(color)
    // the parameters are:
        color: the html color value in hex string value
    //for example,we assume shape 0 is a textbox object,this will set the background color to Yellow 
     const textbox=xs.sheet.data.shapes[0];
     textbox.setBackgroundColor('#FFFF00');
  • Автоматическое изменение цвета фона и цвета текста для получения визуального активного эффекта.
    setActiveEffect(boolvalue)
    // the parameters are:
        boolvalue: if true,will change background color and the text color of the textbox object;if false,restore to original appearence
  • скрыть/показать текстовое содержимое в объекте текстового поля
    hideText(boolvalue)
    // the parameters are:
        boolvalue: if true,will not display the text in the textbox object;if false,restore to original appearence

Вы можете найти больше на нашей демонстрационной странице GitHub https://github.com/aspose-cells/Aspose.Cells-for-.NET/blob/master/Examples_GridJs/wwwroot/xspread/index.html.