c# - Insert Columns between columns in excel -
i have excel file in have number of columns. need insert columns example between "c" , "d".. resulting columns should "c" ,"new column(d)", "e".. please me this..
parts of code open excel file below...
microsoft.office.interop.excel.application application = new microsoft.office.interop.excel.application(); microsoft.office.interop.excel.workbook workbook = application.workbooks.open(txtdestination.text.tostring() + "\\" + path.getfilename(file_name, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing, type.missing); worksheet worksheet = (worksheet)workbook.activesheet;
i this:
select column want insert new column next to
excel.range orng = osheet.range["i1"];
insert new column, specifying direction want shift existing columns. in case, insert new column left of i1; i1 become h1
orng.entirecolumn.insert(excel.xlinsertshiftdirection.xlshifttoright, excel.xlinsertformatorigin.xlformatfromrightorbelow);
to new column, such set header value, select i1 range again.
orng = osheet.range["i1"];
set column header text
orng.value2 = "discount";
Comments
Post a Comment