private static void AddTable(ExcelDoc d, string name, double[] columnsSize, string[] header, string[,] content) { if (columnsSize == null || header == null || content == null || columnsSize.Length != header.Length || columnsSize.Length != content.GetLength(1)) { throw new Exception("Входные параметры имели не верный формат"); } if (columnsSize.Length == 0) { return; } ExcelSheet s = d.AddSheet(name); s.CreateColumns(columnsSize); for (int c = 0; c < columnsSize.Length; c++) { if (!string.IsNullOrEmpty(header[c]) && header[c][0] == '=') { s.SetCellFormulaValue(0, c, header[c], false, ValueTypes.String, CellStyles.BoldBorderCenter); } else { s.SetCellStringValue(0, c, header[c], ValueTypes.String, CellStyles.BoldBorderCenter); } } for (int r = 0; r < content.GetLength(0); r++) { for (int c = 0; c < content.GetLength(1); c++) { if (!string.IsNullOrEmpty(content[r, c]) && content[r, c][0] == '=') { s.SetCellFormulaValue(r + 1, c, content[r, c], false, ValueTypes.String, CellStyles.NormalBorderLeft); } else { s.SetCellStringValue(r + 1, c, content[r, c], ValueTypes.String, CellStyles.NormalBorderLeft); } } } d.Save(); d.Close(); }
internal void Dispose() { Parent = null; }
internal SheetCells(ExcelSheet parent) { Parent = parent; }