private List <ColummnNoklName> GetColummn(List <ShahmatcaModel> shahmatcaModels) { int numberColummn = 0; List <ColummnNoklName> colummnNoklNames = new List <ColummnNoklName>(); foreach (ShahmatcaModel shahmatcaModel in shahmatcaModels) { ColummnNoklName colummnNoklName = colummnNoklNames.FirstOrDefault(c => c.NameNomkl == shahmatcaModel.Nomenclature); if (colummnNoklName == null) { colummnNoklNames.Add(new ColummnNoklName() { NameNomkl = shahmatcaModel.Nomenclature, NumberColummn = numberColummn }); numberColummn++; } } return(colummnNoklNames); }
private void CreatXMLSSumme(SpreadsheetDocument spreadsheetDocument, ref int i, List <ColummnNoklName> colummnNoklNames, List <RowManagerContrAgGr> rowManagerContrAgGrs, List <ShahmatcaModel> shahmatcaModels, WorksheetPart worksheetPart) { SharedStringTablePart shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); string nameColummn = GetCharOfTabel(0); InsertSharedStringItem("Группа контрагентов", shareStringPart); Cell cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + 3), worksheetPart, 1, 80); cell.CellValue = new CellValue(i.ToString()); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); worksheetPart.Worksheet.Save(); i++; shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); nameColummn = GetCharOfTabel(1); InsertSharedStringItem("Контрагент/Номенклатура", shareStringPart); cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + 3), worksheetPart, 1, 80); cell.CellValue = new CellValue(i.ToString()); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); worksheetPart.Worksheet.Save(); i++; foreach (ColummnNoklName colummnNoklName in colummnNoklNames) { shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); nameColummn = GetCharOfTabel(colummnNoklName.NumberColummn + 2); InsertSharedStringItem(colummnNoklName.NameNomkl, shareStringPart); cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + 3), worksheetPart, 2, 80); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); cell.CellValue = new CellValue(i.ToString()); worksheetPart.Worksheet.Save(); i++; } foreach (RowManagerContrAgGr rowManagerContrAgGr in rowManagerContrAgGrs) { shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); InsertSharedStringItem(rowManagerContrAgGr.GR_Contragent, shareStringPart); cell = InsertCellInWorksheet("A", (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 1, 30); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); cell.CellValue = new CellValue(i.ToString()); worksheetPart.Worksheet.Save(); i++; shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); InsertSharedStringItem(rowManagerContrAgGr.Contragent, shareStringPart); cell = InsertCellInWorksheet("B", (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 1, 30); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); cell.CellValue = new CellValue(i.ToString()); worksheetPart.Worksheet.Save(); i++; nameColummn = GetCharOfTabel(colummnNoklNames.Count + 2); shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); InsertSharedStringItem(rowManagerContrAgGr.Manager, shareStringPart); cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 1, 30); cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); cell.CellValue = new CellValue(i.ToString()); worksheetPart.Worksheet.Save(); i++; } foreach (ShahmatcaModel shahmatcaModel in shahmatcaModels) { ColummnNoklName colummnNoklName = colummnNoklNames.FirstOrDefault(c => c.NameNomkl == shahmatcaModel.Nomenclature); RowManagerContrAgGr rowManagerContrAgGr = rowManagerContrAgGrs.FirstOrDefault(r => r.Contragent == shahmatcaModel.Contragent); if (rowManagerContrAgGr != null) { shareStringPart = GetSharedStringTablePart(spreadsheetDocument.WorkbookPart); nameColummn = GetCharOfTabel(colummnNoklName.NumberColummn + 2); InsertSharedStringItem(shahmatcaModel.Summa, shareStringPart); if (shahmatcaModel.SummaColor == "R" || shahmatcaModel.SummaColor == "Н") { cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 4, 30); } else if (shahmatcaModel.SummaColor == "B") { cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 5, 30); } else if (shahmatcaModel.SummaColor == "W") { cell = InsertCellInWorksheet(nameColummn, (UInt32)(rowManagerContrAgGrs.Count + rowManagerContrAgGr.NumberRow + 4), worksheetPart, 3, 30); } cell.DataType = new EnumValue <CellValues>(CellValues.SharedString); cell.CellValue = new CellValue(i.ToString()); worksheetPart.Worksheet.Save(); i++; } } }