Aspose.Words無需Microsoft Word也可在任何平臺上知足Word文檔的一切操做需求。本文將與你們分享如何檢測文件格式和檢查格式兼容性。git
圖表是一種很是有用的工具,能以圖形的方式表示或可視化任何類型的數據,從而對目標受衆產生最大的影響。圖表能夠讓用戶查看所表示數據的結果,以便更好地理解和預測當前和將來的數據。
github
在Word文檔中,能夠根據用戶的須要使用各類類型的圖表。爲了使圖表更易於理解,能夠將圖表標題和軸標題添加到圖表中。軸標題一般適用於能夠在圖表中顯示的全部軸,最經常使用的圖表類型有兩個軸。 沿圖表底部的X軸是橫軸,沿圖表左側的Y軸是縱軸。bash
在某些狀況下,用戶可能須要隱藏圖表軸或其中任何一個。使用Aspose.Words for .NET,能夠經過將特定軸的ChartAxis.Hidden屬性值設置爲false來實現。此屬性指示此軸是否隱藏。默認值爲false。ide
如下代碼段顯示瞭如何隱藏圖表的Y軸。工具
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;
// Clear demo data.
chart.Series.Clear();
// Fill data.
chart.Series.Add("AW Series 1",
new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" },
new double[] { 1.2, 0.3, 2.1, 2.9, 4.2 });
// Hide the Y axis.
chart.AxisY.Hidden = true;
dataDir = dataDir + @"HideChartAxis_out.docx";
doc.Save(dataDir);
複製代碼
下面給出了圖表的結果視圖,其中隱藏了Y軸:ui
在使用ChartAxis時,Aspose.Words for .NET可以讓用戶自定義標籤對齊的方式。默認狀況下,Microsoft Word會將全部軸標籤對齊到中心,以下所示:spa
TickAabelAlignment屬性已在ChartAxis類下引入,用於設置標籤對齊。ChartAxis類表示圖表的軸選項。TickLabelAlignment屬性可獲取或設置軸刻度標籤的文本對齊方式,僅在多行標籤的狀況下才有效。 默認值爲「ParagraphAlignment.Center」。code
如下代碼段顯示了TickLabelAlignment的工做狀況。cdn
Document doc = new Document(dataDir + "Document.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
ChartAxis axis = shape.Chart.AxisX;
//This property has effect only for multi-line labels.
axis.TickLabelAlignment = ParagraphAlignment.Right;
doc.Save(dataDir + "Document_out.docx");複製代碼
生成的圖表視圖以下所示:blog