Пример #1
0
        /// <summary>
        /// Добавление формулы с ссылкой
        /// </summary>
        /// <param name="text">Формула</param>
        /// <param name="ReferenceStr">Ссылка формулы</param>
        public void Add_TechFormulaWithReference(string text, string ReferenceStr)
        {
            OXMLTableWrap table = new OXMLTableWrap(2, 1, TableNormalStyle, null);

            table.GetCell(0, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;
            table.GetCell(1, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;

            table.Columns[0].Width = 16.0f;
            table.Columns[1].Width = 1.0f;

            table.GetCell(0, 0).margins.LeftMargin = 12;
            doc.AddMathFormulaToParagraph(table.GetCell(0, 0).paragraph, text);

            table.GetCell(1, 0).paragraph.AddText(ReferenceStr);

            var param = new OXMLTableBorderParam();	//убираем границы таблицы
            param.bVal = "None";
            param.bColor = "auto";
            param.bSpace = 0;
            param.bSize = 0;
            table.borders.AllBorders = param;

            doc.AddTable(table);
        }
Пример #2
0
        public void TestMathFormulaWithRef()
        {
            try
            {

                OXMLDocWrap doc = new OXMLDocWrap();
                doc.OpenDocument(@"..\..\test\TestModule.docx");

                    OXMLTableWrap table = new OXMLTableWrap(2, 1, doc.TableStyles.Find(x => x.StyleID =="a5"), null);

                    table.Rows[0].setHeightWithRule(2, OXMLHeightRuleValues.Auto);

                    table.GetCell(0, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;
                    table.GetCell(1, 0).paragraph.TextAlignmentH = TextAlignmentHoriz.Center;

                    table.Columns[0].Width = 16.0f;
                    table.Columns[1].Width = 1.0f;

                    table.GetCell(0, 0).margins.LeftMargin = 12;
                    doc.AddMathFormulaToParagraph(table.GetCell(0, 0).paragraph, @"F=\SUP((\FRAC(1)(2)))(4)+1");

                    table.GetCell(1, 0).paragraph.AddText("(1)");

                    var param = new OXMLTableBorderParam();
                    param.bVal = "None";
                    param.bColor = "auto";
                    param.bSpace = 0;
                    param.bSize = 0;

                    table.borders.AllBorders = param;
                    doc.AddTable(table);

                doc.CloseDocument();

            } catch (Exception e)
            {
                Assert.Fail("EXCEPT: " + e.Message);
            }

            Assert.Pass();
        }
Пример #3
0
 void SetBorderType(BorderType BT, OXMLTableBorderParam param)
 {
     Type t = typeof(BorderValues);
     var element = Enum.Parse(t, param.bVal);
     BT.Val   = (BorderValues)element;
     BT.Color = param.bColor;
     BT.Size  = param.bSize;
     BT.Space = param.bSpace;
 }