Infoga rader och kolumner
Contents
[
Hide
]
I den här artikeln förklaras hur man lägger till nya rader och kolumner i ett kalkylblad med hjälp av Aspose.Cells.GridWeb API. Rader eller kolumner kan infogas på vilken position som helst i kalkylbladet.
Infoga rader
För att infoga en rad på valfri position i ett kalkylblad:
- Lägg till kontrollen Aspose.Cells.GridWeb till webbformuläret.
- Hämta kalkylbladet du lägger till rader i.
- Infoga en rad genom att ange en radindex där raden ska infogas.
This file contains 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 reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get row index entered by user | |
int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
// Add row at specified index | |
sheet.Cells.InsertRow(rowIndex); |
Infoga kolumner
För att infoga en kolumn på valfri position i ett kalkylblad:
- Lägg till Aspose.Cells.GridWeb-kontrollen i en webbformulär.
- Hämta kalkylbladet du lägger till kolumner i.
- Infoga en kolumn genom att ange kolumnindex där kolumnen ska infogas.
This file contains 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 reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get column index entered by user | |
int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
// Add column at specified index | |
sheet.Cells.InsertColumn(columnIndex); |
Du kan också använda InsertRows/InsertColumns-metoderna för att infoga flera rader/kolumner i kalkylbladen.