Настройка ширины столбца или высоты строки
Contents
[
Hide
]
В этом разделе обсуждается настройка ширины столбца и высоты строки с помощью Aspose.Cells.GridDesktop API. Иногда ячейки рабочего листа содержат значения, которые шире, чем исходная ячейка. Это затрудняет пользователям чтение содержимого ячейки. Некоторым пользователям не нравится использовать клавишу со стрелкой вправо для просмотра полного значения в ячейке. Чтобы решить такие проблемы, разработчики могут изменить ширину столбца. Изменение высоты строки решает аналогичные проблемы.
Настройка ширины столбца
Чтобы установить ширину столбца с помощью 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; |