/// <summary> /// List<Form> Init(int toc_line) - initiate all Forms for Document in toc_line. /// </summary> /// <param name="toc_line">line number in TOC</param> /// <returns>form list</returns> public static List<Form> Init(int toc_line) { Log.set("Init(" + toc_line + ")"); //------------------------------------------------------------------------------ language = true; //en-US for Englisg Debug. Remove or comment this line later ! //------------------------------------------------------------------------------ List<Form> Forms = new List<Form>(); for (int col = Decl.DOC_FORMS, i = 0; i < 10; i++) { string s = Lang(tocMtr.Strng(toc_line, col++)); if (string.IsNullOrEmpty(s)) continue; if (FileOp.isNamedRangeExist(Wb, s)) { List<int> _r = new List<int>(); List<int> _c = new List<int>(); string sf = s + "_F"; if (FileOp.isNamedRangeExist(Wb, sf)) { Mtr format = new Mtr(Wb.Names.Item(sf).RefersToRange.Value); for (int c = 1; c <= format.iEOC(); c++) for (int r = 1; r <= format.iEOL(); r++) { string f = format.Strng(r, c); if (f.Contains("{") & f.Contains("}")) { _r.Add(r); _c.Add(c); } } } Forms.Add(new Form(s, _r, _c)); } } Log.exit(); return Forms; }
public static void saveRngValue(Mtr Body, int rowToPaste = 1, bool AutoFit = true, string msg = "") { Log.set("saveRngValue"); int r0 = Body.LBoundR(), r1 = Body.iEOL(), //!! c0 = Body.LBoundC(), c1 = Body.iEOC(); //!! try { object[,] obj = new object[r1, c1]; for (int i = 0; i < r1; i++) { for (int j = 0; j < c1; j++) { obj[i, j] = Body[i + 1, j + 1]; } } r1 = r1 - r0 + rowToPaste; r0 = rowToPaste; Excel.Range cell1 = _sh.Cells[r0, c0]; Excel.Range cell2 = _sh.Cells[r1, c1]; Excel.Range rng = _sh.Range[cell1, cell2]; rng.Value = obj; if (AutoFit) { for (int i = 1; i <= c1; i++) { _sh.Columns[i].AutoFit(); } } } catch (Exception e) { if (msg == "") { msg = "Range[ [" + r0 + ", " + c0 + "] , [" + r1 + ", " + c1 + "] ]"; } Log.FATAL(msg); } Log.exit(); }
/// <summary> /// Start(TOCdir) - prepare further works with the Documents; setup data from TOC /// </summary> /// <param name="FileDir">Directory, Path to TSmatch.xlsx</param> /// <history> 22.1.2016 /// 12.3.2016 - multilanguage Heders support /// 14.3.2016 - Form class support /// 19.3.2016 - use EOL method /// 30.3.2016 - Start(TOCdir) and getDoc with #template interaction with Bootstrap /// 17.4.2016 - tocStart extracted from Start for initial TOC open /// </history> public static void Start(Dictionary<string, string> _Templates) { Log.set("Document.Start(#Templates)"); Templates = _Templates; //2/8 Document toc = tocStart(Templates["#TOC"]); toc = tocStart(Templates["#TOC"]); Mtr mtr = toc.Body; for (int i = toc.i0; i <= toc.il; i++) { string docName = mtr.Strng(i, Decl.DOC_NAME); if (docName != "") { Document doc = new Document(docName); // mtr относится только к TOCmatch, а не ко всем Документам, //.. то есть реально загружаем ТОС, а остальные Документы- потом if (doc.name == Decl.DOC_TOC) doc = toc; Documents.Add(docName, doc); doc.MadeTime = Lib.getDateTime(mtr[i, Decl.DOC_TIME]); doc.ResLines = Lib.ToIntList(mtr.Strng(i, Decl.DOC_TYPE), '/'); doc.MadeStep = mtr.Strng(i, Decl.DOC_MADESTEP); doc.FileName = mtr.Strng(i, Decl.DOC_FILE); doc.FileDirectory = mtr.Strng(i, Decl.DOC_DIR); doc.type = mtr.Strng(i, Decl.DOC_TYPE); doc.isNewDoc = (doc.type == Decl.DOC_TYPE_N); doc.SheetN = mtr.Strng(i, Decl.DOC_SHEET); if (doc.type == Decl.TSMATCH_TYPE) doc.Sheet = toc.Wb.Worksheets[doc.SheetN]; doc.creationDate = Lib.getDateTime(mtr[i, Decl.DOC_CREATED]); doc.Supplier = mtr.Strng(i, Decl.DOC_SUPPLIER); doc.LoadDescription = mtr.Strng(i, Decl.DOC_STRUCTURE_DESCRIPTION); doc.forms = Form.Init(i); doc.Loader = mtr.Strng(i, Decl.DOC_LOADER); doc.EOL(i); int j; for (j = i + 1; j <= mtr.iEOL() && mtr.Strng(j, Decl.DOC_NAME) == ""; j++) ; doc.stamp = new Stamp(i, j - 1); } //if docName !="" } // for по строкам TOC Log.exit(); } // end Start
public static void saveRngValue(Mtr Body, int rowToPaste = 1, bool AutoFit = true, string msg = "") { Log.set("saveRngValue"); int r0 = Body.LBoundR(), r1 = Body.iEOL(), //!! c0 = Body.LBoundC(), c1 = Body.iEOC(); //!! try { object[,] obj = new object[r1, c1]; for (int i = 0; i < r1; i++) for (int j = 0; j < c1; j++) obj[i, j] = Body[i + 1, j + 1]; r1 = r1 - r0 + rowToPaste; r0 = rowToPaste; Excel.Range cell1 = _sh.Cells[r0, c0]; Excel.Range cell2 = _sh.Cells[r1, c1]; Excel.Range rng = _sh.Range[cell1, cell2]; rng.Value2 = obj; if( AutoFit) for (int i = 1; i <= c1; i++) _sh.Columns[i].AutoFit(); } catch (Exception e) { if (msg == "") { msg = "Range[ [" + r0 + ", " + c0 + "] , [" + r1 + ", " + c1 + "] ]"; } Log.FATAL(msg); } Log.exit(); }