共有数式の最大行数を指定(C++)

可能な使用シナリオ

共有数式の既定の最大行数は64ですが、任意の数値(例:1000)に設定可能です。共有数式の行数がこれを超えると、パフォーマンスに影響します。そこで、Aspose.CellsはGetMaxRowsOfSharedFormula()プロパティを提供し、これを使用して最大行数を指定できます。合計行数がこれを超える場合、共有数式は複数の共有数式に分割されます。以下のスクリーンショット参照。

todo:image_alt_text

共有式の最大行数を指定

次のサンプルコードは、GetMaxRowsOfSharedFormula()プロパティの使用例です。共有数式の最大行数を5に設定し、セルD1に100行分の共有数式を追加して保存します。出力エクセルファイルを確認すると、各5行ごとに共有数式が分割されているのがわかります。

サンプルコード

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

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

    // Create a new workbook
    Workbook wb;

    // Set the max rows of shared formula to 5
    wb.GetSettings().SetMaxRowsOfSharedFormula(5);

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

    // Access cell D1
    Cell cell = ws.GetCells().Get(u"D1");

    // Set the shared formula in 100 rows
    cell.SetSharedFormula(u"=Sum(A1:A2)", 100, 1);

    // Save the output Excel file
    wb.Save(u"outputSpecifyMaximumRowsOfSharedFormula.xlsx");

    std::cout << "Shared formula set successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}