I would like to add a column that already contains cells values between two columns (or at the end) of a worksheet of an existing workbook that I load.
我想添加一个列,该列已经包含我加载的现有工作簿的工作表的两列(或最后)之间的单元格值。
So I have a function that sets that "column values" I need :
所以我有一个函数来设置我需要的“列值”:
private static Workbook SetIndicatorsWorkbook()
{
var workbook = new Workbook(WorkbookFormat.Excel2007MacroEnabled);
var worksheet = workbook.Worksheets.Add("Unit & Integration Tests");
//Don't worry about team and jenkinsBuilTeams variables
foreach (var team in jenkinsBuildTeams)
{
worksheet.Rows[posX].Cells[0].Value = lastnbUnitTests + lastnbIntegrationTests;
posX += 1;
}
return workbook;
}
And then in main function I want to add this column (which is workbook.worksheets[0].Columns[0]
) in a loaded workbook :
然后在main函数中我想在加载的工作簿中添加此列(即workbook.worksheets [0] .Columns [0]):
private static void Main()
{
//The workbook I need to update
Workbook workbook = Workbook.Load("file.xlsx");
Workbook temp = SetIndicatorsWorkbook();
WorksheetColumn wc = temp.Worksheets[0].Columns[0];
//The issue is that Worksheet's Columns collection has no "Insert" property
workbook.Save("file.xlsx");
}
1 个解决方案
#1
3
The Columns collection of the Worksheet has an Insert method that will shift data/formatting just as would happen in Excel. This was added in the 2014 volume 2 version. You can read more about that in the help topic or the api documentation. Note I've linked to the WPF version help but the Insert method is available in the other platforms as well.
Worksheet的Columns集合有一个Insert方法,可以像在Excel中一样移动数据/格式。这是在2014年第2卷中添加的。您可以在帮助主题或api文档中阅读更多相关信息。注意我已经链接到WPF版本帮助,但Insert方法也可以在其他平台中使用。
#1
3
The Columns collection of the Worksheet has an Insert method that will shift data/formatting just as would happen in Excel. This was added in the 2014 volume 2 version. You can read more about that in the help topic or the api documentation. Note I've linked to the WPF version help but the Insert method is available in the other platforms as well.
Worksheet的Columns集合有一个Insert方法,可以像在Excel中一样移动数据/格式。这是在2014年第2卷中添加的。您可以在帮助主题或api文档中阅读更多相关信息。注意我已经链接到WPF版本帮助,但Insert方法也可以在其他平台中使用。