8using System.Collections.Generic;
9using NanoXLSX.Interfaces;
10using NanoXLSX.Interfaces.Reader;
11using NanoXLSX.Registry;
12using NanoXLSX.Registry.Attributes;
16 [NanoXlsxQueuePlugIn(PlugInUUID =
"FORMATTED_TEXT_SHARED_STRINGS_REPLACER", QueueUUID = PlugInUUID.FinalizingInlineProcessor, PlugInOrder = 1000)]
17 internal class SharedStringsReplacer : IPluginInlineReadProcessor
23 public IOptions Options {
get;
set; }
27 public Workbook Workbook {
get;
set; }
37 public void Init(Workbook workbook, IOptions readerOptions,
int? index =
null)
39 this.Workbook = workbook;
40 this.Options = readerOptions;
48 Dictionary<string, FormattedText> formattedTexts = Workbook.AuxiliaryData.GetData<Dictionary<string, FormattedText>>(PlugInUUID.SharedStringsReader, FormattedSharedStringsReader.AUXILIARY_DATA_ID);
49 if (formattedTexts ==
null)
53 for (
int i = 0; i < Workbook.Worksheets.Count; i++)
55 Worksheet sheet = Workbook.Worksheets[i];
56 foreach (KeyValuePair<string, FormattedText> entry
in formattedTexts)
58 List<Cell> cells = sheet.CellsByValue(entry.Key);
59 if (cells !=
null && cells.Count > 0)
61 foreach (Cell cell
in cells)
63 sheet.Cells[cell.CellAddress].Value = entry.Value;