using Spire.Xls; using Spire.Xls.Core; using System; using System.IO; namespace HStation.RevitDev.RevitDataExport.Utility { internal class ExcelHelper { private Workbook _workbook; private Worksheet _sheet; public ExcelHelper() { Workbook workbook = new Workbook(); workbook.Worksheets.Clear(); _workbook = workbook; } internal void SetCurrentSheet(string sheetName) { if (_workbook.Worksheets[sheetName] == null) { _sheet = _workbook.Worksheets.Add(sheetName); } } internal void SaveAs(string filePath) { _workbook.SaveToFile(filePath); } internal void Write(int rowIndex, int columnIndex, string content) { _sheet.Range[rowIndex, columnIndex].Value = content; } private static char[] InvalidChars = { ':', ':', '\\', '/', '?', '?', '【', '[', ']', '】', '*' }; public static string UniformSheetName(string name) { foreach (var invalidChar in InvalidChars) { name = name.Replace(invalidChar, '-'); } return name; } } }