public void WriteInfoAboutSourceToExcel() { CProductCalc productCalc = new CProductCalc(); List <CFactory> factList = productCalc.GetFactoryList(); Worksheet pSourceSheet = m_pBook.Worksheets.Add(); pSourceSheet.Name = GetUniqueSheetName("FullSource"); int currentRow = 1 + 1; 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); Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 1, m_Spisok.GetName(tagInput[i]), 20); Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 2, m_Spisok.GetName(pTag), 10); Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 3, TagCount.ToString()); currentRow++; } } } }
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; } } } }