【发布时间】:2017-02-06 15:01:19
【问题描述】:
我正在使用 ClosedXML 创建一个包含一些数据的 xlsx 文件。在 Excel 表中,我有一个包含数据的表格。在表格的列(不是工作表的列)中,我想指定数据类型。
/* This datatable is created and populated somewhere else in my program*/
Datatable dt = new Datatable();
ws.Cell(t.Position.Row, t.Position.Column).InsertTable(dt);
IXLTables allTables = ws.Tables;
var table = allTables.ElementAt(i);
int j = 1;
/* The options object hold the excel datatypes for each column*/
foreach (var c in option.Tables.ElementAt(i).Columns)
{
table.Column(j).DataType = c.Type;
j++;
}
i++;
从选项对象的 foreach 循环中找到并添加数据类型,这在我的程序中如何工作可能并不重要。
问题是当我向表中的列添加数据类型时,它包含表的标题。由于标题是“文本”并且我可能指定的值是数字,我得到一个错误。任何人都知道如何让它忽略表格的标题并简单地将数据类型添加到下面的列中?
提前致谢。
【问题讨论】: