include/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.

Defines

#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
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
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
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
DLL_EXPORT_XLSXIO const
XLSXIOCHAR * 
xlsxioread_get_version_string ()
 get xlsxio_write version string
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open (const char *filename)
 open .xlsx file
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle (int filehandle)
 open .xlsx file
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory (void *data, uint64_t datalen, int freedata)
 open .xlsx from memory buffer
DLL_EXPORT_XLSXIO void xlsxioread_close (xlsxioreader handle)
 close .xlsx file
DLL_EXPORT_XLSXIO void xlsxioread_list_sheets (xlsxioreader handle, xlsxioread_list_sheets_callback_fn callback, void *callbackdata)
 list worksheets in .xlsx file
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
DLL_EXPORT_XLSXIO
xlsxioreadersheetlist 
xlsxioread_sheetlist_open (xlsxioreader handle)
 open list of worksheet names
DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close (xlsxioreadersheetlist sheetlisthandle)
 close worksheet
DLL_EXPORT_XLSXIO const
XLSXIOCHAR * 
xlsxioread_sheetlist_next (xlsxioreadersheetlist sheetlisthandle)
 get next worksheet name
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)
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)
DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags (xlsxioreadersheet sheethandle)
 get flags used to open worksheet
DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open (xlsxioreader handle, const XLSXIOCHAR *sheetname, unsigned int flags)
 open worksheet
DLL_EXPORT_XLSXIO void xlsxioread_sheet_close (xlsxioreadersheet sheethandle)
 close worksheet
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_row (xlsxioreadersheet sheethandle)
 get next row from worksheet (to be called before each row)
DLL_EXPORT_XLSXIO XLSXIOCHAR * xlsxioread_sheet_next_cell (xlsxioreadersheet sheethandle)
 get next cell from worksheet
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_string (xlsxioreadersheet sheethandle, XLSXIOCHAR **pvalue)
 get next cell from worksheet as a string
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_int (xlsxioreadersheet sheethandle, int64_t *pvalue)
 get next cell from worksheet as an integer
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_float (xlsxioreadersheet sheethandle, double *pvalue)
 get next cell from worksheet as a floating point value
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_datetime (xlsxioreadersheet sheethandle, time_t *pvalue)
 get next cell from worksheet as date and time data

Detailed Description

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

Author:
Brecht Sanders
Date:
2016 MIT

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

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

type of pointer to callback function for listing worksheets

Parameters:
name name of worksheet
callbackdata callback data passed to xlsxioread_list_sheets
Returns:
zero to continue, non-zero to abort
See also:
xlsxioread_list_sheets()
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:
row row number (first row is 1)
col column number (first column is 1)
value value of cell (note: formulas are not calculated)
callbackdata callback data passed to xlsxioread_process
Returns:
zero to continue, non-zero to abort
See also:
xlsxioread_process()
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:
row row number (first row is 1)
maxcol maximum column number on this row (first column is 1)
callbackdata callback data passed to xlsxioread_process
Returns:
zero to continue, non-zero to abort
See also:
xlsxioread_process()
xlsxioread_process_cell_callback_fn

Function Documentation

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

get xlsxio_write version

Parameters:
pmajor pointer to integer that will receive major version number
pminor pointer to integer that will receive minor version number
pmicro pointer to integer that will receive micro version number
See also:
xlsxiowrite_get_version_string()
DLL_EXPORT_XLSXIO const XLSXIOCHAR* xlsxioread_get_version_string (  ) 

get xlsxio_write version string

Returns:
version string
See also:
xlsxiowrite_get_version()
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open ( const char *  filename  ) 

open .xlsx file

Parameters:
filename path of .xlsx file to open
Returns:
read handle for .xlsx object or NULL on error
See also:
xlsxioread_close()
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle ( int  filehandle  ) 

open .xlsx file

Parameters:
filehandle file 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()
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory ( void *  data,
uint64_t  datalen,
int  freedata 
)

open .xlsx from memory buffer

Parameters:
data memory buffer containing .xlsx file (data must remain valid as long as any xlsxioread_ functions are called)
datalen size of memory buffer containing .xlsx file
freedata if non-zero data will be freed by xlsxioread_close()
Returns:
read handle for .xlsx object or NULL on error
See also:
xlsxioread_close()
DLL_EXPORT_XLSXIO void xlsxioread_close ( xlsxioreader  handle  ) 

close .xlsx file

Parameters:
handle read handle for .xlsx object
See also:
xlsxioread_open()
DLL_EXPORT_XLSXIO void xlsxioread_list_sheets ( xlsxioreader  handle,
xlsxioread_list_sheets_callback_fn  callback,
void *  callbackdata 
)

list worksheets in .xlsx file

Parameters:
handle read handle for .xlsx object
callback callback function called for each worksheet
callbackdata custom data as passed to quickmail_add_body_custom/quickmail_add_attachment_custom
See also:
xlsxioread_list_sheets_callback_fn
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:
handle read handle for .xlsx object
sheetname worksheet name (NULL for first sheet)
flags XLSXIOREAD_SKIP_ flag(s) to determine how data is processed
cell_callback callback function called for each cell
row_callback callback function called after each row
callbackdata callback 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
DLL_EXPORT_XLSXIO xlsxioreadersheetlist xlsxioread_sheetlist_open ( xlsxioreader  handle  ) 

open list of worksheet names

Parameters:
handle read handle for .xlsx object
See also:
xlsxioread_sheetlist_close()
xlsxioread_open()
DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close ( xlsxioreadersheetlist  sheetlisthandle  ) 

close worksheet

Parameters:
sheetlisthandle read handle for worksheet object
See also:
xlsxioread_sheetlist_open()
DLL_EXPORT_XLSXIO const XLSXIOCHAR* xlsxioread_sheetlist_next ( xlsxioreadersheetlist  sheetlisthandle  ) 

get next worksheet name

Parameters:
sheetlisthandle read handle for worksheet object
Returns:
name of worksheet or NULL if no more worksheets are available
See also:
xlsxioread_sheetlist_open()
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:
sheethandle read handle for worksheet object
See also:
xlsxioread_sheet_open()
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:
sheethandle read handle for worksheet object
See also:
xlsxioread_sheet_open()
DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags ( xlsxioreadersheet  sheethandle  ) 

get flags used to open worksheet

Parameters:
sheethandle read handle for worksheet object
See also:
xlsxioread_sheet_open()
DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open ( xlsxioreader  handle,
const XLSXIOCHAR *  sheetname,
unsigned int  flags 
)

open worksheet

Parameters:
handle read handle for .xlsx object
sheetname worksheet name (NULL for first sheet)
flags XLSXIOREAD_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()
DLL_EXPORT_XLSXIO void xlsxioread_sheet_close ( xlsxioreadersheet  sheethandle  ) 

close worksheet

Parameters:
sheethandle read handle for worksheet object
See also:
xlsxioread_sheet_open()
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_row ( xlsxioreadersheet  sheethandle  ) 

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

Parameters:
sheethandle read handle for worksheet object
Returns:
non-zero if a new row is available
See also:
xlsxioread_sheet_open()
DLL_EXPORT_XLSXIO XLSXIOCHAR* xlsxioread_sheet_next_cell ( xlsxioreadersheet  sheethandle  ) 

get next cell from worksheet

Parameters:
sheethandle read handle for worksheet object
Returns:
value (caller must free the result) or NULL if no more cells are available in the current row
See also:
xlsxioread_sheet_open()
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_string ( xlsxioreadersheet  sheethandle,
XLSXIOCHAR **  pvalue 
)

get next cell from worksheet as a string

Parameters:
sheethandle read handle for worksheet object
pvalue pointer where string will be stored if data is available (caller must free the result)
Returns:
non-zero if a new cell was available in the current row
See also:
xlsxioread_sheet_open()
xlsxioread_sheet_next_cell()
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_int ( xlsxioreadersheet  sheethandle,
int64_t *  pvalue 
)

get next cell from worksheet as an integer

Parameters:
sheethandle read handle for worksheet object
pvalue pointer 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()
DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_float ( xlsxioreadersheet  sheethandle,
double *  pvalue 
)

get next cell from worksheet as a floating point value

Parameters:
sheethandle read handle for worksheet object
pvalue pointer 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()
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:
sheethandle read handle for worksheet object
pvalue pointer 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()
 All Files Functions Typedefs Defines

Generated on 7 Jul 2020 for XLSX I/O by  doxygen 1.6.1