diff --git a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj index 2abb68c43..92ca1749a 100644 --- a/Examples/ApiExamples/ApiExamples/ApiExamples.csproj +++ b/Examples/ApiExamples/ApiExamples/ApiExamples.csproj @@ -51,6 +51,7 @@ + @@ -127,8 +128,8 @@ - - + + diff --git a/Examples/ApiExamples/ApiExamples/ExCharts.cs b/Examples/ApiExamples/ApiExamples/ExCharts.cs index b4fa15e86..92b73cfe1 100644 --- a/Examples/ApiExamples/ApiExamples/ExCharts.cs +++ b/Examples/ApiExamples/ApiExamples/ExCharts.cs @@ -123,15 +123,15 @@ public void AxisProperties() //ExFor:ChartAxis.MinorTickMark //ExFor:ChartAxis.MajorUnit //ExFor:ChartAxis.MinorUnit - //ExFor:ChartAxis.TickLabelOffset - //ExFor:ChartAxis.TickLabelPosition - //ExFor:ChartAxis.TickLabelSpacingIsAuto + //ExFor:AxisTickLabels.Offset + //ExFor:AxisTickLabels.Position + //ExFor:AxisTickLabels.IsAutoSpacing //ExFor:ChartAxis.TickMarkSpacing //ExFor:Charts.AxisCategoryType //ExFor:Charts.AxisCrosses - //ExFor:Charts.Chart.AxisX - //ExFor:Charts.Chart.AxisY - //ExFor:Charts.Chart.AxisZ + //ExFor:Chart.AxisX + //ExFor:Chart.AxisY + //ExFor:Chart.AxisZ //ExSummary:Shows how to insert a chart and modify the appearance of its axes. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); @@ -1627,5 +1627,42 @@ public void ResetDataPointFill() doc.Save(ArtifactsDir + "Charts.ResetDataPointFill.docx"); //ExEnd:ResetDataPointFill } + + [Test] + public void DataTable() + { + //ExStart:DataTable + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:ChartDataTable + //ExFor:ChartDataTable.Show + //ExSummary:Shows how to show data table with chart series data. + Document doc = new Document(); + DocumentBuilder builder = new DocumentBuilder(doc); + + Shape shape = builder.InsertChart(ChartType.Column, 432, 252); + Chart chart = shape.Chart; + + ChartSeriesCollection series = chart.Series; + series.Clear(); + double[] xValues = new double[] { 2020, 2021, 2022, 2023 }; + series.Add("Series1", xValues, new double[] { 5, 11, 2, 7 }); + series.Add("Series2", xValues, new double[] { 6, 5.5, 7, 7.8 }); + series.Add("Series3", xValues, new double[] { 10, 8, 7, 9 }); + + ChartDataTable dataTable = chart.DataTable; + dataTable.Show = true; + + dataTable.HasLegendKeys = false; + dataTable.HasHorizontalBorder = false; + dataTable.HasVerticalBorder = false; + + dataTable.Font.Italic = true; + dataTable.Format.Stroke.Weight = 1; + dataTable.Format.Stroke.DashStyle = DashStyle.ShortDot; + dataTable.Format.Stroke.Color = Color.DarkBlue; + + doc.Save(ArtifactsDir + "Charts.DataTable.docx"); + //ExEnd:DataTable + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs index fb1c6c0d2..4ede7ea22 100644 --- a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs +++ b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs @@ -623,5 +623,23 @@ public void DeleteShapes() Assert.AreEqual(0, doc.GetChildNodes(NodeType.Shape, true).Count); //ExEnd } + + [Test] + public void UpdateActualReferenceMarks() + { + //ExStart:UpdateActualReferenceMarks + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:Document.UpdateActualReferenceMarks + //ExFor:Footnote.ActualReferenceMark + //ExSummary:Shows how to get actual footnote reference mark. + Document doc = new Document(MyDir + "Footnotes and endnotes.docx"); + + Footnote footnote = (Footnote)doc.GetChild(NodeType.Footnote, 1, true); + doc.UpdateFields(); + doc.UpdateActualReferenceMarks(); + + Assert.AreEqual("1", footnote.ActualReferenceMark); + //ExEnd:UpdateActualReferenceMarks + } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs b/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs new file mode 100644 index 000000000..97acae7a7 --- /dev/null +++ b/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs @@ -0,0 +1,31 @@ +using System; +using System.IO; +using System.Text; +using ApiExamples; +using Aspose.Words.Loading; +using NUnit.Framework; + +namespace Aspose.Words.ApiExamples +{ + class ExMarkdownLoadOptions : ApiExampleBase + { + [Test] + public void PreserveEmptyLines() + { + //ExStart:PreserveEmptyLines + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:MarkdownLoadOptions + //ExFor:MarkdownLoadOptions.PreserveEmptyLines + //ExSummary:Shows how to preserve empty line while load a document. + string mdText = $"{Environment.NewLine}Line1{Environment.NewLine}{Environment.NewLine}Line2{Environment.NewLine}{Environment.NewLine}"; + using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(mdText))) + { + MarkdownLoadOptions loadOptions = new MarkdownLoadOptions() { PreserveEmptyLines = true }; + Document doc = new Document(stream, loadOptions); + + Assert.AreEqual("\rLine1\r\rLine2\r\f", doc.GetText()); + } + //ExEnd:PreserveEmptyLines + } + } +} diff --git a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs index d0c073dd6..66b5ee2d8 100644 --- a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs +++ b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs @@ -1242,6 +1242,23 @@ public void RestrictedTypes() //ExEnd:RestrictedTypes } + [Test] + public void Word2016Charts() + { + //ExStart:Word2016Charts + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:ReportingEngine.BuildReport(Document, Object[], String[]) + //ExSummary:Shows how to work with charts from word 2016. + Document doc = new Document(MyDir + "Reporting engine template - Word 2016 Charts.docx"); + + ReportingEngine engine = new ReportingEngine(); + engine.BuildReport(doc, new object[] { Common.GetShares(), Common.GetShareQuotes() }, + new string[] { "shares", "quotes" }); + + doc.Save(ArtifactsDir + "ReportingEngine.Word2016Charts.docx"); + //ExEnd:Word2016Charts + } + private static void BuildReport(Document document, object dataSource, ReportBuildOptions reportBuildOptions) { ReportingEngine engine = new ReportingEngine { Options = reportBuildOptions }; diff --git a/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs b/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs index f6695d233..08e4fb6ba 100644 --- a/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs +++ b/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs @@ -1312,5 +1312,22 @@ public void RemoveSelfOnly() Assert.AreEqual(0, sdts.Count()); //ExEnd:RemoveSelfOnly } + + [Test] + public void Appearance() + { + //ExStart:Appearance + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:SdtAppearance + //ExFor:StructuredDocumentTagRangeStart.Appearance + //ExSummary:Shows how to show tag around content. + Document doc = new Document(MyDir + "Multi-section structured document tags.docx"); + StructuredDocumentTagRangeStart tag = + doc.GetChild(NodeType.StructuredDocumentTagRangeStart, 0, true) as StructuredDocumentTagRangeStart; + + if (tag.Appearance == SdtAppearance.Hidden) + tag.Appearance = SdtAppearance.Tags; + //ExEnd:Appearance + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExStyles.cs b/Examples/ApiExamples/ApiExamples/ExStyles.cs index c61dd9445..1ec4a25c0 100644 --- a/Examples/ApiExamples/ApiExamples/ExStyles.cs +++ b/Examples/ApiExamples/ApiExamples/ExStyles.cs @@ -372,5 +372,30 @@ public void LockStyle() doc = new Document(ArtifactsDir + "Styles.LockStyle.docx"); Assert.IsTrue(doc.Styles[StyleIdentifier.Heading1].Locked); } + + [Test] + public void StylePriority() + { + //ExStart:StylePriority + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:Style.Priority + //ExFor:Style.UnhideWhenUsed + //ExFor:Style.SemiHidden + //ExSummary:Shows how to prioritize and hide a style. + Document doc = new Document(); + Style styleTitle = doc.Styles[StyleIdentifier.Subtitle]; + + if (styleTitle.Priority == 9) + styleTitle.Priority = 10; + + if (!styleTitle.UnhideWhenUsed) + styleTitle.UnhideWhenUsed = true; + + if (styleTitle.SemiHidden) + styleTitle.SemiHidden = true; + + doc.Save(ArtifactsDir + "Styles.StylePriority.docx"); + //ExEnd:StylePriority + } } } diff --git a/Examples/ApiExamples/ApiExamples/ExSvgSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExSvgSaveOptions.cs index 9379719e5..0456bc48f 100644 --- a/Examples/ApiExamples/ApiExamples/ExSvgSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExSvgSaveOptions.cs @@ -8,6 +8,7 @@ using System; using System.IO; using Aspose.Words; +using Aspose.Words.Math; using Aspose.Words.Saving; using NUnit.Framework; @@ -82,5 +83,23 @@ void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args) private int mSavedResourceCount; } //ExEnd + + [Test] + public void SaveOfficeMath() + { + //ExStart:SaveOfficeMath + //GistId:a775441ecb396eea917a2717cb9e8f8f + //ExFor:NodeRendererBase.Save(String, SvgSaveOptions) + //ExSummary:Shows how to pass save options when rendering office math. + Document doc = new Document(MyDir + "Office math.docx"); + + OfficeMath math = (OfficeMath)doc.GetChild(NodeType.OfficeMath, 0, true); + + SvgSaveOptions options = new SvgSaveOptions(); + options.TextOutputMode = SvgTextOutputMode.UsePlacedGlyphs; + + math.GetMathRenderer().Save(ArtifactsDir + "SvgSaveOptions.Output.svg", options); + //ExEnd:SaveOfficeMath + } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/TestData/Common.cs b/Examples/ApiExamples/ApiExamples/TestData/Common.cs index cacedc033..9bf460a79 100644 --- a/Examples/ApiExamples/ApiExamples/TestData/Common.cs +++ b/Examples/ApiExamples/ApiExamples/TestData/Common.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using ApiExamples.TestData.TestClasses; +using Aspose.Words.ApiExamples.HelperClasses.TestClasses; namespace ApiExamples.TestData { @@ -173,5 +174,36 @@ public static IEnumerable GetContracts() yield return contract; } } + + public static ShareTestClass[] GetShares() + { + return new ShareTestClass[] + { + new ShareTestClass("Technology", "Consumer Electronics", "AAPL", 6.602835, -0.0054), + new ShareTestClass("Technology", "Software - Infrastructure", "MSFT", 5.832072, -0.005), + new ShareTestClass("Technology", "Software - Infrastructure", "ADBE", 0.562561, -0.0274), + new ShareTestClass("Technology", "Semiconductors", "NVDA", 1.335994, -0.0074), + new ShareTestClass("Technology", "Semiconductors", "QCOM", 0.462198, 0.0248), + new ShareTestClass("Communication Services", "Internet Content & Information", "GOOG", 3.771651, 0.011), + new ShareTestClass("Communication Services", "Entertainment", "DIS", 0.575768, 0.0102), + new ShareTestClass("Communication Services", "Entertainment", "WBD", 0.116579, -0.0165), + new ShareTestClass("Consumer Cyclical", "Internet Retail", "AMZN", 3.011482, 0.044), + new ShareTestClass("Consumer Cyclical", "Auto Manufactures", "TSLA", 1.816734, -0.0018), + new ShareTestClass("Consumer Cyclical", "Auto Manufactures", "GM", 0.160205, 0.0026), + new ShareTestClass("Financial", "Credit Services", "V", 1.1, 0.005) + }; + } + + public static ShareQuoteTestClass[] GetShareQuotes() + { + return new ShareQuoteTestClass[] + { + new ShareQuoteTestClass(45131, 15232450, 171.32, 172.50, 170.69, 171.98), + new ShareQuoteTestClass(45132, 13962990, 172.20, 172.70, 171.40, 171.86), + new ShareQuoteTestClass(45133, 14902060, 171.86, 171.93, 170.31, 171.35), + new ShareQuoteTestClass(45134, 16962540, 171.64, 173.10, 171.35, 172.00), + new ShareQuoteTestClass(45135, 15588280, 171.98, 172.40, 170.00, 171.44) + }; + } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareQuoteTestClass.cs b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareQuoteTestClass.cs new file mode 100644 index 000000000..e78788dd5 --- /dev/null +++ b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareQuoteTestClass.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aspose.Words.ApiExamples.HelperClasses.TestClasses +{ + public class ShareQuoteTestClass + { + internal ShareQuoteTestClass(int date, int volume, double open, double high, double low, double close) + { + this.Date = date; + this.Volume = volume; + this.Open = open; + this.High = high; + this.Low = low; + this.Close = close; + } + + public string Color() + { + return (Open < Close) ? "#1B9629" : "#96002C"; + } + + public int Date; + public int Volume; + public double Open; + public double High; + public double Low; + public double Close; + } +} diff --git a/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareTestClass.cs b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareTestClass.cs new file mode 100644 index 000000000..badfbeadc --- /dev/null +++ b/Examples/ApiExamples/ApiExamples/TestData/TestClasses/ShareTestClass.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Common; + +namespace Aspose.Words.ApiExamples.HelperClasses.TestClasses +{ + public class ShareTestClass + { + internal ShareTestClass(string sector, string industry, string ticker, double weight, double delta) + { + this.Sector = sector; + this.Industry = industry; + this.Ticker = ticker; + this.Weight = weight; + this.Delta = delta; + } + + public string Title() + { + double percentValue = Delta * 100; + return string.Format("{0}\r\n{1}%", Ticker, percentValue.ToString()); + } + + public string Color() + { + const double fullColorDelta = 0.016d; + const byte unusedColorChannelValue = 80; + + byte r = unusedColorChannelValue; + byte g = unusedColorChannelValue; + byte b = unusedColorChannelValue; + + int value = + unusedColorChannelValue + + (int)System.Math.Round(System.Math.Abs(Delta) / fullColorDelta * + (byte.MaxValue - unusedColorChannelValue)); + + if (value > byte.MaxValue) + value = byte.MaxValue; + + if (Delta < 0) + r = (byte)value; + else + g = (byte)value; + + return string.Format("#{0:X2}{1:X2}{2:X2}", r, g, b); + } + + public string IndustryColor() + { + if (Industry == "Consumer Electronics") + return "#1B9629"; + else if (Industry == "Software - Infrastructure") + return "#6029E3"; + else if (Industry == "Semiconductors") + return "#E38529"; + else if (Industry == "Internet Content & Information") + return "#964D05"; + else if (Industry == "Entertainment") + return "#12E32B"; + else if (Industry == "Internet Retail") + return "#96002C"; + else if (Industry == "Auto Manufactures") + return "#1EE3A4"; + else if (Industry == "Credit Services") + return "#D40B70"; + else + return "#888888"; + } + + public string Sector; + public string Industry; + public string Ticker; + public double Weight; + public double Delta; + } +} diff --git a/Examples/Data/Reporting engine template - Word 2016 Charts.docx b/Examples/Data/Reporting engine template - Word 2016 Charts.docx new file mode 100644 index 000000000..f093f3c15 Binary files /dev/null and b/Examples/Data/Reporting engine template - Word 2016 Charts.docx differ