在一个excel表格在Excel中开始添加一个新列 [英] Adding a new column at the start of an excel table in an excel

查看:224
本文介绍了在一个excel表格在Excel中开始添加一个新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道一个人如何可以使用C sharp.net Excel电子表格的开头插入一个新列。我使用的Microsoft.Office.Interop.Excel;我想用OLEO要做到这一点,但我没有看到发生。我一直对如何做这方面的最后两天谷歌搜索。我不明白为什么有这个不是更多的教程

I am wondering how one can insert a new column at the beginning of an excel spreadsheet using C sharp.net. I am using Microsoft.Office.Interop.Excel; I want to use OLEO to do this, but I don't see that happening. I have been searching google on how to do this for the last two days now. I can't understand why there are not more tutorials on this?

推荐答案

结帐出的 Range.Insert 方法,你可以在一个单元格区域称在他们面前插入整个行/列:

Checkout out the Range.Insert method which you can call on a range of cells to insert entire rows/columns in front of them:

Worksheet sheet = (Worksheet) workBookIn.Sheets[1]; // Worksheet indexes are one based

Range rng = sheet.get_Range("A1", Missing.Value);

rng.EntireColumn.Insert(XlInsertShiftDirection.xlShiftToRight,
                        XlInsertFormatOrigin.xlFormatFromRightOrBelow);

这篇关于在一个excel表格在Excel中开始添加一个新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆