Nitin S
Nitin S

Reputation: 7591

How to reorder columns in excel using C# interop

How to change index of columns in MS excel using interop?

Say I want to move column C to column A position

I wonder how to do this programatically using excel interop

Upvotes: 3

Views: 3614

Answers (1)

Nalaka
Nalaka

Reputation: 1185

Try This..

// cut column c and insert into A, shifting columns right

        Excel.Range copyRange = xlWs.Range["C:C"];
        Excel.Range insertRange = xlWs.Range["A:A"];
        insertRange.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, copyRange.Cut());

Upvotes: 3

Related Questions