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 source code to all the examples.
Select your language below to view the source. You can download Number Duck here, along with source code to all the examples.
C++C#printf("Simple Example\n"); printf("Create a spreadsheet!\n\n"); Workbook* pWorkbook = new Workbook(); Worksheet* pWorksheet = pWorkbook->GetWorksheetByIndex(0); Cell* pCell = pWorksheet->GetCellByAddress("A1"); pCell->SetString("Totally cool spreadsheet!"); pWorksheet->GetCell(1,1)->SetFloat(3.1417f); pWorkbook->Save("SimpleExample.xls", Workbook::FILE_TYPE_XLS); delete pWorkbook; 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()); } delete pWorkbookIn;