Option für Pivot Tabelle einstellen "Für leere Zellen anzeigen" mit C++

Pivot-Tabellen-Option in Microsoft Excel einstellen

Um diese Option in Microsoft Excel zu finden und einzustellen:

  1. Wählen Sie eine Pivot-Tabelle aus und klicken Sie mit der rechten Maustaste.
  2. Wählen Sie PivotTable-Optionen aus.
  3. Wählen Sie das Registerkarte Layout & Format aus.
  4. Wählen Sie die Option Leere Zellen anzeigen aus und geben Sie einen Text an.

Pivot-Tabellen-Option mit Aspose.Cells einstellen

Aspose.Cells bietet die Eigenschaften PivotTable.GetDisplayNullString() und PivotTable.GetNullString() zum Einstellen der Pivot-Tabellen-Option “Leere Zellen anzeigen”.

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;

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

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Output directory path
    U16String outDir(u"..\\Data\\02_OutputDirectory\\");

    // Path of input excel file
    U16String inputFilePath = srcDir + u"input.xlsx";

    // Path of output excel file
    U16String outputFilePath = outDir + u"output_out.xlsx";

    // Create workbook
    Workbook wb(inputFilePath);

    // Get the first worksheet
    WorksheetCollection sheets = wb.GetWorksheets();
    Worksheet sheet = sheets.Get(0);

    // Get the first pivot table
    PivotTableCollection pivotTables = sheet.GetPivotTables();
    PivotTable pt = pivotTables.Get(0);

    // Indicating if or not display the empty cell value
    pt.SetDisplayNullString(true);

    // Indicating the null string
    pt.SetNullString(u"null");

    // Calculate pivot table data
    pt.CalculateData();

    // Set refresh data on opening file to false
    pt.SetRefreshDataOnOpeningFile(false);

    // Save the workbook
    wb.Save(outputFilePath);

    std::cout << "Pivot table settings applied successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

Verwandte Artikel