使用电子表格控件SpreadJS定制外观(四):如何为文字添加上划线、删除线和处理溢出

SpreadJS最新试用版

设置文本的上划线,删除线和下划线

Spread.Sheets 支持文本修饰属性。你可以使用方法设置文本的上划线,删除线和下划线。

使用电子表格控件SpreadJS定制外观(四):如何为文字添加上划线、删除线和处理溢出

示例代码

以下代码给位于 (0,0)的单元格中的文字加入了一条上划线, 给位于(1,0)单元格中的文字加了下划线和上划线,给位于 (0,1)单元格中的文字加了下划线,删除线和上划线。

activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Underline);activeSheet.getRange(1, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.Underline);activeSheet.getRange(-1, 1, -1, 1, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.LineThrough | GC.Spread.Sheets.TextDecorationType.Underline);var style = new GC.Spread.Sheets.Style();style.textDecoration = GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.Underline;activeSheet.setStyle(1, 1, style, GC.Spread.Sheets.SheetArea.viewport);activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).value("Test");activeSheet.getCell(1, 0, GC.Spread.Sheets.SheetArea.viewport).value("Test");activeSheet.getCell(0, 1, GC.Spread.Sheets.SheetArea.viewport).value("Test");

允许文字溢出

你可以使用options.allowCellOverflow属性来设置当单元格中的文字的长度较长时,是否溢出到相邻的单元格中。

使用电子表格控件SpreadJS定制外观(四):如何为文字添加上划线、删除线和处理溢出

示例代码

以下代码设置了单元格的对齐方式,并且也设置了允许单元格溢出。

activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Underline); activeSheet.getRange(1, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.Underline); activeSheet.getRange(-1, 1, -1, 1, GC.Spread.Sheets.SheetArea.viewport).textDecoration(GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.LineThrough | GC.Spread.Sheets.TextDecorationType.Underline); var style = new GC.Spread.Sheets.Style(); style.textDecoration = GC.Spread.Sheets.TextDecorationType.Overline | GC.Spread.Sheets.TextDecorationType.Underline; activeSheet.setStyle(1, 1, style, GC.Spread.Sheets.SheetArea.viewport); activeSheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport).value("Test"); activeSheet.getCell(1, 0, GC.Spread.Sheets.SheetArea.viewport).value("Test"); activeSheet.getCell(0, 1, GC.Spread.Sheets.SheetArea.viewport).value("Test");

好了这就是我们今天的内容了,如果你对我们的产品感兴趣或者有任何疑问,欢迎咨询在线客服>>

高端UI界面开发
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年6月18日
下一篇 2020年6月18日

相关推荐

发表回复

登录后才能评论