Настраиваемая строка и настраиваемый заголовок столбца рабочего листа 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(); |