Настройка ширины столбца или высоты строки
Contents
[
Hide
]
Эта тема обсуждает установку ширины столбца и высоты строки с использованием API Aspose.Cells.GridDesktop. Иногда ячейки листа содержат значения, которые шире, чем оригинальная ячейка. Это затрудняет прочтение содержимого ячейки пользователем. Некоторым пользователям не нравится использовать клавишу со стрелкой вправо, чтобы просмотреть полное значение в ячейке. Для решения таких проблем разработчики могут изменить ширину столбца. Изменение высоты строки решает аналогичные проблемы.
Как установить ширину столбца
Чтобы установить ширину столбца с помощью Aspose.Cells.GridDesktop:
- Получите доступ к листу.
- Получите доступ к столбцу, который вы хотите изменить ширину.
- Установите ширину столбца.
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 | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cell | |
GridCell cell = sheet.Cells["a1"]; | |
cell.SetCellValue("Welcome to Aspose!"); | |
// Accessing the first column of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; | |
// Setting the width of the column | |
column.Width = 150; |
Как установить высоту строки
Чтобы установить высоту строки с помощью Aspose.Cells.GridDesktop, выполните следующие шаги:
- Получите доступ к любому желаемому листу.
- Получите доступ к строке, высоту которой вы хотите изменить.
- Установите высоту строки.
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 | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cells | |
GridCell cell = sheet.Cells["b2"]; | |
cell.SetCellValue("1"); | |
cell = sheet.Cells["c2"]; | |
cell.SetCellValue("2"); | |
cell = sheet.Cells["d2"]; | |
cell.SetCellValue("3"); | |
cell = sheet.Cells["e2"]; | |
cell.SetCellValue("4"); | |
// Accessing the first row of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[1]; | |
// Setting the height of the row | |
row.Height = 100; |