-
Notifications
You must be signed in to change notification settings - Fork 0
/
xlsxio_write.h
164 lines (141 loc) · 6.24 KB
/
xlsxio_write.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*****************************************************************************
Copyright (C) 2016 Brecht Sanders All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*****************************************************************************/
/**
* @file xlsxio_write.h
* @brief XLSX I/O header file for writing .xlsx files.
* @author Brecht Sanders
* @date 2016
* @copyright MIT
*
* Include this header file to use XLSX I/O for writing .xlsx files and
* link with -lxlsxio_write.
*/
#ifndef INCLUDED_XLSXIO_WRITE_H
#define INCLUDED_XLSXIO_WRITE_H
#include <stdlib.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
typedef signed __int64 int64_t;
#else
#include <stdint.h>
#endif
#include <time.h>
/*! \cond PRIVATE */
#ifndef DLL_EXPORT_XLSXIO
#ifdef _WIN32
#if defined(BUILD_XLSXIO_DLL) || defined(BUILD_XLSXIO_SHARED) || defined(xlsxio_write_SHARED_EXPORTS)
#define DLL_EXPORT_XLSXIO __declspec(dllexport)
#elif !defined(STATIC) && !defined(BUILD_XLSXIO_STATIC) && !defined(BUILD_XLSXIO)
#define DLL_EXPORT_XLSXIO __declspec(dllimport)
#else
#define DLL_EXPORT_XLSXIO
#endif
#else
#define DLL_EXPORT_XLSXIO
#endif
#endif
/*! \endcond */
#ifdef __cplusplus
extern "C" {
#endif
/*! \brief get xlsxio_write version
* \param pmajor pointer to integer that will receive major version number
* \param pminor pointer to integer that will receive minor version number
* \param pmicro pointer to integer that will receive micro version number
* \sa xlsxiowrite_get_version_string()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_get_version (int* pmajor, int* pminor, int* pmicro);
/*! \brief get xlsxio_write version string
* \return version string
* \sa xlsxiowrite_get_version()
*/
DLL_EXPORT_XLSXIO const char* xlsxiowrite_get_version_string ();
/*! \brief write handle for .xlsx object */
typedef struct xlsxio_write_struct* xlsxiowriter;
/*! \brief create and open .xlsx file
* \param filename path of .xlsx file to open
* \param sheetname name of worksheet
* \return write handle for .xlsx object or NULL on error
* \sa xlsxiowrite_close()
*/
DLL_EXPORT_XLSXIO xlsxiowriter xlsxiowrite_open (const char* filename, const char* sheetname);
/*! \brief close .xlsx file
* \param handle write handle for .xlsx object
* \return zero on success, non-zero on error
* \sa xlsxiowrite_open()
*/
DLL_EXPORT_XLSXIO int xlsxiowrite_close (xlsxiowriter handle);
/*! \brief specify how many initial rows will be buffered in memory to determine column widths
* \param handle write handle for .xlsx object
* \param rows number of rows to buffer in memory, zero for none
* Must be called before the first call to xlsxiowrite_next_row()
* \sa xlsxiowrite_add_column()
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_set_detection_rows (xlsxiowriter handle, size_t rows);
/*! \brief specify the row height to use for the current and next rows
* \param handle write handle for .xlsx object
* \param height row height (in text lines), zero for unspecified
* Must be called before the first call to any xlsxiowrite_add_ function of the current row
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_set_row_height (xlsxiowriter handle, size_t height);
/*! \brief add a column cell
* \param handle write handle for .xlsx object
* \param name column name
* \param width column width (in characters)
* Only one row of column names is supported or none.
* Call for each column, and finish column row by calling xlsxiowrite_next_row().
* Must be called before any xlsxiowrite_next_row() or the xlsxiowrite_add_cell_ functions.
* \sa xlsxiowrite_next_row()
* \sa xlsxiowrite_set_detection_rows()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_add_column (xlsxiowriter handle, const char* name, int width);
/*! \brief add a cell with string data
* \param handle write handle for .xlsx object
* \param value string value
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_add_cell_string (xlsxiowriter handle, const char* value);
/*! \brief add a cell with integer data
* \param handle write handle for .xlsx object
* \param value integer value
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_add_cell_int (xlsxiowriter handle, int64_t value);
/*! \brief add a cell with floating point data
* \param handle write handle for .xlsx object
* \param value floating point value
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_add_cell_float (xlsxiowriter handle, double value);
/*! \brief add a cell with date and time data
* \param handle write handle for .xlsx object
* \param value date and time value
* \sa xlsxiowrite_next_row()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_add_cell_datetime (xlsxiowriter handle, time_t value);
/*! \brief mark the end of a row (next cell will start on a new row)
* \param handle write handle for .xlsx object
* \sa xlsxiowrite_add_cell_string()
*/
DLL_EXPORT_XLSXIO void xlsxiowrite_next_row (xlsxiowriter handle);
#ifdef __cplusplus
}
#endif
#endif