本文整理汇总了C#中IXLWorksheet.LastRowUsed方法的典型用法代码示例。如果您正苦于以下问题:C# IXLWorksheet.LastRowUsed方法的具体用法?C# IXLWorksheet.LastRowUsed怎么用?C# IXLWorksheet.LastRowUsed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXLWorksheet
的用法示例。
在下文中一共展示了IXLWorksheet.LastRowUsed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getTotalHeight
public static double getTotalHeight(IXLWorksheet ws, int startRow)
{
var totalHeight = 0.0;
foreach (var row in ws.Rows(startRow, ws.LastRowUsed().RowNumber()))
{
totalHeight += row.Height;
}
return totalHeight;
}
示例2: GetRowCount
public int GetRowCount(string sheetName)
{
worksheet = workbook.Worksheet(sheetName);
return worksheet.LastRowUsed().RowNumber();
}
示例3: GetColumnNumber
private int GetColumnNumber(String sheetName, String colName)
{
worksheet = workbook.Worksheet(sheetName);
IXLRow r = worksheet.Row(1);
while (r != worksheet.LastRowUsed())
{
foreach(IXLCell c in r.CellsUsed())
{
if (c.Value.Equals(colName))
return c.Address.ColumnNumber; // Starts with 0
}
r = r.RowBelow();
}
return -1;
}
示例4: AddPerformanceFormatting
private void AddPerformanceFormatting(IXLWorksheet performanceSheet)
{
int lastRowUsed = performanceSheet.LastRowUsed().RowNumber();
//freeze panels
performanceSheet.SheetView.Freeze(1, 2);
//performance global styles
performanceSheet.Range(1, 1, performanceSheet.LastCellUsed().Address.RowNumber, performanceSheet.LastCellUsed().Address.ColumnNumber)
.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
//column specific formatting
//date columns
performanceSheet.Range(string.Format("A2:A{0}", lastRowUsed)).Style.DateFormat.Format = "dd/MM/yyyy";
//percentage formatting (0.00%)
performanceSheet.Ranges(string.Format("E2:E{0},H2:I{1},Y2:Y{2},AC2:AC{3},AE2:AF{4},AH2:AI{5},AK2:AL{6},AN2:AO{7}",
lastRowUsed, lastRowUsed, lastRowUsed, lastRowUsed, lastRowUsed, lastRowUsed, lastRowUsed, lastRowUsed
)).Style.NumberFormat.NumberFormatId = 10;
//no decimal points
performanceSheet.Range(string.Format("R2:R{0}", lastRowUsed)).Style.NumberFormat.Format = "0";
//decimal format (0.00)
performanceSheet.Ranges(string.Format("J2:J{0},L2:N{1}",
lastRowUsed, lastRowUsed
)).Style.NumberFormat.Format = "0.00";
//three decimal points (0.000)
performanceSheet.Range(string.Format("U2:U{0}",
lastRowUsed
)).Style.NumberFormat.Format = "0.000";
//money with two decimals ($ 0.00)
performanceSheet.Ranges(string.Format("T2:T{0},W2:W{1},Z2:Z{2}",
lastRowUsed, lastRowUsed, lastRowUsed
)).Style.NumberFormat.Format = "$ 0.00";
//money with three decimals ($ 0.000)
performanceSheet.Range(string.Format("V2:V{0}",
lastRowUsed, lastRowUsed, lastRowUsed
)).Style.NumberFormat.Format = "$ 0.000";
// adjust to content
performanceSheet.Columns().AdjustToContents();
}
示例5: FindRowById
private static IXLRow FindRowById(string id, IXLWorksheet worksheet)
{
var lastRowUsed = worksheet.LastRowUsed().RowNumber();
for (int rowIndex = 0; rowIndex <= lastRowUsed; rowIndex++) {
if (worksheet.Row(rowIndex).Cell(1).GetValue<string>().ToLower() == id.ToLower()) {
return worksheet.Row(rowIndex);
}
}
return null;
}
示例6: SplitKD
private static bool SplitKD(IXLWorksheet worksheet, string title, int column)
{
// row to scan for KD
const int row = 6;
try
{
while (!worksheet.Cell(row, column).IsEmpty())
{
// scan for first KD derivative in TRIM LEVEL row
if (worksheet.Cell(row, column).GetString().EndsWith("KD"))
{
// remove existing column grouping - commented out as grouping no longer applied as you can't un-group on a protected worksheet
// worksheet.Columns(8, worksheet.LastColumnUsed().ColumnNumber()).Ungroup();
// add KD SPEC GROUP heading
worksheet.Cell(1, column).Value = title.ToUpper() + " KD";
// insert and size new divider column before KD derivatives
worksheet.Column(column).InsertColumnsBefore(1);
worksheet.Column(column).Width = 8;
// group non-KD derivatives - commented out as you can't un-group on a protected worksheet
// worksheet.Columns(8, column - 1).Group();
// merge non-KD SPEC GROUP heading
worksheet.Range(1, 8, 1, column - 1).Merge();
// group KD derivatives - commented out as you can't un-group on a protected worksheet
// worksheet.Columns(column + 1, worksheet.LastColumnUsed().ColumnNumber()).Group();
// merge KD SPEC GROUP heading
worksheet.Range(1, column + 1, 1, worksheet.LastColumnUsed().ColumnNumber()).Merge();
// add vertical KD title
worksheet.Cell(1, column).Value = title.ToUpper() + " KD";
// merge and format vertical divider heading
worksheet.Range(1, column, 9, column).Merge();
worksheet.Range(1, column, worksheet.LastRowUsed().RowNumber(), column).Style
.Font.SetBold(true)
.Font.SetFontColor(XLColor.White)
.Fill.SetBackgroundColor(XLColor.Black)
.Alignment.SetVertical(XLAlignmentVerticalValues.Bottom)
.Alignment.SetTextRotation(90);
// do for first KD derivative then break out
return true;
}
column = column + 1;
}
return false;
}
catch (Exception ex)
{
Log.Error(ex);
throw;
}
}