Ejemplo n.º 1
0
        public void AddTable()
        {
            try
            {

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

                OXMLTableStyleWrap tStyle = doc.TableStyles.Find(x => x.StyleID =="a5");
                OXMLTableWrap table = new OXMLTableWrap(4, 7, tStyle, null);

                table.GetCell(2, 2).TextAlignmentV = TextAlignmentVert.Bottom;
                table.GetCell(2, 2).paragraph.TextAlignmentH = TextAlignmentHoriz.Right;
                table.GetCell(2, 2).paragraph.AddText("YES");

                table.Rows[1].Height = 2.5F;
                table.Columns[1].Width = 2.5F;

                //if (table.CountColumns != 4) Assert.Fail("Count columns failt: " + table.CountColumns);
                //if (table.CountRows != 4) Assert.Fail("Count Rows failt: " + table.CountRows);

                //table.SetRowHeight(1, 2);
                //table.SetColumnWidth(1, 3);

                doc.AddTable(table);

                doc.CloseDocument();

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

            Assert.Pass();
        }
Ejemplo n.º 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();
        }