Documentation Buy Contact Blog
Simple Example

This is a simple example to show how to read and write to an Excel spreadsheet using Number Duck. You can download Number Duck here, along with the source and binaries for this example.

This is what your final result will look like
This is what your final result will look like
C++ PHP
C++
printf("Simple Example\n");
printf("Create a spreadsheet!\n\n");

Workbook workbook("");
Worksheet* pWorksheet = workbook.GetWorksheetByIndex(0);
	
Cell* pCell = pWorksheet->GetCellByAddress("A1");
pCell->SetString("Totally cool spreadsheet!");

pWorksheet->GetCell(1,1)->SetFloat(3.1417f);
	
workbook.Save("SimpleExample.xls");

Workbook* pWorkbookIn = new Workbook("");
if (pWorkbookIn->Load("SimpleExample.xls"))
{
	Worksheet* pWorksheetIn = pWorkbookIn->GetWorksheetByIndex(0);
	Cell* pCellIn = pWorksheetIn->GetCell(0,0);
	printf("Cell Contents: %s\n", pCellIn->GetString());
}