Specificera anpassade decimala och grupperingsseparatorer för arbetsboken med C++

Ange anpassade avskiljare i Microsoft Excel

Följande skärmbild visar Avancerade Excel-alternativ och markerar avsnittet för att ange Anpassade avskiljare.

todo:image_alt_text

Ange anpassade avskiljare med Aspose.Cells

Följande exempelkod illustrerar hur man anger anpassade avskiljare med Aspose.Cells API. Det specificerar anpassade decimal- och grupptalsavskiljare som punkt och mellanslag respektive.

C++ kod för att specificera anpassade nummerdecimala och grupperingsseparatorer

#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 new workbook
    Workbook workbook;

    // Specify custom separators
    workbook.GetSettings().SetNumberDecimalSeparator(u'.');
    workbook.GetSettings().SetNumberGroupSeparator(u' ');

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

    // Set cell value
    Cell cell = worksheet.GetCells().Get(u"A1");
    cell.PutValue(123456.789);

    // Set custom cell style
    Style style = cell.GetStyle();
    style.SetCustom(u"#,##0.000;[Red]#,##0.000", true);
    cell.SetStyle(style);

    // Auto-fit columns
    worksheet.AutoFitColumns();

    // Save workbook as PDF
    workbook.Save(outDir + u"CustomSeparator_out.pdf");

    std::cout << "Workbook saved successfully with custom separators!" << std::endl;

    Aspose::Cells::Cleanup();
}