1 module xlsxio;
2 
3 /*****************************************************************************
4 Copyright (C)  2016  Brecht Sanders  All Rights Reserved
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 THE SOFTWARE.
20 *****************************************************************************/
21 
22 
23 import core.stdc.time: time_t;
24 
25 version(XmlUnicode)
26 {
27 	alias wchar_t = wchar;
28 	alias XLSXIOCHAR = wchar_t;
29 	pragma(msg, "building with XLSXIOCHAR as wchar");
30 }
31 else
32 {
33 	alias XLSXIOCHAR = char;
34 	pragma(msg, "building with XLSXIOCHAR as char");
35 }
36 
37 
38 extern(C) @nogc nothrow:
39 struct xlsxio_read_struct;
40 struct xlsxio_read_sheet_struct;
41 struct xlsxio_read_sheetlist_struct;
42 struct xlsxio_write_struct;
43 
44 void xlsxioread_get_version (int* pmajor, int* pminor, int* pmicro);
45 const(XLSXIOCHAR)* xlsxioread_get_version_string ();
46 alias xlsxioreader = xlsxio_read_struct*;
47 xlsxioreader xlsxioread_open (const(char*) filename);
48 xlsxioreader xlsxioread_open_filehandle (int filehandle);
49 xlsxioreader xlsxioread_open_memory (void* data, ulong datalen, int freedata);
50 void xlsxioread_close (xlsxioreader handle);
51 alias xlsxioread_list_sheets_callback_fn = int function(const(XLSXIOCHAR)* name, void* callbackdata);
52 void xlsxioread_list_sheets (xlsxioreader handle, xlsxioread_list_sheets_callback_fn callback, void* callbackdata);
53 
54 enum XLSXIOREAD_SKIP_NONE           = 0;
55 enum XLSXIOREAD_SKIP_EMPTY_ROWS      = 0x01;
56 enum XLSXIOREAD_SKIP_EMPTY_CELLS     = 0x02;
57 enum XLSXIOREAD_SKIP_ALL_EMPTY       = (XLSXIOREAD_SKIP_EMPTY_ROWS | XLSXIOREAD_SKIP_EMPTY_CELLS);
58 enum XLSXIOREAD_SKIP_EXTRA_CELLS     = 0x04;
59 alias xlsxioread_process_cell_callback_fn = int function(size_t row, size_t col, const(XLSXIOCHAR)* value, void* callbackdata);
60 alias xlsxioread_process_row_callback_fn = int function(size_t row, size_t maxcol, void* callbackdata);
61 int xlsxioread_process (xlsxioreader handle, const(XLSXIOCHAR)* sheetname, uint flags, xlsxioread_process_cell_callback_fn cell_callback, xlsxioread_process_row_callback_fn row_callback, void* callbackdata);
62 alias xlsxioreadersheetlist = xlsxio_read_sheetlist_struct*;
63 xlsxioreadersheetlist xlsxioread_sheetlist_open (xlsxioreader handle);
64 void xlsxioread_sheetlist_close (xlsxioreadersheetlist sheetlisthandle);
65 const(XLSXIOCHAR)* xlsxioread_sheetlist_next (xlsxioreadersheetlist sheetlisthandle);
66 alias xlsxioreadersheet = xlsxio_read_sheet_struct*;
67 xlsxioreadersheet xlsxioread_sheet_open (xlsxioreader handle, const(XLSXIOCHAR)* sheetname, uint flags);
68 void xlsxioread_sheet_close (xlsxioreadersheet sheethandle);
69 int xlsxioread_sheet_next_row (xlsxioreadersheet sheethandle);
70 XLSXIOCHAR* xlsxioread_sheet_next_cell (xlsxioreadersheet sheethandle);
71 int xlsxioread_sheet_next_cell_string (xlsxioreadersheet sheethandle, XLSXIOCHAR** pvalue);
72 int xlsxioread_sheet_next_cell_int (xlsxioreadersheet sheethandle, long* pvalue);
73 int xlsxioread_sheet_next_cell_float (xlsxioreadersheet sheethandle, double* pvalue);
74 int xlsxioread_sheet_next_cell_datetime (xlsxioreadersheet sheethandle, time_t* pvalue);
75 void xlsxiowrite_get_version (int* pmajor, int* pminor, int* pmicro);
76 const(char)* xlsxiowrite_get_version_string ();
77 alias xlsxiowriter = xlsxio_write_struct*;
78 xlsxiowriter xlsxiowrite_open (const(char)* filename, const(char)* sheetname);
79 int xlsxiowrite_close (xlsxiowriter handle);
80 void xlsxiowrite_set_detection_rows (xlsxiowriter handle, size_t rows);
81 void xlsxiowrite_set_row_height (xlsxiowriter handle, size_t height);
82 void xlsxiowrite_add_column (xlsxiowriter handle, const(char)* name, int width);
83 void xlsxiowrite_add_cell_string (xlsxiowriter handle, const(char)* value);
84 void xlsxiowrite_add_cell_int (xlsxiowriter handle, long value);
85 void xlsxiowrite_add_cell_float (xlsxiowriter handle, double value);
86 void xlsxiowrite_add_cell_datetime (xlsxiowriter handle, time_t value);
87 void xlsxiowrite_next_row (xlsxiowriter handle);