XLSX I/O
xlsxio_read.h
Go to the documentation of this file.
1 /*****************************************************************************
2 Copyright (C) 2016 Brecht Sanders All Rights Reserved
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 *****************************************************************************/
22 
36 #ifndef INCLUDED_XLSXIO_READ_H
37 #define INCLUDED_XLSXIO_READ_H
38 
39 #include <stdlib.h>
40 #if defined(_MSC_VER) && _MSC_VER < 1600
41 typedef signed __int64 int64_t;
42 typedef unsigned __int64 uint64_t;
43 #else
44 #include <stdint.h>
45 #endif
46 #include <time.h>
47 
49 #ifndef XLSXIOCHAR
50 #if defined(XML_UNICODE_WCHAR_T)
51 #warning Building with XML_UNICODE_WCHAR_T and -fshort-wchar is not supported unless all other linked libraries and programs are also compiled with -fshort-wchar
52 #elif !defined(XML_UNICODE)
53 #define XLSXIOCHAR char
54 #else
55 #include <wchar.h>
56 #define XLSXIOCHAR wchar_t
57 #endif
58 #endif
59 
61 #ifndef DLL_EXPORT_XLSXIO
62 #ifdef _WIN32
63 #if defined(BUILD_XLSXIO_DLL) || defined(BUILD_XLSXIO_SHARED) || defined(xlsxio_write_SHARED_EXPORTS)
64 #define DLL_EXPORT_XLSXIO __declspec(dllexport)
65 #elif !defined(STATIC) && !defined(BUILD_XLSXIO_STATIC) && !defined(BUILD_XLSXIO)
66 #define DLL_EXPORT_XLSXIO __declspec(dllimport)
67 #else
68 #define DLL_EXPORT_XLSXIO
69 #endif
70 #else
71 #define DLL_EXPORT_XLSXIO
72 #endif
73 #endif
74 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
86 DLL_EXPORT_XLSXIO void xlsxioread_get_version (int* pmajor, int* pminor, int* pmicro);
87 
92 DLL_EXPORT_XLSXIO const XLSXIOCHAR* xlsxioread_get_version_string ();
93 
95 typedef struct xlsxio_read_struct* xlsxioreader;
96 
102 DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open (const char* filename);
103 
109 DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle (int filehandle);
110 
118 DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory (void* data, uint64_t datalen, int freedata);
119 
124 DLL_EXPORT_XLSXIO void xlsxioread_close (xlsxioreader handle);
125 
126 
127 
134 typedef int (*xlsxioread_list_sheets_callback_fn)(const XLSXIOCHAR* name, void* callbackdata);
135 
142 DLL_EXPORT_XLSXIO void xlsxioread_list_sheets (xlsxioreader handle, xlsxioread_list_sheets_callback_fn callback, void* callbackdata);
143 
144 
145 
152 #define XLSXIOREAD_SKIP_NONE 0
153 
154 #define XLSXIOREAD_SKIP_EMPTY_ROWS 0x01
155 
156 #define XLSXIOREAD_SKIP_EMPTY_CELLS 0x02
157 
158 #define XLSXIOREAD_SKIP_ALL_EMPTY (XLSXIOREAD_SKIP_EMPTY_ROWS | XLSXIOREAD_SKIP_EMPTY_CELLS)
159 
160 #define XLSXIOREAD_SKIP_EXTRA_CELLS 0x04
161 
172 typedef int (*xlsxioread_process_cell_callback_fn)(size_t row, size_t col, const XLSXIOCHAR* value, void* callbackdata);
173 
182 typedef int (*xlsxioread_process_row_callback_fn)(size_t row, size_t maxcol, void* callbackdata);
183 
195 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);
196 
197 
198 
200 typedef struct xlsxio_read_sheetlist_struct* xlsxioreadersheetlist;
201 
208 
213 DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close (xlsxioreadersheetlist sheetlisthandle);
214 
220 DLL_EXPORT_XLSXIO const XLSXIOCHAR* xlsxioread_sheetlist_next (xlsxioreadersheetlist sheetlisthandle);
221 
222 
223 
225 typedef struct xlsxio_read_sheet_struct* xlsxioreadersheet;
226 
231 DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_row_index (xlsxioreadersheet sheethandle);
232 
237 DLL_EXPORT_XLSXIO size_t xlsxioread_sheet_last_column_index (xlsxioreadersheet sheethandle);
238 
243 DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags (xlsxioreadersheet sheethandle);
244 
253 DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open (xlsxioreader handle, const XLSXIOCHAR* sheetname, unsigned int flags);
254 
259 DLL_EXPORT_XLSXIO void xlsxioread_sheet_close (xlsxioreadersheet sheethandle);
260 
266 DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_row (xlsxioreadersheet sheethandle);
267 
274 DLL_EXPORT_XLSXIO XLSXIOCHAR* xlsxioread_sheet_next_cell (xlsxioreadersheet sheethandle);
275 
284 DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_string (xlsxioreadersheet sheethandle, XLSXIOCHAR** pvalue);
285 
293 DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_int (xlsxioreadersheet sheethandle, int64_t* pvalue);
294 
302 DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_float (xlsxioreadersheet sheethandle, double* pvalue);
303 
311 DLL_EXPORT_XLSXIO int xlsxioread_sheet_next_cell_datetime (xlsxioreadersheet sheethandle, time_t* pvalue);
312 
313 
314 
320 DLL_EXPORT_XLSXIO void xlsxioread_free (XLSXIOCHAR* data);
321 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #endif
xlsxioread_sheetlist_open
DLL_EXPORT_XLSXIO xlsxioreadersheetlist xlsxioread_sheetlist_open(xlsxioreader handle)
open list of worksheet names
xlsxioread_sheet_next_cell
DLL_EXPORT_XLSXIO XLSXIOCHAR * xlsxioread_sheet_next_cell(xlsxioreadersheet sheethandle)
get next cell from worksheet
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
xlsxioread_get_version_string
const DLL_EXPORT_XLSXIO XLSXIOCHAR * xlsxioread_get_version_string()
get xlsxio_write version string
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)
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
xlsxioread_close
DLL_EXPORT_XLSXIO void xlsxioread_close(xlsxioreader handle)
close .xlsx file
xlsxioread_open_filehandle
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_filehandle(int filehandle)
open .xlsx file
xlsxioread_sheet_open
DLL_EXPORT_XLSXIO xlsxioreadersheet xlsxioread_sheet_open(xlsxioreader handle, const XLSXIOCHAR *sheetname, unsigned int flags)
open worksheet
xlsxioreadersheetlist
struct xlsxio_read_sheetlist_struct * xlsxioreadersheetlist
read handle for list of worksheet names
Definition: xlsxio_read.h:200
xlsxioread_free
DLL_EXPORT_XLSXIO void xlsxioread_free(XLSXIOCHAR *data)
free memory allocated by the library
xlsxioread_sheetlist_close
DLL_EXPORT_XLSXIO void xlsxioread_sheetlist_close(xlsxioreadersheetlist sheetlisthandle)
close worksheet
xlsxioreadersheet
struct xlsxio_read_sheet_struct * xlsxioreadersheet
read handle for worksheet object
Definition: xlsxio_read.h:225
xlsxioread_process_cell_callback_fn
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
Definition: xlsxio_read.h:172
xlsxioread_get_version
DLL_EXPORT_XLSXIO void xlsxioread_get_version(int *pmajor, int *pminor, int *pmicro)
get xlsxio_write version
xlsxioread_sheet_close
DLL_EXPORT_XLSXIO void xlsxioread_sheet_close(xlsxioreadersheet sheethandle)
close worksheet
xlsxioread_sheetlist_next
const DLL_EXPORT_XLSXIO XLSXIOCHAR * xlsxioread_sheetlist_next(xlsxioreadersheetlist sheetlisthandle)
get next worksheet name
xlsxioread_process_row_callback_fn
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
Definition: xlsxio_read.h:182
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
xlsxioread_open
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open(const char *filename)
open .xlsx file
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
xlsxioreader
struct xlsxio_read_struct * xlsxioreader
read handle for .xlsx object
Definition: xlsxio_read.h:95
xlsxioread_open_memory
DLL_EXPORT_XLSXIO xlsxioreader xlsxioread_open_memory(void *data, uint64_t datalen, int freedata)
open .xlsx from memory buffer
xlsxioread_sheet_flags
DLL_EXPORT_XLSXIO unsigned int xlsxioread_sheet_flags(xlsxioreadersheet sheethandle)
get flags used to open worksheet
xlsxioread_list_sheets_callback_fn
int(* xlsxioread_list_sheets_callback_fn)(const XLSXIOCHAR *name, void *callbackdata)
type of pointer to callback function for listing worksheets
Definition: xlsxio_read.h:134
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
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)
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
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)
XLSXIOCHAR
#define XLSXIOCHAR
character type used (usually char, but when XML_UNICODE is defined wchar_t)
Definition: xlsxio_read.h:53