Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Inserting and Deleting Columns

Francois Botha edited this pageOct 22, 2016 ·2 revisions
varworkbook=newXLWorkbook();varws=workbook.Worksheets.Add("Inserting and Deleting Columns");// Range starts with 2 columnsvarrng=ws.Range("B2:C3");// Range starts on B2// Insert a column before the rangews.Column(1).InsertColumnsAfter(1);// Range starts on C2// Insert a column in between the rangews.Column(3).InsertColumnsAfter(1);// Range now has 3 columns// Insert a column (from a range) before the rangews.Range("A2:A3").InsertColumnsAfter(1);// Range starts on D2// Insert a column (from a range) in between the rangews.Range("D2:D3").InsertColumnsAfter(1);// Range now has 4 columns// Inserting columns from a range not covering all columns does not affect our defined rangews.Range("A1:A2").InsertColumnsAfter(1);ws.Range("E3:E4").InsertColumnsAfter(1);// Delete a column before the rangews.Column(1).Delete();// Range starts on C2// Delete a column (from a range) before the rangews.Range("A2:A3").Delete(XLShiftDeletedCells.ShiftCellsLeft);// Range starts on B2// Delete a column in between the rangews.Column(3).Delete();// Range now has 3 columns// Delete a column (from a range) in between the rangews.Range("C2:C3").Delete(XLShiftDeletedCells.ShiftCellsLeft);// Range now has 2 columns// Deleting columns from a range not covering all columns does not affect our defined rangews.Range("A1:A2").Delete(XLShiftDeletedCells.ShiftCellsLeft);ws.Range("D3:D4").Delete(XLShiftDeletedCells.ShiftCellsLeft);rng.Style.Fill.BackgroundColor=XLColor.Orange;workbook.SaveAs("InsertingAndDeletingColumns.xlsx");

FAQ

Examples

Real world scenarios

Time Savers

Performance and Memory

Misc

Inserting Data/Tables

Styles

Ranges

Rows

Columns

Page Setup (Print Options)

AutoFilters

Comments

Dev docs

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp