private static DataType GuessType(IXLColumn col) { var colDistinctValues = col .CellsUsed() .Skip(1) .Select(cell => cell.Value.ToString()) .Distinct() .ToArray(); return(GuessType(colDistinctValues)); }
// 统计一列里面所有单元的最大字符数。注:字符数约定按照西文字符数计算,一个汉字等于两个西文字符 static int GetMaxChars(IXLColumn column) { int max = 0; foreach (IXLCell cell in column.CellsUsed()) { // 跳过 Merged 的 Cell。也就是表格标题 if (cell.IsMerged()) { continue; } string text = cell.GetString(); int current = GetCharWidth(text); if (current > max) { max = current; } } return(max); }