Passa al contenuto principale

Class ExcelWriter

Namespace: TecnoPack.TranslationsManager.Excel
Assembly: CO0002_Templ_FlowpackHMI_V00_26_M.dll

Writes translation dictionaries to Excel worksheets.

public sealed class ExcelWriter

Inheritance

object ← ExcelWriter

Constructors

ExcelWriter(bool)

Initializes a new instance of .

public ExcelWriter(bool withLookup = false)

Parameters

withLookup bool

Methods

AddWorksheet(string, TranslationDictionary, string)

Adds a worksheet with the given name and translation dictionary to the workbook. Also appends the original path and sheet name to the lookup worksheet if provided.

public void AddWorksheet(string sheetName, TranslationDictionary dictionary, string path = null)

Parameters

sheetName string

The worksheet name to use in the Excel workbook.

dictionary TranslationDictionary

The translation dictionary to write to the worksheet.

path string

Optional. The original node path of the dictionary. If provided, this will be appended to the lookup worksheet in column A, with the sheet name in column B.

SaveAs(string)

Saves the workbook to the specified file path.

public void SaveAs(string filePath)

Parameters

filePath string

The file path to save the workbook.

SaveToByteArray()

Saves the current Excel workbook into an in-memory byte array. This allows the workbook to be used without creating a physical file on disk.

public byte[] SaveToByteArray()

Returns

byte[]

A byte array containing the serialized Excel workbook.

Examples

ExcelWriter writer = new ExcelWriter();
writer.AddWorksheet("MySheet", myDictionary);
byte[] excelData = writer.SaveToByteArray();
File.WriteAllBytes("translations.xlsx", excelData);

WorksheetExists(string)

Checks if a worksheet name already exists in the workbook.

public bool WorksheetExists(string sheetName)

Parameters

sheetName string

The worksheet name to check.

Returns

bool

True if the name exists, otherwise false.

  • Constructors
    • ExcelWriter(bool)
  • Methods
    • AddWorksheet(string, TranslationDictionary, string)
    • SaveAs(string)
    • SaveToByteArray()
    • WorksheetExists(string)