简体   繁体   中英

how to add entire column using excel-dna in C#

Need to open a existing xlsx where a ribben menu and a button require. on click of button need to add 9 blank columns. so shift whole A column to right keep adding 9 blank columns then update them with some calculation.calculation is a lator part , not able to add blank columns

Added menu and button and on click of button tried below code.

var app = (Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application;
app.Selection.Insert();

when excel open and if i select whole column manually and click on button it add a blank column and shift A to right ... now not sure how to select whole column using code.

tried few thing but not selecting

 XlCall.Excel(XlCall.xlcSelectEnd, 4);
        ExcelReference selection = 
(ExcelReference)XlCall.Excel(XlCall.xlfSelection);

var row = selection.RowFirst;
var col = selection.ColumnFirst;
var col1 = selection.ColumnLast;
//var val1 = selection.GetValue();
//selection.SetValue(343443);

var activeCell = new ExcelReference(0, row, 0, 0);
app.Selection.Insert();

but not selecting .. please advise how to add blank column.

    app.ActiveSheet.Columns("A:A").Select()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM