Aspose.Cells for C++

Here at Aspose we work hard to make developers’ lives easier by providing easy‑to‑use, powerful APIs for managing documents of many formats. Aspose.Cells for C++ lets developers dynamically create, manipulate, and convert spreadsheets without requiring Office Automation or Microsoft Excel. Aspose.Cells for C++ 16.11.0 is a native C++ library now available for public use.

While you download the API build to try it, here is a list of supported features with a few code snippets for quick testing.

Load & Save Spreadsheets

The first release of Aspose.Cells for C++ supports loading and saving Excel 97‑2003 Workbook format (XLS) and Open Office XML format (XLSX) from a file path or stream. The Workbook class represents a Microsoft Excel spreadsheet and provides the properties and methods needed to work with spreadsheet files. To load an existing spreadsheet, pass the file path (or stream) to the Workbook constructor. Use the Workbook.Save method to save the spreadsheet or convert it. The Save method offers many overloads, including one that accepts a value from the SaveFormat enumeration to specify the output format.

Worksheet Manipulation

Aspose.Cells for C++ exposes the WorksheetCollection and Worksheet classes to access worksheets. These classes support a wide range of features, including:

  • Add & remove worksheets
  • Copy & move worksheets
  • Manage page breaks
  • Manage worksheet views

Cell Manipulation

A cell is the basic unit of a spreadsheet and can contain data, a formula, and formatting such as font and shading. In Aspose.Cells for C++, a cell is represented by the Cell class, while a collection of cells is represented by the CellsCollection class. Key capabilities include:

  • Access a specific cell or a visible range
  • Add or retrieve data from a cell
  • Format a cell or a range of cells
  • Find data or formulas
  • Trace precedent and dependent cells
  • Create subtotals

Row & Column Manipulation

Aspose.Cells for C++ provides Row and RowCollection classes for worksheet rows and Column and ColumnCollection classes for columns. These classes offer properties and methods to manipulate rows and columns as needed. Notable features are:

  • Copy rows & columns
  • Adjust row height & column width
  • Group / un‑group rows & columns
  • Insert / delete rows & columns

Manage Excel Tables

An Excel table (called a List Object in Aspose.Cells for C++) is a matrix of cells with any number of rows and columns. The Aspose::Cells::Tables namespace contains the classes needed to work with List Objects. Important classes such as ListObject and ListObjectCollection let you create and format tables easily.

Formula Calculation Engine

Aspose.Cells for C++ includes a custom formula calculation engine that supports almost all English‑based Excel functions, including text, logical, information, date & time, lookup & reference, math & trigonometry, statistical, database, and financial formulas. You can insert a function into a cell and retrieve the calculated value. The following snippet shows how simple it is to use the API to insert a formula and get its result.

 //Create a new workbook
 intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook();

 //Get first worksheet which is created by default
 intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0);

 //Adding a value to "A1" cell
 intrusive_ptr<ICell> cell = ws->GetICells()->GetObjectByIndex(new String("A1"));
 cell->PutValue(5);

 //Adding a value to "A2" cell
 cell = ws->GetICells()->GetObjectByIndex(new String("A2"));
 cell->PutValue(15);

 //Adding a value to "A3" cell
 cell = ws->GetICells()->GetObjectByIndex(new String("A3"));
 cell->PutValue(25);

 //Adding SUM formula to "A4" cell
 cell = ws->GetICells()->GetObjectByIndex(new String("A4"));
 cell->SetFormula(new String("=SUM(A1:A3)"));

 //Calculating the results of formulas
 wb->CalculateFormula();

 //Get the calculated value of the cell "A4" and print it on console
 cell = ws->GetICells()->GetObjectByIndex(new String("A4"));
 printf("Calculated Value of Cell A4: %s\r\n", cell->GetStringValue()->charValue());

Aspose.Cells for C++ Resources

The resources you may need to accomplish your tasks:

Keeping the Aspose tradition, you are welcome to shape upcoming releases of Aspose.Cells for C++ by posting suggestions and concerns in the Aspose.Cells support forum.