Inserire righe e colonne
Contents
[
Hide
]
Questo argomento spiega come inserire nuove righe e colonne in un foglio di lavoro utilizzando l’API di Aspose.Cells.GridWeb. Le righe o colonne possono essere inserite in qualsiasi posizione nel foglio di lavoro.
Inserimento Righe
Per inserire una riga in qualsiasi posizione in un foglio di lavoro:
- Aggiungi il controllo Aspose.Cells.GridWeb al modulo Web.
- Accedi al foglio di lavoro a cui stai aggiungendo righe.
- Inserisci una riga specificando un indice di riga in cui la riga deve essere inserita.
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); |
Inserimento di colonne
Per inserire una colonna in qualsiasi posizione in un foglio di lavoro:
- Aggiungi il controllo Aspose.Cells.GridWeb a un modulo Web.
- Accedi al foglio di lavoro a cui stai aggiungendo colonne.
- Inserisci una colonna specificando l’indice di colonna in cui la colonna deve essere inserita.
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); |
Puoi anche utilizzare i metodi InsertRows/InsertColumns per inserire più righe/colonne nei fogli di lavoro di conseguenza.