Изменение размера строк и столбцов
Contents
[
Hide
]
Иногда значения ячеек шире, чем ячейка, в которой они находятся, или находятся на нескольких строках. Такие значения не видны пользователям полностью, если только они не изменяют высоту и ширину строк и столбцов. Aspose.Cells.GridWeb полностью поддерживает настройку высоты строк и ширины столбцов. В этом разделе эти функции обсуждаются подробно с помощью примеров.
Работа с высотой строк и шириной столбцов
Настройка высоты строки
Чтобы установить высоту строки:
- Добавьте элемент управления Aspose.Cells.GridWeb в свою веб-форму.
- Получите доступ к коллекции Cells рабочего листа.
- Установите высоту всех ячеек в любой указанной строке.
Метод SetRowHeight и SetColumnWidth из коллекции Cells также имеет варианты, доступные для установки измерений высоты строки и ширины столбца в дюймах и пикселях.
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 | |
// Get row index entered by user | |
int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
// Get row height entered by user | |
int rowHeight = Convert.ToInt16(txtRowHeight.Text.Trim()); | |
// Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
// Resize row at specified index to specified height | |
cells.SetRowHeight(rowIndex, rowHeight); |
Настройка ширины столбца
Чтобы установить ширину столбца:
- Добавьте элемент управления Aspose.Cells.GridWeb в свою веб-форму.
- Получите доступ к коллекции Cells рабочего листа.
- Установите ширину всех ячеек в любом указанном столбце.
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 | |
// Get column index entered by user | |
int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
// Get column width entered by user | |
int columnWidth = Convert.ToInt16(txtColumnWidth.Text.Trim()); | |
// Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells; | |
// Resize column at specified index to specified width | |
cells.SetColumnWidth(columnIndex, columnWidth); |