本文整理汇总了C#中DataTable.AddColumnHandleDuplicate方法的典型用法代码示例。如果您正苦于以下问题:C# DataTable.AddColumnHandleDuplicate方法的具体用法?C# DataTable.AddColumnHandleDuplicate怎么用?C# DataTable.AddColumnHandleDuplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable.AddColumnHandleDuplicate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readWholeWorkSheetWithIndex
//TODO: quite a bit of duplication with the noindex version
private bool readWholeWorkSheetWithIndex(XlsBiffIndex idx, bool triggerCreateColumns, DataTable table) {
m_dbCellAddrs=idx.DbCellAddresses;
foreach (uint dbCellAddress in m_dbCellAddrs){
if (m_depth==m_maxRow){
break;
}
// init reading data
m_cellOffset=findFirstDataCellOffset((int)dbCellAddress);
if (m_cellOffset==-2) {
return false;
}
if (m_cellOffset<0) {
return true;
}
//DataTable columns
if (triggerCreateColumns) {
if (_isFirstRowAsColumnNames&&readWorkSheetRow()||(_isFirstRowAsColumnNames&&m_maxRow==1)) {
for (int i=0; i<m_maxCol; i++) {
if (m_cellsValues[i]!=null&&m_cellsValues[i].ToString().Length>0) {
table.AddColumnHandleDuplicate(m_cellsValues[i].ToString());
} else {
table.AddColumnHandleDuplicate(string.Concat(COLUMN, i));
}
}
} else {
for (int i=0; i<m_maxCol; i++) {
table.Columns.Add(i.ToString(CultureInfo.InvariantCulture), typeof(Object));
}
}
triggerCreateColumns=false;
table.BeginLoadData();
}
while (readWorkSheetRow()) {
table.Rows.Add(m_cellsValues);
}
//add the row
if (m_depth>0&&!(_isFirstRowAsColumnNames&&m_maxRow==1)) {
table.Rows.Add(m_cellsValues);
}
}
return true;
}
示例2: readWholeWorkSheetNoIndex
private void readWholeWorkSheetNoIndex(bool triggerCreateColumns, DataTable table) {
while (Read()) {
if (m_depth==m_maxRow){
break;
}
bool justAddedColumns=false;
//DataTable columns
if (triggerCreateColumns) {
if (_isFirstRowAsColumnNames||(_isFirstRowAsColumnNames&&m_maxRow==1)) {
for (int i=0; i<m_maxCol; i++) {
if (m_cellsValues[i]!=null&&m_cellsValues[i].ToString().Length>0)
table.AddColumnHandleDuplicate(m_cellsValues[i].ToString());
else
table.AddColumnHandleDuplicate(string.Concat(COLUMN, i));
}
} else {
for (int i=0; i<m_maxCol; i++) {
table.Columns.Add(i.ToString(CultureInfo.InvariantCulture), typeof(Object));
}
}
triggerCreateColumns=false;
justAddedColumns=true;
table.BeginLoadData();
}
if (!justAddedColumns&&m_depth>0&&!(_isFirstRowAsColumnNames&&m_maxRow==1)) {
table.Rows.Add(m_cellsValues);
}
}
if (m_depth>0&&!(_isFirstRowAsColumnNames&&m_maxRow==1)) {
table.Rows.Add(m_cellsValues);
}
}
示例3: ReadDataSet
private DataSet ReadDataSet() {
var dataset = new DataSet();
Dictionary<int, XlsxDimension> demensionDict = DetectDemension();
for (int sheetIndex = 0; sheetIndex < m_workbook.Sheets.Count; sheetIndex++) {
XlsxWorksheet sheet = m_workbook.Sheets[sheetIndex];
var table = new DataTable(m_workbook.Sheets[sheetIndex].Name);
ReadSheetGlobals(sheet);
sheet.Dimension = demensionDict[sheetIndex];
if (sheet.Dimension == null) {
continue;
}
m_depth = 0;
m_emptyRowCount = 0;
// Reada Columns
if (!m_isFirstRowAsColumnNames) {
// No Sheet Columns
for (int i = 0; i < sheet.ColumnsCount; i++) {
table.Columns.Add(i.ToString(CultureInfo.InvariantCulture), typeof(Object));
}
} else if (ReadSheetRow(sheet)) {
// Read Sheet Columns
Debug.Assert(m_cellsValues!=null);
for (int index = 0; index < m_cellsValues.Length; index++) {
if (m_cellsValues[index] != null && m_cellsValues[index].ToString().Length > 0) {
table.AddColumnHandleDuplicate(m_cellsValues[index].ToString());
} else {
table.AddColumnHandleDuplicate(string.Concat(COLUMN, index));
}
}
} else {
continue;
}
// Read Sheet Rows
table.BeginLoadData();
while (ReadSheetRow(sheet)) {
table.Rows.Add(m_cellsValues);
}
if (table.Rows.Count > 0) {
dataset.Tables.Add(table);
}
// Read HyperLinks
ReadHyperLinks(sheet, table);
table.EndLoadData();
}
dataset.AcceptChanges();
dataset.FixDataTypes();
return dataset;
}