XLSX I/O
Macros | Typedefs | Functions
xlsxio_read.h File Reference

XLSX I/O header file for reading .xlsx files. More...

#include <stdlib.h>
#include <stdint.h>
#include <time.h>

Go to the source code of this file.

Macros

#define XLSXIOCHAR   char
 character type used (usually char, but when XML_UNICODE is defined wchar_t)
 
XLSXIOREAD_SKIP_*

possible values for the flags parameter of xlsxioread_process()

See also
xlsxioread_process()
#define XLSXIOREAD_SKIP_NONE
 don't skip any rows or cells
 
#define XLSXIOREAD_SKIP_EMPTY_ROWS
 skip empty rows (note: cells may appear empty while they actually contain data)
 
#define XLSXIOREAD_SKIP_EMPTY_CELLS
 skip empty cells
 
#define XLSXIOREAD_SKIP_ALL_EMPTY
 skip empty rows and cells
 
#define XLSXIOREAD_SKIP_EXTRA_CELLS
 skip extra cells to the right of the rightmost header cell
 

Typedefs

typedef struct xlsxio_read_struct * xlsxioreader
 read handle for .xlsx object
 
typedef int(* xlsxioread_list_sheets_callback_fn) (const XLSXIOCHAR *name, void *callbackdata)
 type of pointer to callback function for listing worksheets More...
 
typedef int(* xlsxioread_process_cell_callback_fn) (size_t row, size_t col, const XLSXIOCHAR *value, void *callbackdata)
 type of pointer to callback function for processing a worksheet cell value More...
 
typedef int(* xlsxioread_process_row_callback_fn) (size_t row, size_t maxcol, void *callbackdata)
 type of pointer to callback function for processing the end of a worksheet row More...
 
typedef struct xlsxio_read_sheetlist_struct * xlsxioreadersheetlist
 read handle for list of worksheet names
 
typedef struct xlsxio_read_sheet_struct * xlsxioreadersheet
 read handle for worksheet object
 

Functions

DLL_EXPORT_XLSXIO void xlsxioread_get_version (int *pmajor, int *pminor, int *pmicro)
 get xlsxio_write version More...
 
const DLL_EXPORT_XLSXIO XLSXIOCHARxlsxioread_get_version_string ()
 get xlsxio_write version string More...
 
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open (const char *filename)
 open .xlsx file More...
 
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle (int filehandle)
 open .xlsx file More...
 
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory (void *data, uint64_t datalen, int freedata)
 open .xlsx from memory buffer More...
 
DLL_EXPORT_XLSXIO void xlsxioread_close (xlsxioreader handle)
 close .xlsx file More...
 
DLL_EXPORT_XLSXIO void xlsxioread_list_sheets (xlsxioreader handle, xlsxioread_list_sheets_callback_fn callback, void *callbackdata)
 list worksheets in .xlsx file More...
 
DLL_EXPORT_XLSXIO int xlsxioread_process (xlsxioreader handle, const XLSXIOCHAR *sheetname, unsigned int flags, xlsxioread_process_cell_callback_fn cell_callback, xlsxioread_process_row_callback_fn row_callback, void *callbackdata)
 process all rows and columns of a worksheet in an .xlsx file More...
 
DLL_EXPORT_XLSXIO xlsxioreadersheetlist xlsxioread_sheetlist_open (xlsxioreader handle)
 open list of worksheet names More...
 
DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close (xlsxioreadersheetlist sheetlisthandle)
 close worksheet More...
 
const DLL_EXPORT_XLSXIO XLSXIOCHARxlsxioread_sheetlist_next (xlsxioreadersheetlist sheetlisthandle)
 get next worksheet name More...
 
DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_row_index (xlsxioreadersheet sheethandle)
 get index of last row read from worksheet (returns 0 if no row was read yet) More...
 
DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_column_index (xlsxioreadersheet sheethandle)
 get index of last column read from current row in worksheet (returns 0 if no column was read yet) More...
 
DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags (xlsxioreadersheet sheethandle)
 get flags used to open worksheet More...
 
DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open (xlsxioreader handle, const XLSXIOCHAR *sheetname, unsigned int flags)
 open worksheet More...
 
DLL_EXPORT_XLSXIO void xlsxioread_sheet_close (xlsxioreadersheet sheethandle)
 close worksheet More...
 
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_row (xlsxioreadersheet sheethandle)
 get next row from worksheet (to be called before each row) More...
 
DLL_EXPORT_XLSXIO XLSXIOCHARxlsxioread_sheet_next_cell (xlsxioreadersheet sheethandle)
 get next cell from worksheet More...
 
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_string (xlsxioreadersheet sheethandle, XLSXIOCHAR **pvalue)
 get next cell from worksheet as a string More...
 
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_int (xlsxioreadersheet sheethandle, int64_t *pvalue)
 get next cell from worksheet as an integer More...
 
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_float (xlsxioreadersheet sheethandle, double *pvalue)
 get next cell from worksheet as a floating point value More...
 
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_datetime (xlsxioreadersheet sheethandle, time_t *pvalue)
 get next cell from worksheet as date and time data More...
 
DLL_EXPORT_XLSXIO void xlsxioread_free (XLSXIOCHAR *data)
 free memory allocated by the library More...
 

Detailed Description

XLSX I/O header file for reading .xlsx files.

Author
Brecht Sanders
Date
2016

Include this header file to use XLSX I/O for reading .xlsx files and link with -lxlsxio_read. This header provides both advanced methods using callback functions and simple methods for iterating through data.

Typedef Documentation

◆ xlsxioread_list_sheets_callback_fn

typedef int(* xlsxioread_list_sheets_callback_fn) (const XLSXIOCHAR *name, void *callbackdata)

type of pointer to callback function for listing worksheets

Parameters
namename of worksheet
callbackdatacallback data passed to xlsxioread_list_sheets
Returns
zero to continue, non-zero to abort
See also
xlsxioread_list_sheets()

◆ xlsxioread_process_cell_callback_fn

typedef int(* xlsxioread_process_cell_callback_fn) (size_t row, size_t col, const XLSXIOCHAR *value, void *callbackdata)

type of pointer to callback function for processing a worksheet cell value

Parameters
rowrow number (first row is 1)
colcolumn number (first column is 1)
valuevalue of cell (note: formulas are not calculated)
callbackdatacallback data passed to xlsxioread_process
Returns
zero to continue, non-zero to abort
See also
xlsxioread_process()
xlsxioread_process_row_callback_fn

◆ xlsxioread_process_row_callback_fn

typedef int(* xlsxioread_process_row_callback_fn) (size_t row, size_t maxcol, void *callbackdata)

type of pointer to callback function for processing the end of a worksheet row

Parameters
rowrow number (first row is 1)
maxcolmaximum column number on this row (first column is 1)
callbackdatacallback data passed to xlsxioread_process
Returns
zero to continue, non-zero to abort
See also
xlsxioread_process()
xlsxioread_process_cell_callback_fn

Function Documentation

◆ xlsxioread_get_version()

DLL_EXPORT_XLSXIO void xlsxioread_get_version ( int *  pmajor,
int *  pminor,
int *  pmicro 
)

get xlsxio_write version

Parameters
pmajorpointer to integer that will receive major version number
pminorpointer to integer that will receive minor version number
pmicropointer to integer that will receive micro version number
See also
xlsxiowrite_get_version_string()

◆ xlsxioread_get_version_string()

const DLL_EXPORT_XLSXIO XLSXIOCHAR* xlsxioread_get_version_string ( )

get xlsxio_write version string

Returns
version string
See also
xlsxiowrite_get_version()

◆ xlsxioread_open()

DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open ( const char *  filename)

open .xlsx file

Parameters
filenamepath of .xlsx file to open
Returns
read handle for .xlsx object or NULL on error
See also
xlsxioread_close()

◆ xlsxioread_open_filehandle()

DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle ( int  filehandle)

open .xlsx file

Parameters
filehandlefile handle of .xlsx file opened with read access in binary mode
Returns
read handle for .xlsx object or NULL on error
See also
xlsxioread_close()

◆ xlsxioread_open_memory()

DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory ( void *  data,
uint64_t  datalen,
int  freedata 
)

open .xlsx from memory buffer

Parameters
datamemory buffer containing .xlsx file (data must remain valid as long as any xlsxioread_ functions are called)
datalensize of memory buffer containing .xlsx file
freedataif non-zero data will be freed by xlsxioread_close()
Returns
read handle for .xlsx object or NULL on error
See also
xlsxioread_close()

◆ xlsxioread_close()

DLL_EXPORT_XLSXIO void xlsxioread_close ( xlsxioreader  handle)

close .xlsx file

Parameters
handleread handle for .xlsx object
See also
xlsxioread_open()

◆ xlsxioread_list_sheets()

DLL_EXPORT_XLSXIO void xlsxioread_list_sheets ( xlsxioreader  handle,
xlsxioread_list_sheets_callback_fn  callback,
void *  callbackdata 
)

list worksheets in .xlsx file

Parameters
handleread handle for .xlsx object
callbackcallback function called for each worksheet
callbackdatacustom data as passed to quickmail_add_body_custom/quickmail_add_attachment_custom
See also
xlsxioread_list_sheets_callback_fn

◆ xlsxioread_process()

DLL_EXPORT_XLSXIO int xlsxioread_process ( xlsxioreader  handle,
const XLSXIOCHAR sheetname,
unsigned int  flags,
xlsxioread_process_cell_callback_fn  cell_callback,
xlsxioread_process_row_callback_fn  row_callback,
void *  callbackdata 
)

process all rows and columns of a worksheet in an .xlsx file

Parameters
handleread handle for .xlsx object
sheetnameworksheet name (NULL for first sheet)
flagsXLSXIOREAD_SKIP_ flag(s) to determine how data is processed
cell_callbackcallback function called for each cell
row_callbackcallback function called after each row
callbackdatacallback data passed to xlsxioread_process
Returns
zero on success, non-zero on error
See also
xlsxioread_process_row_callback_fn
xlsxioread_process_cell_callback_fn

◆ xlsxioread_sheetlist_open()

DLL_EXPORT_XLSXIO xlsxioreadersheetlist xlsxioread_sheetlist_open ( xlsxioreader  handle)

open list of worksheet names

Parameters
handleread handle for .xlsx object
See also
xlsxioread_sheetlist_close()
xlsxioread_open()

◆ xlsxioread_sheetlist_close()

DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close ( xlsxioreadersheetlist  sheetlisthandle)

close worksheet

Parameters
sheetlisthandleread handle for worksheet object
See also
xlsxioread_sheetlist_open()

◆ xlsxioread_sheetlist_next()

const DLL_EXPORT_XLSXIO XLSXIOCHAR* xlsxioread_sheetlist_next ( xlsxioreadersheetlist  sheetlisthandle)

get next worksheet name

Parameters
sheetlisthandleread handle for worksheet object
Returns
name of worksheet or NULL if no more worksheets are available
See also
xlsxioread_sheetlist_open()

◆ xlsxioread_sheet_last_row_index()

DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_row_index ( xlsxioreadersheet  sheethandle)

get index of last row read from worksheet (returns 0 if no row was read yet)

Parameters
sheethandleread handle for worksheet object
See also
xlsxioread_sheet_open()

◆ xlsxioread_sheet_last_column_index()

DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_column_index ( xlsxioreadersheet  sheethandle)

get index of last column read from current row in worksheet (returns 0 if no column was read yet)

Parameters
sheethandleread handle for worksheet object
See also
xlsxioread_sheet_open()

◆ xlsxioread_sheet_flags()

DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags ( xlsxioreadersheet  sheethandle)

get flags used to open worksheet

Parameters
sheethandleread handle for worksheet object
See also
xlsxioread_sheet_open()

◆ xlsxioread_sheet_open()

DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open ( xlsxioreader  handle,
const XLSXIOCHAR sheetname,
unsigned int  flags 
)

open worksheet

Parameters
handleread handle for .xlsx object
sheetnameworksheet name (NULL for first sheet)
flagsXLSXIOREAD_SKIP_ flag(s) to determine how data is processed
Returns
read handle for worksheet object or NULL in case of error
See also
xlsxioread_sheet_close()
xlsxioread_open()

◆ xlsxioread_sheet_close()

DLL_EXPORT_XLSXIO void xlsxioread_sheet_close ( xlsxioreadersheet  sheethandle)

close worksheet

Parameters
sheethandleread handle for worksheet object
See also
xlsxioread_sheet_open()

◆ xlsxioread_sheet_next_row()

DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_row ( xlsxioreadersheet  sheethandle)

get next row from worksheet (to be called before each row)

Parameters
sheethandleread handle for worksheet object
Returns
non-zero if a new row is available
See also
xlsxioread_sheet_open()

◆ xlsxioread_sheet_next_cell()

DLL_EXPORT_XLSXIO XLSXIOCHAR* xlsxioread_sheet_next_cell ( xlsxioreadersheet  sheethandle)

get next cell from worksheet

Parameters
sheethandleread handle for worksheet object
Returns
value (caller must free the result using xlsxioread_free()) or NULL if no more cells are available in the current row
See also
xlsxioread_sheet_open()
xlsxioread_free()

◆ xlsxioread_sheet_next_cell_string()

DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_string ( xlsxioreadersheet  sheethandle,
XLSXIOCHAR **  pvalue 
)

get next cell from worksheet as a string

Parameters
sheethandleread handle for worksheet object
pvaluepointer where string will be stored if data is available (caller must free the result using xlsxioread_free())
Returns
non-zero if a new cell was available in the current row
See also
xlsxioread_sheet_open()
xlsxioread_sheet_next_cell()
xlsxioread_free()

◆ xlsxioread_sheet_next_cell_int()

DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_int ( xlsxioreadersheet  sheethandle,
int64_t *  pvalue 
)

get next cell from worksheet as an integer

Parameters
sheethandleread handle for worksheet object
pvaluepointer where integer will be stored if data is available
Returns
non-zero if a new cell was available in the current row
See also
xlsxioread_sheet_open()
xlsxioread_sheet_next_cell()

◆ xlsxioread_sheet_next_cell_float()

DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_float ( xlsxioreadersheet  sheethandle,
double *  pvalue 
)

get next cell from worksheet as a floating point value

Parameters
sheethandleread handle for worksheet object
pvaluepointer where floating point value will be stored if data is available
Returns
non-zero if a new cell was available in the current row
See also
xlsxioread_sheet_open()
xlsxioread_sheet_next_cell()

◆ xlsxioread_sheet_next_cell_datetime()

DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_datetime ( xlsxioreadersheet  sheethandle,
time_t *  pvalue 
)

get next cell from worksheet as date and time data

Parameters
sheethandleread handle for worksheet object
pvaluepointer where date and time data will be stored if data is available
Returns
non-zero if a new cell was available in the current row
See also
xlsxioread_sheet_open()
xlsxioread_sheet_next_cell()

◆ xlsxioread_free()

DLL_EXPORT_XLSXIO void xlsxioread_free ( XLSXIOCHAR data)

free memory allocated by the library

Parameters
datamemory to be freed
See also
xlsxioread_sheet_next_cell()
xlsxioread_sheet_next_cell_string()