シリーズを非表示にする方法
Contents
[
Hide
]
Excelチャートでシリーズを非表示にする方法
Excelのチャートでは、グラフを右クリックして「データの選択」をクリックし、ポップアップウィンドウでシリーズの表示/非表示をチェック・アンチェックして設定できます。 以下のサンプルファイルをダウンロードし、図のように操作してこの機能を実現します。次に、Aspose.Cellsライブラリを使った方法を紹介します。
Aspose.Cellsでシリーズを非表示に設定する方法
Aspose.Cellsを使ってシリーズを非表示に設定するコードは以下の通りです:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set series invisible using Aspose.Cells | |
string filePath = @""; | |
Workbook workbook = new Workbook(filePath + "SeriesFiltered.xlsx"); | |
ChartCollection charts = workbook.Worksheets[0].Charts; | |
Chart chart = charts["Chart 1"]; | |
SeriesCollection nSeriesFiltered = chart.FilteredNSeries; | |
SeriesCollection nSeries = chart.NSeries; | |
nSeries[1].IsFiltered = true; | |
nSeries[0].IsFiltered = true; | |
workbook.Save(filePath + "output.xlsx"); |
図のように、最初に表示されていた2つのシリーズが、出力ファイルで非表示になっています。