Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
If you assign an invalid custom number format to Style.GetCustom() property, Aspose.Cells will not throw an exception. But if you want Aspose.Cells to check whether the assigned custom number format is valid, please set the Workbook.GetCheckCustomNumberFormat() property to true.
The following sample code assigns an invalid custom number format to Style.GetCustom() property. Since we have already set the Workbook.GetCheckCustomNumberFormat() property to true, it throws an exception, e.g., “Invalid number format”. Please read the comments inside the code for more help.
#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
// Create an instance of the Workbook class
Workbook book;
// Setting this property to true will cause Aspose.Cells to throw an exception
// when an invalid custom number format is assigned to the Style.Custom property
book.GetSettings().SetCheckCustomNumberFormat(true);
// Access the first worksheet
Worksheet sheet = book.GetWorksheets().Get(0);
// Access cell A1 and put a number into it
Cell cell = sheet.GetCells().Get(u"A1");
cell.PutValue(2347);
// Access the cell's style and set its Style.Custom property
Style style = cell.GetStyle();
// This line will throw an exception if Workbook.Settings.CheckCustomNumberFormat is set to true
style.SetCustom(u"ggg @ fff"); // Invalid custom number format
std::cout << "Custom number format set." << std::endl;
Aspose::Cells::Cleanup();
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.