Spezifizierung des DBNum Benutzerdefinierten Pattern Formats mit C++

Mögliche Verwendungsszenarien

Aspose.Cells unterstützt die DBNum-benutzerdefinierte Musterformatierung. Wenn beispielsweise der Zellwert 123 ist und die benutzerdefinierte Formatierung als [DBNum2][$-804]General festgelegt wird, wird er wie 壹佰贰拾叁 angezeigt. Sie können die benutzerdefinierte Formatierung der Zelle mit Cell.GetStyle()-Methode und Style.Custom-Eigenschaft festlegen.

Beispielcode

Das folgende Beispiel zeigt, wie man die DBNum-benutzerdefinierte Musterformatierung festlegt. Bitte überprüfen Sie das AusgabepDF für weitere Unterstützung.

#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\\");

    // Create a workbook
    Workbook wb;

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

    // Access cell A1 and put value 123
    Cell cell = ws.GetCells().Get(u"A1");
    cell.PutValue(123);

    // Access cell style
    Style st = cell.GetStyle();

    // Specifying DBNum custom pattern formatting
    st.SetCustom(u"[DBNum2][$-804]General", true);

    // Set the cell style
    cell.SetStyle(st);

    // Set the first column width
    ws.GetCells().SetColumnWidth(0, 30);

    // Save the workbook in output pdf format
    wb.Save(outDir + u"outputDBNumCustomFormatting.pdf", SaveFormat::Pdf);

    std::cout << "DBNum custom formatting applied successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}