Xlslib is a cross-platform Excel tableWriteClass Library. That is to say, you can call it in C and C ++ under Linux to output an Excel table file.
Download the source code, decompress it, compile and install it.
Source code: http://sourceforge.net/projects/xlslib/files/
Run the following command on the terminal:
./Configre
Make
Make check
Make install
In the last step, make install must switch to the root user to write the header file and library file to/usr.
After this step, the default installed library files are stored in/usr/local/lib, which is not in the default lib path of the system. You need to manually copy them
Sudo CP/usr/local/lib/libxls */usr/lib
Before writingSource codeRemember to include the following two header files, or the compilation will fail!
# Include <wchar. h>
# Include <stdbool. h>
For the example of how to use it, 2.3.4 seems to have changed a lot. Most of the source code searched on the internet is unavailable ,,
You can view it in the targets/test/folder under the source code directory,
Mainc. C is an example of calling xlslib in C. maincpp. cpp is an example of calling xlslib in C ++.
The following is a simple example: WB. c
You can add the XLS library during compilation.
Gcc wb. C-o WB-lxls
# Include <stdio. h> # include <string. h> # include <wchar. h> # include <stdbool. h> # include <errno. h> # include <xlslib/xlslib. h> int main (INT argc, char * argv []) {workbook * WB; worksheet * ws; WB = xlsnewworkbook (); Ws = xlsworkbooksheet (WB, "sheet1 "); xlsworksheetlabel (WS, 0, 1, "name", null); xlsworksheetlabel (WS, 0, 2, "us", null); xlsworksheetlabel (WS, 0, 3, "cn", null); xlsworksheetlabel (WS, 0, 4, "TR", nu Ll); int err = xlsworkbookdump (WB, "blank.xls"); xlsdeleteworkbook (WB); If (Err! = 0) {fprintf (stderr, "Dump xls file failed: I/O failure % d. \ n", err); Return-1;} return 0 ;}