/// <summary> /// /// </summary> /// <returns></returns> private Paragraph MakeP1( ) { Paragraph paragraphNORM = new Paragraph( ) { RsidParagraphMarkRevision = "00985895", RsidParagraphAddition = "00337477", RsidRunAdditionDefault = "00985895" }; M.Justification justification = new M.Justification( ) { Val = M.JustificationValues.Right }; M.ParagraphProperties paraProperties = new M.ParagraphProperties( ); paraProperties.Append(justification); M.Paragraph paragraphMATH = new M.Paragraph( ); M.OfficeMath paraMathLine = new M.OfficeMath( ); M.Run run1 = OpenDocxMathExprs.MakeMathRun("x=1+2/3=1.6667"); // new M.Run( ); paraMathLine.Append(run1); paragraphMATH.Append(paraMathLine); paragraphMATH.Append(paraProperties); paragraphNORM.Append(paragraphMATH); return(paragraphNORM); }
//..................................................................... /// <summary> /// 公式中名称是正文样式,没有斜体 /// </summary> /// <param name="mathlin"></param> /// <returns></returns> public static M.Run MakeMathRun(string mathlin, bool plainstyle = false) { //M.Style fontstyle = new M.Style( ) { Val = M.StyleValues.Plain }; //RunFonts fonts = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math" }; RunProperties properties = new RunProperties( ); properties.Append(OpenDocxMathExprs.MakeMathFont( )); if (plainstyle) { properties.Append(OpenDocxMathExprs.MakeMathFonStyle( )); } //--------------------------------------------- M.Text mathtext = new M.Text( ); mathtext.Text = mathlin; //--------------------------------------------- M.Run mathrun = new M.Run( ); mathrun.Append(properties); mathrun.Append(mathtext); return(mathrun); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private Paragraph MakeP2( ) { Paragraph paragraph3 = new Paragraph( ) { RsidParagraphMarkRevision = "00985895", RsidParagraphAddition = "00985895", RsidRunAdditionDefault = "00985895" }; M.Paragraph paragraph4 = new M.Paragraph( ); M.OfficeMath officeMath2 = new M.OfficeMath( ); M.Run run3 = OpenDocxMathExprs.MakeMathRun("y=2+1"); // new M.Run( ); officeMath2.Append(run3); M.Justification justification = new M.Justification( ) { Val = M.JustificationValues.Left }; M.ParagraphProperties paraProperties = new M.ParagraphProperties( ); paraProperties.Append(justification); paragraph4.Append(paraProperties); paragraph4.Append(officeMath2); paragraph3.Append(paragraph4); return(paragraph3); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathB2( ) { OpxM.Run mathrun = new OpxM.Run( ); mathrun.Append(this.CambriaFont( )); mathrun.Append(this.SimpleMathText("b")); return(mathrun); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathX( ) { OpxM.Run run1 = new OpxM.Run( ); run1.Append(this.CambriaFont( )); run1.Append(this.SimpleMathText("x")); return(run1); }
//..................................................................... /// <summary> /// 开方 的 2 3 4 /// </summary> /// <param name="value"></param> /// <returns></returns> public static M.Degree MakeMathDegree(string value) { M.Run mathrun = OpenDocxMathExprs.MakeMathRun(value); M.Degree degree = new M.Degree( ); degree.Append(mathrun); return(degree); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathA( ) { OpxM.Run run11 = new OpxM.Run( ); run11.Append(this.CambriaFont( )); run11.Append(SimpleMathText("a")); return(run11); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathCN4( ) { OpxM.Run mathrun = new OpxM.Run( ); mathrun.Append(this.PlainStyleValue( )); mathrun.Append(this.CambriaFont( )); mathrun.Append(this.SimpleMathText("-4")); return(mathrun); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> public static M.FunctionName MakeFunctionName(string funcstr) { M.FunctionName funcName = new M.FunctionName( ); M.Run funcRun = OpenDocxMathExprs.MakeMathRun(funcstr, true); funcName.Append(funcRun); return(funcName); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Denominator mathDenom_2_A( ) { OpxM.Denominator denominator1 = new OpxM.Denominator( ); OpxM.Run run10 = mathNumP002( ); OpxM.Run run11 = mathA( ); denominator1.Append(OpenDocxMathExprs.MakeMathRun("2a")); denominator1.Append(run11); return(denominator1); }
private TokenList processRun(Run r) { StringBuilder innerText = new StringBuilder(); foreach (var child in r.ChildElements) { if (child is Text) { innerText.Append(((Text)child).Text); } } return(new TokenList(textRunTokenizer.Tokenize(innerText.ToString(), true))); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private M.MathFunction MakeMath003_Function( ) { M.Subscript parm1 = OpenDocxMathExprs.MakeScriptLower("A", "c,head"); M.Run parm2 = OpenDocxMathExprs.MakeMathRun(";"); M.Subscript parm3 = OpenDocxMathExprs.MakeScriptLower("A", "c,base"); M.Run parm4 = OpenDocxMathExprs.MakeMathRun("*;"); M.Subscript parm5 = OpenDocxMathExprs.MakeScriptLower("A", "c,base"); return(OpenDocxMathExprs.MakeMathFunction("min", parm1, parm2, parm3, parm4, parm5)); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathNumP002( ) { OpxM.Run run10 = new OpxM.Run( ); //OpxM.RunProperties runProperties18 = PlainStyleValue( ); //RunProperties runProperties19 = this.CambriaFont( ); //OpxM.Text text10 = new OpxM.Text( ); //text10.Text = "2"; run10.Append(this.PlainStyleValue( )); run10.Append(this.CambriaFont( )); run10.Append(this.SimpleMathText("2")); return(run10); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathB( ) { OpxM.Run mathrun = new OpxM.Run( ); //RunProperties runProperties7 = new RunProperties( ); //RunFonts runFonts = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math", EastAsia = "Cambria Math", ComplexScript = "Cambria Math" }; //runProperties7.Append( runFonts ); //OpxM.Text text4 = new OpxM.Text( ); //text4.Text = "b"; mathrun.Append(this.CambriaFont( )); mathrun.Append(this.SimpleMathText("b")); return(mathrun); }
public OXMLMathRunWrap(string text) { _text = text; XMLRun = new M.Run(); RunProperties runProperties4 = new RunProperties(); RunFonts runFonts4 = new RunFonts(){ Ascii = "Cambria Math", HighAnsi = "Cambria Math" }; Languages languages4 = new Languages(){ Val = "en-US" }; runProperties4.Append(runFonts4); runProperties4.Append(languages4); M.Text text3 = new M.Text(); text3.Text = text; XMLRun.Append(runProperties4); if (text != "") XMLRun.Append(text3); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathPM( ) { OpxM.Run mathrun = new OpxM.Run( ); //OpxM.RunProperties runProperties8 = new OpxM.RunProperties( ); //OpxM.Style style3 = new OpxM.Style( ) { Val = OpxM.StyleValues.Plain }; //runProperties8.Append( style3 ); //RunProperties propertiesRUN = new RunProperties( ); //RunFonts runFonts6 = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math", EastAsia = "Cambria Math", ComplexScript = "Cambria Math" }; //propertiesRUN.Append( runFonts6 ); //OpxM.Text text5 = new OpxM.Text( ); //text5.Text = "±"; mathrun.Append(this.PlainStyleValue( )); mathrun.Append(this.CambriaFont( )); mathrun.Append(this.SimpleMathText("±")); return(mathrun); }
private Paragraph MakeP3( ) { Paragraph paragraph3 = new Paragraph( ) { RsidParagraphMarkRevision = "00985895", RsidParagraphAddition = "00985895", RsidRunAdditionDefault = "00985895" }; M.Paragraph paragraph4 = new M.Paragraph( ); M.OfficeMath officeMath2 = new M.OfficeMath( ); M.Run run3 = OpenDocxMathExprs.MakeMathRun("z=x+y=2.667"); officeMath2.Append(run3); paragraph4.Append(officeMath2); paragraph3.Append(paragraph4); return(paragraph3); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private OpxM.Run mathMINUS( ) { OpxM.Run mathrun = new OpxM.Run( ); //OpxM.RunProperties propertiesRUN = new OpxM.RunProperties( ); //OpxM.Style headingStyle = new OpxM.Style( ) { Val = OpxM.StyleValues.Plain }; //propertiesRUN.Append( headingStyle ); //RunProperties runProperties6 = new RunProperties( ); //RunFonts runFonts4 = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math", EastAsia = "Cambria Math", ComplexScript = "Cambria Math" }; //runProperties6.Append( runFonts4 ); //OpxM.Text text3 = new OpxM.Text( ); //text3.Text = "-"; mathrun.Append(this.PlainStyleValue( )); mathrun.Append(this.CambriaFont( )); mathrun.Append(this.SimpleMathText("-")); return(mathrun); }
//..................................................................... /// <summary> /// 分子 /// </summary> /// <returns></returns> private OpxM.Numerator mathNumer_B_B2_4AC( ) { OpxM.Numerator numerator1 = new OpxM.Numerator( ); OpxM.Run run3 = mathMINUS( ); OpxM.Run run4 = mathB( ); OpxM.Run run5 = mathPM( ); //..................................................................... OpxM.Radical radical1 = new OpxM.Radical( ); OpxM.RadicalProperties radicalProperties1 = new OpxM.RadicalProperties( ); OpxM.HideDegree hideDegree1 = new OpxM.HideDegree( ) { Val = OpxM.BooleanValues.One }; OpxM.ControlProperties controlProperties2 = new OpxM.ControlProperties( ); //RunProperties runProperties10 = CambriaFont2( ); controlProperties2.Append(CambriaFont2( )); radicalProperties1.Append(hideDegree1); radicalProperties1.Append(controlProperties2); //--------------------------------------------- OpxM.Degree degree1 = new OpxM.Degree( ); OpxM.Base base1 = new OpxM.Base( ); OpxM.Superscript superscript1 = new OpxM.Superscript( ); OpxM.SuperscriptProperties superscriptProperties1 = new OpxM.SuperscriptProperties( ); OpxM.ControlProperties controlProperties3 = new OpxM.ControlProperties( ); //RunProperties runProperties11 = new RunProperties( ); //RunFonts runFonts = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math", EastAsia = "Cambria Math" }; //runProperties11.Append( runFonts ); controlProperties3.Append(this.CambriaFont2( )); superscriptProperties1.Append(controlProperties3); OpxM.Base base2 = new OpxM.Base( ); //--------------------------------------------- OpxM.Run run6 = mathB2( ); base2.Append(run6); OpxM.SuperArgument superArgument1 = new OpxM.SuperArgument( ); //--------------------------------------------- OpxM.Run run7 = mathCP2( ); //--------------------------------------------- superArgument1.Append(run7); superscript1.Append(superscriptProperties1); superscript1.Append(base2); superscript1.Append(superArgument1); OpxM.Run run8 = mathCN4( ); OpxM.Run run9 = mathAC( ); //--------------------------------------------- base1.Append(superscript1); base1.Append(run8); base1.Append(run9); radical1.Append(radicalProperties1); radical1.Append(degree1); radical1.Append(base1); numerator1.Append(run3); numerator1.Append(run4); numerator1.Append(run5); numerator1.Append(radical1); return(numerator1); }
///// <summary> ///// ///// </summary> //private string NamePath = "d:\\123-test-openxml"; ///// <summary> ///// ///// </summary> //private string NameXlsx = "easy-table.docx"; ////..................................................................... ///// <summary> ///// ///// </summary> //public void MakeWord( ) //{ // string docxfile = this.NamePath + "\\" + this.NameXlsx; // // Creates the new instance of the WordprocessingDocument class from the specified file // // WordprocessingDocument.Open(String, Boolean) method // // Parameters: // // string docxfile - docxfile is a string which contains the docxfile of the wordocument // // bool isEditable // using ( WordprocessingDocument wordocument = WordprocessingDocument.Create( docxfile, WordprocessingDocumentType.Document ) ) // { // // Defines the MainDocumentPart // MainDocumentPart mainDocxPart = wordocument.AddMainDocumentPart( ); // mainDocxPart.Document = this.GenerateDocument( ); // //mainDocxPart.Document = new Document( ); // //Body docxbody = mainDocxPart.Document.AppendChild( new Body( ) ); // //// Create a new table // //Table docxtable = new Table( ); // //// Add the table to the docxbody // //docxbody.AppendChild( docxtable ); // mainDocxPart.Document.Save( ); // } // return; //} //..................................................................... /// <summary> /// /// </summary> /// <returns></returns> public override Document GenerateDocument( ) { Document document1 = new Document( ) { MCAttributes = new MarkupCompatibilityAttributes( ) { Ignorable = "w14 wp14" } }; document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Body docxBody = new Body( ); Paragraph normParagraph = new Paragraph( ) { RsidParagraphAddition = "0037253E", RsidRunAdditionDefault = "0078119C" }; //--------------------------------------------- OpxM.Paragraph mathParagraph = new OpxM.Paragraph( ); OpxM.OfficeMath mathOffice = new OpxM.OfficeMath( ); //--------------------------------------------- OpxM.Run run1 = mathX( ); OpxM.Run run2 = mathEQ( ); mathOffice.Append(run1); mathOffice.Append(run2); //--------------------------------------------- OpxM.Fraction fraction1 = new OpxM.Fraction( ); OpxM.FractionProperties fractionProperties1 = MakeFractionProperties( ); OpxM.Numerator numerator1 = mathNumer_B_B2_4AC( ); OpxM.Denominator denominator1 = mathDenom_2_A( ); fraction1.Append(fractionProperties1); fraction1.Append(numerator1); fraction1.Append(denominator1); mathOffice.Append(fraction1); //--------------------------------------------- mathParagraph.Append(mathOffice); //--------------------------------------------- //BookmarkStart bookmarkStart1 = new BookmarkStart( ) { Name = "_GoBack", Id = "0" }; //BookmarkEnd bookmarkEnd1 = new BookmarkEnd( ) { Id = "0" }; normParagraph.Append(mathParagraph); //normParagraph.Append( bookmarkStart1 ); //normParagraph.Append( bookmarkEnd1 ); SectionProperties sectionProperties1 = new SectionProperties( ) { RsidR = "0037253E" }; PageSize pageSize1 = new PageSize( ) { Width = ( UInt32Value )11906U, Height = ( UInt32Value )16838U }; PageMargin pageMargin1 = new PageMargin( ) { Top = 1440, Right = ( UInt32Value )1800U, Bottom = 1440, Left = ( UInt32Value )1800U, Header = ( UInt32Value )851U, Footer = ( UInt32Value )992U, Gutter = ( UInt32Value )0U }; Columns columns1 = new Columns( ) { Space = "425" }; DocGrid docGrid1 = new DocGrid( ) { Type = DocGridValues.Lines, LinePitch = 312 }; sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); sectionProperties1.Append(docGrid1); docxBody.Append(normParagraph); docxBody.Append(sectionProperties1); document1.Append(docxBody); return(document1); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> public override Document GenerateDocument() { Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } }; document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Body body1 = new Body(); Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "00814392", RsidParagraphAddition = "00666F86", RsidRunAdditionDefault = "00814392" }; //--------------------------------------------- M.Paragraph paragraph2 = new M.Paragraph(); M.OfficeMath officeMath1 = new M.OfficeMath(); //--------------------------------------------- M.Radical mathpart1 = OpenDocxMathExprs.MakeMathRadical("x", "2"); M.Run mathpart2 = OpenDocxMathExprs.MakeMathRun("+"); M.Radical mathpart3 = OpenDocxMathExprs.MakeMathRadical("y", "4"); M.Run mathpart4 = OpenDocxMathExprs.MakeMathRun("=w"); //--------------------------------------------- officeMath1.Append(mathpart1); officeMath1.Append(mathpart2); officeMath1.Append(mathpart3); officeMath1.Append(mathpart4); paragraph2.Append(officeMath1); paragraph1.Append(paragraph2); //--------------------------------------------- Paragraph paragraph3 = new Paragraph() { RsidParagraphMarkRevision = "00814392", RsidParagraphAddition = "00814392", RsidRunAdditionDefault = "00814392" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); RunFonts runFonts9 = new RunFonts() { Hint = FontTypeHintValues.EastAsia }; paragraphMarkRunProperties1.Append(runFonts9); paragraphProperties1.Append(paragraphMarkRunProperties1); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" }; BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; paragraph3.Append(paragraphProperties1); paragraph3.Append(bookmarkStart1); paragraph3.Append(bookmarkEnd1); SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "00814392", RsidR = "00814392" }; PageSize pageSize1 = new PageSize() { Width = (UInt32Value)11906U, Height = (UInt32Value)16838U }; PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1800U, Bottom = 1440, Left = (UInt32Value)1800U, Header = (UInt32Value)851U, Footer = (UInt32Value)992U, Gutter = (UInt32Value)0U }; Columns columns1 = new Columns() { Space = "425" }; DocGrid docGrid1 = new DocGrid() { Type = DocGridValues.Lines, LinePitch = 312 }; sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); sectionProperties1.Append(docGrid1); body1.Append(paragraph1); body1.Append(paragraph3); body1.Append(sectionProperties1); document1.Append(body1); return(document1); }
/// <summary> /// /// </summary> /// <returns></returns> private static M.Superscript MakeScriptUpper( ) { M.Superscript superscript1 = new M.Superscript( ); M.SuperscriptProperties superscriptProperties1 = new M.SuperscriptProperties( ); M.ControlProperties controlProperties3 = new M.ControlProperties( ); RunProperties runProperties10 = new RunProperties( ); RunFonts runFonts8 = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math" }; Italic italic2 = new Italic( ); runProperties10.Append(runFonts8); runProperties10.Append(italic2); controlProperties3.Append(runProperties10); superscriptProperties1.Append(controlProperties3); M.Base base2 = new M.Base( ); M.Run run6 = new M.Run( ); RunProperties runProperties11 = new RunProperties( ); RunFonts runFonts9 = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math" }; runProperties11.Append(runFonts9); M.Text text6 = new M.Text( ); text6.Text = "x"; run6.Append(runProperties11); run6.Append(text6); base2.Append(run6); M.SuperArgument superArgument2 = new M.SuperArgument( ); M.Run run7 = new M.Run( ); RunProperties runProperties12 = new RunProperties( ); RunFonts runFonts10 = new RunFonts( ) { Ascii = "Cambria Math", HighAnsi = "Cambria Math" }; runProperties12.Append(runFonts10); M.Text text7 = new M.Text( ); text7.Text = "3"; run7.Append(runProperties12); run7.Append(text7); superArgument2.Append(run7); superscript1.Append(superscriptProperties1); superscript1.Append(base2); superscript1.Append(superArgument2); return(superscript1); }