This commit is contained in:
@@ -30,7 +30,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
|
||||
// --- Общий приватный метод, содержащий всю логику замены ---
|
||||
private static void ReplaceCore(SpreadsheetDocument doc, WorksheetPart[] worksheets, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
static void ReplaceCore(SpreadsheetDocument doc, WorksheetPart[] worksheets, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
{
|
||||
var workbookPart = doc.WorkbookPart!;
|
||||
|
||||
@@ -63,7 +63,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
|
||||
// --- Остальные вспомогательные методы (без изменений) ---
|
||||
private static IEqualityComparer<string> GetComparerForStringComparison(StringComparison comparisonType) =>
|
||||
static IEqualityComparer<string> GetComparerForStringComparison(StringComparison comparisonType) =>
|
||||
comparisonType switch
|
||||
{
|
||||
StringComparison.Ordinal => StringComparer.Ordinal,
|
||||
@@ -75,7 +75,7 @@ internal static class ReplaceStringExtensions
|
||||
_ => StringComparer.OrdinalIgnoreCase,
|
||||
};
|
||||
|
||||
private static void CollectCellChanges(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType, Dictionary<Cell, string> cellChanges, List<string> allSharedStrings)
|
||||
static void CollectCellChanges(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType, Dictionary<Cell, string> cellChanges, List<string> allSharedStrings)
|
||||
{
|
||||
var worksheet = worksheetPart.Worksheet;
|
||||
if (worksheet is null) return;
|
||||
@@ -93,7 +93,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyCellChanges(Dictionary<Cell, string> cellChanges, List<string> allSharedStrings)
|
||||
static void ApplyCellChanges(Dictionary<Cell, string> cellChanges, List<string> allSharedStrings)
|
||||
{
|
||||
foreach (var kvp in cellChanges)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateSharedStringTable(WorkbookPart workbookPart, List<string> allSharedStrings)
|
||||
static void UpdateSharedStringTable(WorkbookPart workbookPart, List<string> allSharedStrings)
|
||||
{
|
||||
var ssPart = workbookPart.SharedStringTablePart;
|
||||
ssPart ??= workbookPart.AddNewPart<SharedStringTablePart>();
|
||||
@@ -125,7 +125,7 @@ internal static class ReplaceStringExtensions
|
||||
sharedStringTable.Save();
|
||||
}
|
||||
|
||||
private static string ProcessReplacements(string input, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
static string ProcessReplacements(string input, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input) || replacementDict.Count == 0) return input;
|
||||
string result = input;
|
||||
@@ -137,7 +137,7 @@ internal static class ReplaceStringExtensions
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string ReplaceInString(string original, string oldValue, string newValue, StringComparison comparisonType)
|
||||
static string ReplaceInString(string original, string oldValue, string newValue, StringComparison comparisonType)
|
||||
{
|
||||
int idx = original.IndexOf(oldValue, comparisonType);
|
||||
if (idx < 0) return original;
|
||||
@@ -154,7 +154,7 @@ internal static class ReplaceStringExtensions
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static string GetCellText(Cell cell, List<string> allSharedStrings)
|
||||
static string GetCellText(Cell cell, List<string> allSharedStrings)
|
||||
{
|
||||
if (cell?.CellValue is null) return string.Empty;
|
||||
if (cell.InlineString is not null)
|
||||
@@ -169,7 +169,7 @@ internal static class ReplaceStringExtensions
|
||||
return value;
|
||||
}
|
||||
|
||||
private static int AddOrFindStringIndex(List<string> allSharedStrings, string text)
|
||||
static int AddOrFindStringIndex(List<string> allSharedStrings, string text)
|
||||
{
|
||||
int idx = allSharedStrings.IndexOf(text);
|
||||
if (idx >= 0) return idx;
|
||||
@@ -178,7 +178,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
|
||||
// --- Колонтитулы (обобщённый метод) ---
|
||||
private static void ReplaceInHeadersFooters(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
static void ReplaceInHeadersFooters(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
{
|
||||
var worksheet = worksheetPart.Worksheet;
|
||||
if (worksheet is null) return;
|
||||
@@ -189,7 +189,7 @@ internal static class ReplaceStringExtensions
|
||||
ReplaceHeaderFooter(elem, replacementDict, comparisonType);
|
||||
}
|
||||
|
||||
private static void ReplaceHeaderFooter(OpenXmlLeafTextElement? element, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
static void ReplaceHeaderFooter(OpenXmlLeafTextElement? element, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
{
|
||||
if (element?.Text is null) return;
|
||||
string original = element.Text;
|
||||
@@ -199,7 +199,7 @@ internal static class ReplaceStringExtensions
|
||||
}
|
||||
|
||||
// --- Комментарии ---
|
||||
private static void ReplaceInComments(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
static void ReplaceInComments(WorksheetPart worksheetPart, Dictionary<string, string> replacementDict, StringComparison comparisonType)
|
||||
{
|
||||
var commentsPart = worksheetPart.WorksheetCommentsPart;
|
||||
if (commentsPart?.Comments is null) return;
|
||||
|
||||
Reference in New Issue
Block a user