public void Set(Bonn.CellReference position, string value) { while (Rows.Count < position.rowIndex) { AppendRow(); } var row = Rows[(int)position.rowIndex - 1]; while (row.Cells.Count < position.columnIndex) { row.Cells.Add(""); } row.Cells[(int)position.columnIndex - 1] = value; }
public void ToXlsx(string filename) { using var document = SpreadsheetDocument.Create(filename, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook); var excel = new Bonn.Document(document); foreach (var it in Sheets) { var sheet = excel.CreateSheet(it.Name); for (int i = 0; i < it.Rows.Count; ++i) { var row = it.Rows[i]; for (int j = 0; j < row.Cells.Count; ++j) { var cell = row.Cells[j]; var position = new Bonn.CellReference((uint)(j + 1), (uint)(i + 1)); sheet.SetCellValue(position, cell); } } } document.Save(); }