Inserisci intervalli

Introduzione

In Excel, puoi selezionare un intervallo, quindi inserire un intervallo e spostare altri dati a destra o verso il basso.

Opzioni di spostamento

Inserisci intervalli utilizzando Aspose.Cells

Aspose.Cells fornisce il metodo Cells.InsertRange per inserire un intervallo.

Inserisci intervalli e sposta le celle a destra

Inserisci un intervallo e sposta le celle a destra come nei seguenti codici con Aspose.Cells:

// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Get all the worksheets in the book.
WorksheetCollection worksheets = workbook.Worksheets;
// Get the first worksheet in the worksheets collection.
Worksheet worksheet = workbook.Worksheets[0];
// Create a range of cells.
Range sourceRange = worksheet.Cells.CreateRange("A1", "A2");
// Input some data with some formattings into
// A few cells in the range.
sourceRange[0, 0].PutValue("Test");
sourceRange[1, 0].PutValue("123");
CellArea ca = CellArea.CreateCellArea("A1", "A2");
worksheet.Cells.InsertRange(ca, ShiftType.Right);
Console.WriteLine(worksheet.Cells["B1"].StringValue == "Test");

Inserisci intervalli e sposta le celle verso il basso

Inserisci un intervallo e sposta le celle verso il basso come nei seguenti codici con Aspose.Cells:

// Instantiate a new Workbook.
Workbook workbook = new Workbook();
// Get all the worksheets in the book.
WorksheetCollection worksheets = workbook.Worksheets;
// Get the first worksheet in the worksheets collection.
Worksheet worksheet = workbook.Worksheets[0];
// Create a range of cells.
Range sourceRange = worksheet.Cells.CreateRange("A1", "A2");
// Input some data with some formattings into
// A few cells in the range.
sourceRange[0, 0].PutValue("Test");
sourceRange[1, 0].PutValue("123");
CellArea ca = CellArea.CreateCellArea("A1", "A2");
worksheet.Cells.InsertRange(ca, ShiftType.Down);
Console.WriteLine(worksheet.Cells["A3"].StringValue == "Test");