本文整理汇总了C#中IXLWorksheet.RowsUsed方法的典型用法代码示例。如果您正苦于以下问题:C# IXLWorksheet.RowsUsed方法的具体用法?C# IXLWorksheet.RowsUsed怎么用?C# IXLWorksheet.RowsUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IXLWorksheet
的用法示例。
在下文中一共展示了IXLWorksheet.RowsUsed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessWorksheet
private void ProcessWorksheet(IXLWorksheet xlWorksheet)
{
if (!_uniqueIdMapping.Any())
_uniqueIdMapping =
_pcfService.GetForChurch(this._churchId)
.Select(i => new { i.UniqueId, i.Id })
.ToDictionary(t => t.UniqueId, t => t.Id);
var rows = xlWorksheet.RowsUsed();
foreach (var row in rows)
{
var pcfUniqueId = row.FirstCellUsed().GetString();
var pcfId =
_uniqueIdMapping.FirstOrDefault(
i => i.Key.Equals(pcfUniqueId, StringComparison.InvariantCultureIgnoreCase)).Value;
if (pcfId != 0)
{
var m = new StagedCells()
{
Name = row.FirstCellUsed().CellRight().GetString(),
UniqueId = UniqueIdGenerator.GenerateUniqueIdForCell(name: row.FirstCellUsed().GetString()),
PCFId = pcfId,
ChurchId = this._churchId
};
_cellService.Insert(m);
}
}
}
示例2: ExcelParser
/// <summary>
/// Creates a new parser using the given <see cref="IXLWorksheet"/> and <see cref="CsvConfiguration"/>.
/// </summary>
/// <param name="worksheet">The <see cref="IXLWorksheet"/> with the data.</param>
/// <param name="configuration">The configuration.</param>
public ExcelParser(IXLWorksheet worksheet, CsvConfiguration configuration)
{
workbook = worksheet.Workbook;
this.worksheet = worksheet;
this.configuration = configuration;
FieldCount = worksheet.RowsUsed().CellsUsed().Max(cell => cell.Address.ColumnNumber);
}
示例3: AutoFitWorksheet
public static void AutoFitWorksheet(IXLWorksheet ws, int startCol, int startRow, double lineHeight)
{
foreach (var row in ws.RowsUsed().Skip(startRow))
{
var maxLines = 1.0;
foreach (var cell in row.CellsUsed().Skip(startCol))
{
if (cell.Value != null)
{
var lines = cell.Value.ToString().Length / (cell.WorksheetColumn().Width * 1.15);
maxLines = maxLines < lines ? lines : maxLines;
}
}
row.Height = lineHeight * Math.Ceiling(maxLines);
}
}
示例4: ProcessWorkSheet
private void ProcessWorkSheet(IXLWorksheet worksheet)
{
if (worksheet != null)
{
foreach (var row in worksheet.RowsUsed())
{
if (row != null && row.RowBelow() != null)
{
var currentRow = row.RowBelow();
if (currentRow != null && currentRow.CellsUsed().Any())
{
var partnerUniqueId = currentRow.FirstCellUsed().GetString();
var armShort = currentRow.FirstCellUsed().CellRight(1).GetString();
var amount = currentRow.FirstCellUsed().CellRight(2).GetDouble();
var currency = currentRow.FirstCellUsed().CellRight(3).GetString();
var month = currentRow.FirstCellUsed().CellRight(4).GetString();
var year = currentRow.FirstCellUsed().CellRight(5).GetString();
var armId = this._partnershipArmMappings.ContainsKey(armShort)
? this._partnershipArmMappings.FirstOrDefault(i => i.Key.Equals(armShort)).Value
: 0;
var currencyId = this._currencySymbol.ContainsKey(currency)
? this._currencySymbol.FirstOrDefault(i => i.Key.Equals(currency)).Value
: 0;
var partnerId = this._partnerIdMappings.ContainsKey(partnerUniqueId)
? this._partnerIdMappings.FirstOrDefault(i => i.Key.Equals(partnerUniqueId)).Value
: 0;
var item = new StagedPartnership()
{
Amount = (decimal) amount,
ArmId = armId,
ChurchId = _churchId,
CurrencyId = currencyId,
DateCreated = DateTime.Now,
Month = 1,
PartnerId = partnerId,
Year = Convert.ToInt32(year)
};
_stagedPartnershipService.Insert(item);
}
}
}
}
}
示例5: ProcessWorksheet
private void ProcessWorksheet(IXLWorksheet workSheet)
{
if (workSheet != null)
{
foreach (var row in workSheet.RowsUsed())
{
if (row != null && row.RowBelow() != null)
{
var currentRow = row.RowBelow();
if (currentRow != null && currentRow.CellsUsed().Any())
{
var title = currentRow.FirstCellUsed().GetString();
var firstName = currentRow.FirstCellUsed().CellRight(1).GetString();
var lastName = currentRow.FirstCellUsed().CellRight(2).GetString();
var email = currentRow.FirstCellUsed().CellRight(3).GetString();
var phone = currentRow.FirstCellUsed().CellRight(4).GetString();
var gender = currentRow.FirstCellUsed().CellRight(5).GetString();
var dateOfBirth = currentRow.FirstCellUsed().CellRight(6).GetDateTime();
var pcfUniqueId = currentRow.FirstCellUsed().CellRight(7).GetString();
var cellUniqueId = currentRow.FirstCellUsed().CellRight(8).GetString();
var pcfId = this._pcfIdMappings.ContainsKey(pcfUniqueId) ? this._pcfIdMappings.FirstOrDefault(i => i.Key.Equals(pcfUniqueId)).Value : 0;
var cellId = this._cellIdMappings.ContainsKey(cellUniqueId) ? this._cellIdMappings.FirstOrDefault(i => i.Key.Equals(cellUniqueId)).Value : 0;
var item = new StagedPartner
{
ChurchId = this._churchId,
DateCreated = DateTime.Now,
Email = email,
Phone = phone,
DateOfBirth = dateOfBirth,
Title = title,
FirstName = firstName,
LastName = lastName,
PCFId = pcfId,
CellId = cellId,
Gender = gender,
UniqueId = IDGenerators.UniqueIdGenerator.GenerateUniqueIdForPartner(firstName + lastName),
};
_stagedPartnerService.Insert(item);
}
}
}
}
}
示例6: ProcessWorksheet
private void ProcessWorksheet(IXLWorksheet xlWorksheet)
{
if(!_uniqueIdIdMapping.Any() )
_uniqueIdIdMapping = _zoneService.GetAll().Select(i => new {i.UniqueId, i.Id}).ToDictionary(t => t.UniqueId, t => t.Id);
var rows = xlWorksheet.RowsUsed();
foreach (var row in rows)
{
var parentUniqueId = row.FirstCellUsed().GetString();
var parentId =
_uniqueIdIdMapping.FirstOrDefault(i => i.Key.Equals(parentUniqueId, StringComparison.InvariantCultureIgnoreCase)).Value;
var name = row.FirstCellUsed().CellRight().GetString();
var m = new StagedGroup()
{
ZoneId = parentId,
Name = name,
UniqueId = UniqueIdGenerator.GenerateUniqueIdForGroup(name)
};
_groupService.Insert(m);
}
}
示例7: LoadRows
public static List<TranslationRow> LoadRows(IXLWorksheet worksheet)
{
var result = new List<TranslationRow>();
var cultures = ReadCultures(worksheet).ToList();
foreach (var row in worksheet.RowsUsed().Skip(1))
{
var textValues = row.Cells(1, (cultures.Count * 2) + 2).Select(cell => (cell.Value != null ? cell.Value.ToString() : null)).ToList();
if (textValues.Any())
{
var customer = new TranslationRow
{
ID = textValues[0],
Key = textValues[1]
};
foreach(var culture in cultures)
{
if (culture.TextColumnIndex > 0 && culture.TextColumnIndex < textValues.Count &&
!String.IsNullOrWhiteSpace(textValues[culture.TextColumnIndex]))
customer.Translations.Add(culture.Culture, textValues[culture.TextColumnIndex]);
if (culture.CommentColumnIndex > 0 && culture.CommentColumnIndex < textValues.Count
&& !String.IsNullOrWhiteSpace(textValues[culture.CommentColumnIndex]))
customer.Comments.Add(culture.Culture, textValues[culture.CommentColumnIndex]);
}
result.Add(customer);
}
else
{
break;
}
}
return result;
}