本文整理汇总了C#中ExcelWorksheet.CalculateMaxUsedColumns方法的典型用法代码示例。如果您正苦于以下问题:C# ExcelWorksheet.CalculateMaxUsedColumns方法的具体用法?C# ExcelWorksheet.CalculateMaxUsedColumns怎么用?C# ExcelWorksheet.CalculateMaxUsedColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExcelWorksheet
的用法示例。
在下文中一共展示了ExcelWorksheet.CalculateMaxUsedColumns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyColumnsAutoWidth
private static void ApplyColumnsAutoWidth(ExcelWorksheet ws)
{
int columnCount = ws.CalculateMaxUsedColumns();
for (int i = 0; i < columnCount; i++)
ws.Columns[i].AutoFit();
}
示例2: FormatGradeConversion
public void FormatGradeConversion(ExcelWorksheet ws)
{
foreach (DataColumn dc in _conversionDataTable.Columns)
{
if (dc.ColumnName != "PerformanceLevel" && dc.ColumnName != "Color")
{
ws.Cells[0, dc.Ordinal].Value = dc.ColumnName;
ws.Cells[0, dc.Ordinal].Style.Font.Weight = ExcelFont.BoldWeight;
}
}
int rowCount = 1;
foreach (DataRow dr in _conversionDataTable.Rows)
{
ws.Cells[rowCount, 0].Value = dr["Student_ID"].ToString();
ws.Cells[rowCount, 1].Value = dr["Student_Name"].ToString();
ws.Cells[rowCount, 2].Value = dr["RawScore"].ToString();
ws.Cells[rowCount, 2].Style.FillPattern.SetSolid(Color.FromName(dr["Color"].ToString()));
ws.Cells[rowCount, 3].Value = dr["ScaleScore"].ToString();
ws.Cells[rowCount, 3].Style.FillPattern.SetSolid(Color.FromName(dr["Color"].ToString()));
ws.Cells[rowCount, 4].Value = dr["ConvertedScore"].ToString();
ws.Cells[rowCount, 4].Style.FillPattern.SetSolid(Color.FromName(dr["Color"].ToString()));
rowCount++;
}
int columnCount = ws.CalculateMaxUsedColumns();
for (int i = 0; i < columnCount; i++)
{
ws.Columns[i].AutoFit(1, ws.Rows[0], ws.Rows[ws.Rows.Count - 1]);
}
}