C++でスライサーのフォーマット設定

可能な使用シナリオ

Microsoft Excel内のスライサーを列数やスタイルなどを設定してフォーマットできます。Aspose.CellsはSlicer.GetNumberOfColumns()Slicer.GetStyleType()のプロパティを使ってこれを行うことも可能です。

スライサーの書式設定

以下のコードを参照してください。これはスライサーを含むサンプルExcelファイルを読み込み、スライサーの列数とスタイルタイプを設定して出力Excelファイルとして保存します。スクリーンショットは、サンプルコード実行後のスライサーの見た目を示しています。

todo:image_alt_text

サンプルコード

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C

    // Load sample Excel file containing slicer.
    Workbook workbook(u"sampleFormattingSlicer.xlsx");

    // Access first worksheet.
    Worksheet worksheet = workbook.GetWorksheets().Get(0);

    // Access the first slicer inside the slicer collection.
    Slicer slicer = worksheet.GetSlicers().Get(0);

    // Set the number of columns of the slicer.
    slicer.SetNumberOfColumns(2);

    // Set the type of slicer style.
    slicer.SetStyleType(SlicerStyleType::SlicerStyleLight6);

    // Save the workbook in output XLSX format.
    workbook.Save(u"outputFormattingSlicer.xlsx", SaveFormat::Xlsx);

    std::cout << "Slicer formatted and workbook saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}