Вставить диапазоны
Contents
[
Hide
]
Вступление
В Excel вы можете выбрать диапазон, затем вставить диапазон и сдвинуть другие данные вправо или вниз.
Вставьте диапазоны, используя Aspose.Cells
Aspose.Cells предоставляетCells.InsertRange способ вставки диапазона.
Вставить диапазоны и сдвинуть Cells вправо
Вставьте диапазон и сдвиньте ячейки правильно, как следующие коды с Aspose.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
// 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"); | |
Вставить диапазоны и сдвинуть Cells вниз
Вставьте диапазон и сдвиньте ячейки вниз как следующие коды с Aspose.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
// 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"); | |