本文整理汇总了C#中Worksheet.GetAffectedNamedRanges方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.GetAffectedNamedRanges方法的具体用法?C# Worksheet.GetAffectedNamedRanges怎么用?C# Worksheet.GetAffectedNamedRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Worksheet
的用法示例。
在下文中一共展示了Worksheet.GetAffectedNamedRanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDetails
/// <summary>
/// This function is used to update the details of the object models based on the details which was updated.
/// </summary>
/// <param name="target">
/// Updated range.
/// </param>
/// <param name="currentSheet">
/// Current worksheet.
/// </param>
private void UpdateDetails(Range target, Worksheet currentSheet)
{
Dictionary<string, string> allNamedRange = new Dictionary<string, string>();
bool buildAndBindLayerDetailsViewModel = false;
// Get all Layer details into dictionary.
this.currentWorkbookMap.LocalLayerMaps.ForEach(item =>
{
allNamedRange.Add(item.RangeDisplayName, item.RangeAddress);
});
// Get all affected ranges
affectedNamedRanges = currentSheet.GetAffectedNamedRanges(target, allNamedRange);
this.currentWorkbookMap.LocalLayerMaps.ForEach(
item =>
{
if (affectedNamedRanges.ContainsKey(item.RangeDisplayName) && item.RangeName.IsValid() && !handledNamedRanges.ContainsKey(item.RangeDisplayName))
{
handledNamedRanges.Add(item.RangeDisplayName, affectedNamedRanges[item.RangeDisplayName]);
buildAndBindLayerDetailsViewModel = true;
Range currentRange = currentSheet.Range[affectedNamedRanges[item.RangeDisplayName]];
Collection<string> latestHeader = currentRange.GetHeader();
Collection<string> previousHeader = item.HeaderRowData;
// We need to upload data first and then Update the header as to make sure that we update the latest header.
// If we update header and then push data which has header in it,
// there are chances that auto map in WWT might be called because we are including the header data.
// Update the data irrespective of header is changed or not.
UpdateData(currentRange, item);
if (item.RangeAddress != affectedNamedRanges[item.RangeDisplayName] && latestHeader.Count != previousHeader.Count)
{
// Header Change :- Scenarios in which this will occur.
// 1. When a Column is deleted.
// 2. When a Cells are deleted and shifted up/Down.
item.UpdateHeaderProperties(currentRange);
}
else if (latestHeader.Count != previousHeader.Count)
{
// Header Change :- Scenarios in which this will occur.
// 1. When a data in the columns header is updated
item.UpdateHeaderProperties(currentRange);
}
else
{
for (int index = 0; index < latestHeader.Count; index++)
{
if (string.Compare(latestHeader[index], previousHeader[index], StringComparison.Ordinal) != 0)
{
// Scenario in which this check is MUST: Headers are mapped with only data and not to header text and
// any of the date time columns header row having date formatted as Text.
DateTime latestDate = DateTime.MinValue, previousDate = DateTime.MinValue;
// For Excel 2010, current range will return the date as Double value, which needs to be converted to
// date time first and then to be compared with previous date.
double latestHeaderDate;
if (Double.TryParse(latestHeader[index], out latestHeaderDate))
{
latestHeader[index] = DateTime.FromOADate(latestHeaderDate).ToString();
}
// In case of column format is set as only hh:mm:ss, then previous header date columns will
// be returned as double value.
double previousHeaderDate;
if (Double.TryParse(previousHeader[index], out previousHeaderDate))
{
previousHeader[index] = DateTime.FromOADate(previousHeaderDate).ToString();
}
if (DateTime.TryParse(latestHeader[index], out latestDate) && DateTime.TryParse(previousHeader[index], out previousDate))
{
if (latestDate == previousDate)
{
continue;
}
}
// Header Change :- Scenarios in which this will occur.
// 1. When a data in the columns header is updated
item.UpdateHeaderProperties(currentRange);
break;
}
}
}
// Sets co-ordinate type (Spherical/Rectangular) based on the mapping, If Lat/Long/RA/Dec is mapped,
// spherical takes preference over rectangular.
this.SetCoordinateType();
// Update the header details on every operation.
//.........这里部分代码省略.........