private void FillRange(Excel.Worksheet sheet, int startR, int startC, RevitDataSection section) { Excel.Range range = sheet.Range[sheet.Cells[startR, startC], sheet.Cells[startR + section.Height - 1, startC + section.Width - 1]]; range.Value = section.ValueMatrix; }
private RevitDataTable GetRevitDataTable(ViewSchedule schedule) { ScheduleDefinition scheduleDefinition = schedule.Definition; TableSectionData bodyData = schedule.GetTableData().GetSectionData(SectionType.Body); TableSectionData headerData = schedule.GetTableData().GetSectionData(SectionType.Header); RevitDataTable dataTable = new RevitDataTable(schedule.Name); RevitDataSection dataSection = new RevitDataSection("Без названия"); dataTable.Sections.Add(dataSection); // заголовки int start_i; if (scheduleDefinition.ShowHeaders) { RevitDataRow header = new RevitDataRow(0); for (int col = 0; col < bodyData.NumberOfColumns; col++) { RevitDataCell dataCell = new RevitDataCell( schedule.GetCellText(SectionType.Body, 0, col), bodyData.GetCellType(0, col), bodyData.GetCellParamId(col)); header.Cells.Add(dataCell); } start_i = 1; dataTable.Header = header; } else { start_i = 0; } //ищем секции for (int row = start_i; row < bodyData.NumberOfRows; row++) { if (bodyData.GetCellType(row, 0) == CellType.Text && bodyData.GetMergedCell(row, 0).Right == bodyData.LastColumnNumber) { string header = bodyData.GetCellText(row, 0); header = string.IsNullOrEmpty(header) ? "Без названия" : header; dataSection = new RevitDataSection(header); dataTable.Sections.Add(dataSection); continue; } RevitDataRow dataRow = new RevitDataRow(row); for (int col = 0; col < bodyData.NumberOfColumns; col++) { RevitDataCell dataCell = new RevitDataCell( schedule.GetCellText(SectionType.Body, row, col), bodyData.GetCellType(row, col), bodyData.GetCellParamId(col)); dataRow.Cells.Add(dataCell); } dataSection.Rows.Add(dataRow); } if (dataTable["Без названия"].Rows.Count == 0) { dataTable.Sections.Remove(dataTable["Без названия"]); } return(dataTable); }