private int WriteFactory(Worksheet pSheet, CFactory pFactory, int row, int column) { List <ProductTag> input = pFactory.GetInputArray(); int realCount = 0; string factoryName = pFactory.GetFactName(); pSheet.Cells[row, column] = factoryName; Range pTitleRange = Utils.GetRange(pSheet, row, column, row, column + 4); pTitleRange.Merge(); pTitleRange.Interior.Color = Color.Bisque; realCount++; for (int i = 0; i < input.Count; i++) { ProductTag tag = input[i]; int value = pFactory.GetTagCount(tag); int currRow = row + realCount; string tagName = m_spisok.GetName(tag); if (value > 0) { realCount++; pSheet.Cells[currRow, column].ColumnWidth = 20; Utils.WriteTagString(pSheet, currRow, column, tagName, value); } } return(realCount); }
private void DefaultStyle() { Range FullRange = m_pSheet.Range[m_pSheet.Cells[m_startRow, m_startColumn], m_pSheet.Cells[m_startRow + 7, m_startColumn + 4]]; for (int i = (int)XlBordersIndex.xlEdgeLeft; i <= (int)XlBordersIndex.xlInsideHorizontal; i++) { FullRange.Borders[(XlBordersIndex)i].LineStyle = XlLineStyle.xlContinuous; } FullRange = m_pSheet.Range[m_pSheet.Cells[m_startRow, m_startColumn], m_pSheet.Cells[m_startRow, m_startColumn + 4]]; FullRange.Merge(); FullRange.Value = m_pFactory.GetFactName(); int delta = 0; m_pSheet.Cells[m_startRow, m_startColumn].ColumnWidth = 20; Utils.UpdateCell(m_pSheet, m_startRow + 1, m_startColumn + 1 + delta++, "Надо"); Utils.UpdateCell(m_pSheet, m_startRow + 1, m_startColumn + 1 + delta++, "Процесс"); Utils.UpdateCell(m_pSheet, m_startRow + 1, m_startColumn + 1 + delta++, "Готов"); Utils.UpdateCell(m_pSheet, m_startRow + 1, m_startColumn + 1 + delta++, "Осталось"); }
public void WriteInfoAboutFactroryToExcel() { List <ProductSourceInfo> PSInfo = new List <ProductSourceInfo>(); CProductCalc productCalc = new CProductCalc(); List <CFactory> factList = productCalc.GetFactoryList(); //Worksheet pSourceSheet = m_pBook.Worksheets.Add(); //pSourceSheet.Name = GetUniqueSheetName("FullSource"); for (int factNo = 0; factNo < factList.Count; factNo++) { Kernal.CFactory factory = factList[factNo]; List <Kernal.ProductTag> tagInput = factory.GetInputArray(); for (int i = 0; i < tagInput.Count; i++) { Kernal.CSmartArray array = new Kernal.CSmartArray(); array.Add(tagInput[i], 1); factory.SetInput(array); factory.Calc(); Kernal.CSmartArray result = new Kernal.CSmartArray(); factory.UpdateResult(result); Dictionary <ProductTag, int> map = result.GetMap(); int count = map.Count; var en = map.Keys.GetEnumerator(); en.MoveNext(); for (int j = 0; j < count; j++) { ProductTag pTag = en.Current; en.MoveNext(); int TagCount = result.GetTagCount(pTag); PSInfo.Add(new ProductSourceInfo(tagInput[i], pTag, TagCount)); } } } Dictionary <ProductTag, List <ProductInfo> > InfoArray = new Dictionary <ProductTag, List <ProductInfo> >(); for (int i = 0; i < PSInfo.Count; i++) { ProductSourceInfo info = PSInfo[i]; if (!InfoArray.ContainsKey(info.m_SourceTag)) { InfoArray[info.m_SourceTag] = new List <ProductInfo>(); } InfoArray[info.m_SourceTag].Add(new ProductInfo(info.m_ProductTag, info.m_Value)); } int FactCount = Enum.GetNames(typeof(FactoryType)).Length; for (int FactNo = 0; FactNo < FactCount; FactNo++) { CFactory pFact = CreateFactory((FactoryType)FactNo); string FactName; if (pFact == null) { if ((FactoryType)FactNo == FactoryType.ftField) { FactName = "поля"; } else { continue; } } else { FactName = pFact.GetFactName(); } Worksheet pSourceSheet = m_pBook.Worksheets.Add(); pSourceSheet.Name = GetUniqueSheetName(FactName); int CurrentColumn = 1; var e = InfoArray.Keys.GetEnumerator(); for (int i = 0; i < InfoArray.Count; i++) { e.MoveNext(); ProductTag tag = e.Current; if (m_Spisok.GetFactoryType(tag) == (FactoryType)FactNo) { List <ProductInfo> list = InfoArray[tag]; Kernal.Utils.UpdateCell(pSourceSheet, 1, CurrentColumn, m_Spisok.GetName(tag), 20); Range pTitleRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, 1, CurrentColumn + 1); pTitleRange.Merge(); for (int ProductNo = 0; ProductNo < list.Count; ProductNo++) { ProductInfo info = list[ProductNo]; Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn, m_Spisok.GetName(info.m_SourceTag), 20); Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn + 1, info.m_Value.ToString(), 4); } Range pRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, list.Count + 1, CurrentColumn + 1); for (int borderNo = (int)XlBordersIndex.xlEdgeLeft; borderNo <= (int)XlBordersIndex.xlInsideHorizontal; borderNo++) { pRange.Borders[(XlBordersIndex)borderNo].LineStyle = XlLineStyle.xlContinuous; } CurrentColumn += 2; } } } }