GridDesktop工作表的自定义行和自定义列标题
Contents
[
Hide
]
可能的使用场景
您可以自定义GridDesktop工作表的行和列标题。通常,行从1开始,列从A开始。您可以更改此行为并为GridDesktop工作表的行和列使用您自己的标题。为了更改行和列的标题,请实现ICustomRowCaption和ICustomColumnCaption接口。
GridDesktop工作表的自定义行和自定义列标题
以下示例代码实现了ICustomRowCaption和ICustomColumnCaption接口,并更改了行和列的标题。屏幕截图显示了执行此示例代码的结果供参考。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
public class MyICustomColumnCaption : ICustomColumnCaption | |
{ | |
//Returns the Custom Column Caption | |
public string GetCaption(int column) | |
{ | |
return "Mine " + (column + 10); | |
} | |
} | |
public class MyICustomRowCaption : ICustomRowCaption | |
{ | |
//Returns the Custom Row Caption | |
public string GetCaption(int row) | |
{ | |
return "R" + (row + 10).ToString(); | |
} | |
} | |
//------------------------------------------- | |
//------------------------------------------- | |
//Access the First GridDesktop Worksheet | |
Worksheet ws = this.gridDesktop1.Worksheets[0]; | |
//Assign the Worksheet Custom Column and Row Caption Instance | |
ws.CustomColumnCaption = new MyICustomColumnCaption(); | |
ws.CustomRowCaption = new MyICustomRowCaption(); |