GridDesktop 工作表的自定义行和自定义列标题
Contents
[
Hide
]
可能的使用场景
您可以自定义 GridDesktop 工作表的行和列标题。通常,行从 1 开始,列从 A 开始。您可以更改此行为并为 GridDesktop 工作表的行和列使用您自己的标题。为了改变行和列的标题,请实现 ICustomRowCaption 和 ICustomColumnCaption 接口。
GridDesktop 工作表的自定义行和自定义列标题
以下示例代码实现 ICustomRowCaption 和 ICustomColumnCaption 接口并更改行和列的标题。截图展示了该示例代码的执行结果,供参考。
示例代码
This file contains hidden or 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(); |