/// <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> /// <param name="strTextName"></param> /// <param name="parameter"></param> /// <returns></returns> public static M.MathFunction MakeMathFunction(string strTextName, params OpenXmlElement[] parameter) { M.MathFunction mathFunc = new M.MathFunction( ); //--------------------------------------------- M.FunctionProperties funcProperties = new M.FunctionProperties( ); funcProperties.Append(OpenDocxMathExprs.MakeControlProperties( )); //--------------------------------------------- M.FunctionName funcNaming = OpenDocxMathExprs.MakeFunctionName(strTextName); //--------------------------------------------- M.DelimiterProperties delimProperties = new M.DelimiterProperties( ); delimProperties.Append(OpenDocxMathExprs.MakeControlProperties(true)); M.Base mathBaseParms = new M.Base( ); foreach (OpenXmlElement value in parameter) { mathBaseParms.Append(value); } M.Delimiter delimiter = new M.Delimiter( ); delimiter.Append(delimProperties); delimiter.Append(mathBaseParms); M.Base funcBase = new M.Base( ); funcBase.Append(delimiter); //--------------------------------------------- mathFunc.Append(funcProperties); mathFunc.Append(funcNaming); mathFunc.Append(funcBase); return(mathFunc); }
//..................................................................... /// <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> /// <param name="value"></param> /// <returns></returns> public static M.Base MakeMathBase(string value) { M.Base mathbase = new M.Base( ); mathbase.Append(OpenDocxMathExprs.MakeMathRun(value)); return(mathbase); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> private static M.FractionProperties MakeFractionProperties( ) { M.FractionProperties properties = new M.FractionProperties( ); properties.Append(OpenDocxMathExprs.MakeControlProperties()); return(properties); }
//..................................................................... /// <summary> /// /// </summary> /// <param name="value"></param> /// <returns></returns> public static M.SubArgument MakeScriptArgumentLower(string value) { M.SubArgument result = new M.SubArgument( ); result.Append(OpenDocxMathExprs.MakeMathRun(value)); return(result); }
//..................................................................... /// <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> 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); }
//..................................................................... /// <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> /// <param name="upper"></param> /// <param name="lower"></param> /// <returns></returns> public static M.Fraction MakeFraction(string upper, string lower) { M.Fraction fraction = new M.Fraction( ); M.Numerator upperNUM = new M.Numerator( ); upperNUM.Append(OpenDocxMathExprs.MakeMathRun(upper)); M.Denominator lowerDEN = new M.Denominator( ); lowerDEN.Append(OpenDocxMathExprs.MakeMathRun(lower)); fraction.Append(OpenDocxMathExprs.MakeFractionProperties( )); fraction.Append(upperNUM); fraction.Append(lowerDEN); return(fraction); }
//..................................................................... /// <summary> /// /// </summary> /// <param name="upper"></param> /// <param name="lower"></param> /// <returns></returns> public static M.Fraction MakeFraction(OpenXmlElement upper, OpenXmlElement lower) { M.Fraction fraction = new M.Fraction( ); M.Numerator upperNUM = new M.Numerator( ); upperNUM.Append(upper); M.Denominator lowerDEN = new M.Denominator( ); lowerDEN.Append(lower); fraction.Append(OpenDocxMathExprs.MakeFractionProperties( )); fraction.Append(upperNUM); fraction.Append(lowerDEN); return(fraction); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> public static M.SubSuperscript MakeScriptBoth(string strBase, string strUpper, string strLower) { M.SubSuperscript script = new M.SubSuperscript( ); M.SubSuperscriptProperties properties = new M.SubSuperscriptProperties( ); properties.Append(OpenDocxMathExprs.MakeControlProperties(true)); script.Append(properties); script.Append(OpenDocxMathExprs.MakeMathBase(strBase)); script.Append(OpenDocxMathExprs.MakeScriptArgumentLower(strLower)); script.Append(OpenDocxMathExprs.MakeScriptArgumentUpper(strUpper)); return(script); }
//..................................................................... /// <summary> /// /// </summary> /// <returns></returns> public static M.Superscript MakeScriptUpper(string mathBase, string mathArgm) { M.SuperscriptProperties properties = new M.SuperscriptProperties( ); properties.Append(OpenDocxMathExprs.MakeControlProperties(true)); //--------------------------------------------- M.Superscript script = new M.Superscript( ); script.Append(properties); script.Append(OpenDocxMathExprs.MakeMathBase(mathBase)); script.Append(OpenDocxMathExprs.MakeScriptArgumentUpper(mathArgm)); return(script); }
//..................................................................... /// <summary> /// /// </summary> /// <param name="strBase"></param> /// <param name="strDegree"></param> /// <returns></returns> public static M.Radical MakeMathRadical(string strBase, string strDegree) { M.Radical radical = new M.Radical( ); M.RadicalProperties properties = new M.RadicalProperties( ); properties.Append(OpenDocxMathExprs.MakeControlProperties(true)); M.Base mathBAS = OpenDocxMathExprs.MakeMathBase(strBase); M.Degree mathDEG = OpenDocxMathExprs.MakeMathDegree(strDegree); radical.Append(properties); radical.Append(mathBAS); radical.Append(mathDEG); return(radical); }
//..................................................................... /// <summary> /// /// </summary> /// <param name="useItalic"></param> /// <returns></returns> public static M.ControlProperties MakeControlProperties(bool useItalic = false) { RunProperties propertiesRUN = new RunProperties( ); propertiesRUN.Append(OpenDocxMathExprs.MakeMathFont()); if (useItalic) { propertiesRUN.Append(OpenDocxMathExprs.MakeMathFontItalic()); } //--------------------------------------------- M.ControlProperties propertiesCTRL = new M.ControlProperties( ); propertiesCTRL.Append(propertiesRUN); return(propertiesCTRL); }
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); }
private static M.SubSuperscript MakeScriptBoth( ) { M.SubSuperscript subSuperscript1 = new M.SubSuperscript( ); M.SubSuperscriptProperties subSuperscriptProperties1 = new M.SubSuperscriptProperties( ); subSuperscriptProperties1.Append(OpenDocxMathExprs.MakeControlProperties(true)); M.Base base1 = OpenDocxMathExprs.MakeMathBase("A"); // new M.Base( ); //--------------------------------------------- M.SubArgument subArgument1 = OpenDocxMathExprs.MakeScriptArgumentLower("i"); M.SuperArgument superArgument1 = OpenDocxMathExprs.MakeScriptArgumentUpper("w"); //--------------------------------------------- subSuperscript1.Append(subSuperscriptProperties1); subSuperscript1.Append(base1); subSuperscript1.Append(subArgument1); subSuperscript1.Append(superArgument1); return(subSuperscript1); }
private static M.Fraction MakeRun3( ) { M.SubSuperscript upperSCR = MakeScriptBoth( ); M.Superscript lowerSCR = OpenDocxMathExprs.MakeScriptUpper("x", "3"); //.ma MakeScriptUpper( ); return(OpenDocxMathExprs.MakeFraction(upperSCR, lowerSCR)); //M.Fraction fraction1 = new M.Fraction( ); //M.FractionProperties fractionProperties1 = HansOpenDocx.MakeFractionProperties( ); //M.Numerator numerator1 = new M.Numerator( ); //numerator1.Append( upperSCR ); //M.Denominator denominator1 = new M.Denominator( ); //denominator1.Append( lowerSCR ); //fraction1.Append( fractionProperties1 ); //fraction1.Append( numerator1 ); //fraction1.Append( denominator1 ); //return fraction1; }
//..................................................................... /// <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> public static M.Run MakeMathRunNoteMult( ) { return(OpenDocxMathExprs.MakeMathRun("∙")); }