This commit is contained in:
@@ -158,7 +158,7 @@ internal static class ReplaceNumericExtensions
|
||||
|
||||
// =========================== ОБЩАЯ ЛОГИКА ===========================
|
||||
|
||||
private static void ReplaceNumericCore<T>(
|
||||
static void ReplaceNumericCore<T>(
|
||||
WorkbookPart workbookPart,
|
||||
WorksheetPart[] worksheets,
|
||||
IEnumerable<KeyValuePair<string, T>> numericReplacements,
|
||||
@@ -255,7 +255,7 @@ internal static class ReplaceNumericExtensions
|
||||
UpdateSharedStringTable(workbookPart, allSharedStrings);
|
||||
}
|
||||
|
||||
private static void ReplaceSingleCore<T>(
|
||||
static void ReplaceSingleCore<T>(
|
||||
WorkbookPart workbookPart,
|
||||
WorksheetPart[] worksheets,
|
||||
string oldValue,
|
||||
@@ -343,7 +343,7 @@ internal static class ReplaceNumericExtensions
|
||||
|
||||
// =========================== ВСПОМОГАТЕЛЬНЫЕ МЕТОДЫ ===========================
|
||||
|
||||
private static string GetCellTextForNumeric(Cell cell, List<string> allSharedStrings)
|
||||
static string GetCellTextForNumeric(Cell cell, List<string> allSharedStrings)
|
||||
{
|
||||
if (cell?.CellValue == null) return string.Empty;
|
||||
|
||||
@@ -366,7 +366,7 @@ internal static class ReplaceNumericExtensions
|
||||
return val;
|
||||
}
|
||||
|
||||
private static void SetCellText(Cell cell, string newText,
|
||||
static void SetCellText(Cell cell, string newText,
|
||||
List<string> allSharedStrings, Dictionary<string, int> sharedStringIndexMap)
|
||||
{
|
||||
if (cell.InlineString != null)
|
||||
@@ -388,7 +388,7 @@ internal static class ReplaceNumericExtensions
|
||||
cell.CellValue = new CellValue(index.ToString());
|
||||
}
|
||||
|
||||
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>();
|
||||
@@ -399,7 +399,7 @@ internal static class ReplaceNumericExtensions
|
||||
sharedStringTable.Save();
|
||||
}
|
||||
|
||||
private static string ConcatTexts(IEnumerable<Text> texts)
|
||||
static string ConcatTexts(IEnumerable<Text> texts)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var t in texts)
|
||||
@@ -408,7 +408,7 @@ internal static class ReplaceNumericExtensions
|
||||
}
|
||||
|
||||
// Оптимизированная замена подстроки через string.Create (без unsafe)
|
||||
private static unsafe string ReplaceSubstring(string original, int start, int length, string replacement)
|
||||
static unsafe string ReplaceSubstring(string original, int start, int length, string replacement)
|
||||
{
|
||||
if (length == 0) return original;
|
||||
int newLen = original.Length - length + replacement.Length;
|
||||
@@ -428,7 +428,7 @@ internal static class ReplaceNumericExtensions
|
||||
}
|
||||
}
|
||||
|
||||
private static uint CreateNumberFormat(WorkbookPart workbookPart, string format)
|
||||
static uint CreateNumberFormat(WorkbookPart workbookPart, string format)
|
||||
{
|
||||
var stylesPart = workbookPart.WorkbookStylesPart;
|
||||
if (stylesPart == null)
|
||||
@@ -457,7 +457,7 @@ internal static class ReplaceNumericExtensions
|
||||
|
||||
// =========================== КОЛОНТИТУЛЫ И КОММЕНТАРИИ ===========================
|
||||
|
||||
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;
|
||||
@@ -468,7 +468,7 @@ internal static class ReplaceNumericExtensions
|
||||
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;
|
||||
@@ -477,7 +477,7 @@ internal static class ReplaceNumericExtensions
|
||||
element.Text = processed;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -493,7 +493,7 @@ internal static class ReplaceNumericExtensions
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -505,7 +505,7 @@ internal static class ReplaceNumericExtensions
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user