Esempio n. 1
0
        //.....................................................................
        /// <summary>
        /// 使用  H1-list-style.docx
        ///
        /// 列出全部 stylex
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonListStyles_Click(object sender, EventArgs e)
        {
            OpenDocxBase test = new  OpenDocxBase( );

            test.OpenExistDocx("D:\\123-test-openxml\\h1.docx", false);

            //MessageBox.Show( "Alles in Ordnung!!!" );
            Process.Start("explorer.exe", test.NamePath);

            this.Close( );
            return;
        }
        //.....................................................................
        /// <summary>
        ///
        /// </summary>
        /// <param name="listing"></param>
        public void MakeTableRow(List <string> listing, double height)
        {
            int cellwidt = ( int )(OPENXML_A4MM_USER / this.Colnum);

            TableRow rowline = new TableRow( )
            {
                RsidTableRowAddition = "005823AE", RsidTableRowProperties = "00226BAF"
            };

            TableRowHeight rowheight = new TableRowHeight( )
            {
                Val = OpenDocxBase.MM2Uint32V(height)
            };

            rowline.Append(rowheight);

            int idx = 0;

            foreach (string line in listing)
            {
                idx++;
                int align = 1;
                if (idx == 2)
                {
                    align = 2;
                }
                if (idx == 3)
                {
                    align = 3;
                }

                rowline.Append(this.MakeTableCell(line, cellwidt, align));
            }

            this.Tisch.Append(rowline);
        }
        //.....................................................................
        /// <summary>
        ///
        /// </summary>
        /// <param name="txtline"></param>
        /// <returns></returns>
        private TableCell MakeTableCell(string txtline, int widthMM, int align = 1)
        {
            UInt32Value uint32ww = OpenDocxBase.MM2Uint32V(widthMM);

            //.............................................
            TableCellWidth zellwidth = new TableCellWidth( )
            {
                Width = uint32ww.ToString(), /*widthMM.ToString( ),*/ Type = TableWidthUnitValues.Dxa
            };

            TableCellVerticalAlignment zellVertAlign = new TableCellVerticalAlignment( )
            {
                Val = TableVerticalAlignmentValues.Center
            };

            TableCellProperties zellProperties = new TableCellProperties( );

            zellProperties.Append(zellwidth);
            zellProperties.Append(zellVertAlign);

            //.............................................
            Justification justRIGHT = new Justification( )
            {
                Val = JustificationValues.Right
            };
            Justification justCENTER = new Justification( )
            {
                Val = JustificationValues.Center
            };

            ParagraphProperties paraProperties = new ParagraphProperties( );

            if (align == 2)
            {
                paraProperties.Append(justCENTER);
            }
            if (align == 3)
            {
                paraProperties.Append(justRIGHT);
            }

            //.............................................

            RunFonts runFonts = new RunFonts( )
            {
                Hint = FontTypeHintValues.EastAsia
            };

            RunProperties textRunProperties = new RunProperties( );

            textRunProperties.Append(runFonts);

            Run runOBJ = new Run( );

            runOBJ.Append(textRunProperties);
            runOBJ.Append(new Text( )
            {
                Text = txtline
            });

            //.............................................
            Paragraph paragraph = new Paragraph( )
            {
                RsidParagraphAddition = "005823AE", RsidRunAdditionDefault = "005823AE"
            };

            paragraph.Append(paraProperties);
            paragraph.Append(runOBJ);

            //.............................................
            TableCell tableZELL = new TableCell( );

            tableZELL.Append(zellProperties);
            tableZELL.Append(paragraph);

            return(tableZELL);
        }