代码如下
- export const setIcon = (row, col, spread, params) => {
- const currentTemplateSheet = spread.getActiveSheetTab().getTemplate()
- // const style = new GC.Spread.Sheets.Style()
- console.log('style-info-----', currentTemplateSheet.getStyle(row, col))
- let style = currentTemplateSheet.getStyle(row, col)
- if (!style) {
- style = new GC.Spread.Sheets.Style()
- }
- const src =
- 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjRjBGN0ZGIiBkPSJNMCAxNlYwaDE2eiIvPjxwYXRoIGQ9Ik05LjkxIDIuMDkxYTEuMjE4IDEuMjE4IDAgMCAxIC4wOS40NTguNzE3LjcxNyAwIDAgMS0uMDUuMjYuNzkuNzkgMCAwIDEtLjE2LjI0OGMtLjA3OS4wOC0uMTUuMTUtLjIxMy4yMXMtLjExOC4xMTItLjE2NS4xNTljLS4wNTMuMDUzLS4xMDMuMS0uMTUuMTRMNy40IDEuNzAyYy4wOC0uMDczLjE3NS0uMTYxLjI4NC0uMjY0LjExLS4xMDMuMjAxLS4xODUuMjc0LS4yNDRBLjg3NS44NzUgMCAwIDEgOC41NDEgMWMuMDk2LjAwNC4xOS4wMTkuMjc5LjA0NS4wOS4wMjcuMTY3LjA1Ny4yMzQuMDkuMTQuMDczLjI5NC4yLjQ2My4zODMuMTcuMTgzLjMuMzc0LjM5My41NzN6bS03Ljc1OSA0Ljg2LjI4LS4yODNjLjE0NS0uMTUuMzI4LS4zMzQuNTQ3LS41NTNsLjcyNy0uNzI3LjgwNy0uODA3TDYuNjUzIDIuNDRsMS44NjMgMS44NzItMi4xNDEgMi4xNDItLjc5Ny44MDZjLS4yNjYuMjYtLjUwNS40OTctLjcxNy43MTNsLS41MjguNTMyYTQuMzA5IDQuMzA5IDAgMCAxLS40NzguNDI5Yy0uMDg3LjA2Ni0uMTc2LjEyLS4yNy4xNi0uMDkyLjA0Ni0uMjI4LjEwMi0uNDA4LjE2OGExMy44MDcgMTMuODA3IDAgMCAxLTEuMTIuMzU5IDQuMjI0IDQuMjI0IDAgMCAxLS4zOTQuMDljLS4xNzkuMDItLjI5OC0uMDA3LS4zNTgtLjA4cy0uMDc3LS4xOTYtLjA1LS4zNjlhMy4zNiAzLjM2IDAgMCAxIC4wOTUtLjQwM2MuMDUtLjE3Ni4xMDMtLjM1OS4xNTktLjU0OC4wNTYtLjE4OS4xMTEtLjM2My4xNjQtLjUyMy4wNTMtLjE1OS4wOTctLjI2OS4xMy0uMzI4LjA0LS4wOTMuMDg0LS4xNzguMTM0LS4yNTRhMS42NCAxLjY0IDAgMCAxIC4yMTQtLjI1NHoiIGZpbGw9IiMwMDYyRkYiIGZpbGwtcnVsZT0ibm9uemVybyIvPjwvZz48L3N2Zz4='
- if (!style.decoration) {
- style.decoration = {}
- }
- if (!style.decoration.icons) {
- style.decoration.icons = []
- }
- const editIconItem = style.decoration.icons.find((item) => item.type === 'REPORT_EDIT_CON')
- // 设置过的无需再设置
- if (editIconItem) {
- return
- }
- if (!style.decoration.icons.length) {
- style.decoration.icons[0] = {
- src,
- position: GC.Spread.Sheets.IconPosition.left,
- type: 'REPORT_EDIT_CON'
- }
- } else {
- style.decoration.icons.push({
- src,
- position: GC.Spread.Sheets.IconPosition.left,
- type: 'REPORT_EDIT_CON'
- })
- }
- if (params.type === 'Static') {
- style.decoration = undefined
- return
- }
- currentTemplateSheet.setStyle(row, col, style)
- }
复制代码 |