How to Use libxls to read and use xlslib to write excel on linux, libxlsxlslib
Read excel files: libxls-1.4.0.zip
: Http://sourceforge.net/projects/libxls/
Installation Method:
./Configure
Make
Make install
Sudo cp-r-v/usr/local/libxls/include/libxls // usr/include
Sudo cp-r-v/usr/local/libxls/include/xlx. h/usr/include
Sudo cp-r-v/usr/local/libxls/lib // usr
// Example:
# Include <stdio. h>
# Include <stdlib. h>
# Include <xls. h>
# Include <unistd. h>
//////////////////////////////////////// /////////
Int main (int argc, char ** argv)
{
XlsWorkBook * pWb;
XlsWorkSheet * pWs;
Struct st_row_data * row;
Int r, c;
Char buf [512], result [512];
If (argc <2)
{
Sprintf (stderr, "please input the xml file .");
Return EXIT_FAILURE;
}
// Open workbook, choose standard coversion
PWb = xls_open (argv [1], "UTF-8 ");
If (NULL = pWb)
{
Fprintf (stderr, "File not found! \ N ");
Return EXIT_FAILURE;
}
// Open and parse the first sheet
PWs = xls_getWorkSheet (pWb, 0 );
Xls_parseWorkSheet (pWs );
// Process all rows of the first sheet
For (r = 0; r <= pWs-> rows. lastrow; r ++)
{
Row = & pWs-> rows. row [r];
For (c = 0; c <= pWs-> rows. lastcol; c ++)
{
If (row-> cells. cell [c]. str! = NULL)
{
Printf ("% s \ t", row-> cells. cell [c]. str );
}
}
Printf ("\ n ");
}
// Close workSheet
Xls_close_WS (pWs );
// Close workbook
Xls_close_WB (pWb );
Return 0;
}
Compile: gcc-o readXls. c-lxlsreader
Reference: http://blog.csdn.net/yao_guet/article/details/7326065
Http://www.codeweblog.com/libxls%E4%BD%BF%E7%94%A8/
Http://blog.csdn.net/zhangqiu1989/article/details/8822853
//////////////////////////////////////// /////////////////
Generate excel file: xlslib-package-2.5.0.zip
: Http://sourceforge.net/projects/xlslib/
Installation Method:
./Configure
Make
Make install
Example:
# Include <string. h>
# Include <xlslib/xlslib. h>
Using namespace xlslib_core;
Using namespace std;
Int main (int argc, char * argv [])
{
Workbook wb;
Xf_t * xf = wb. xformat ();
Worksheet * ws;
Ws = wb. sheet ("sheet1 ");
String label = "Hello, World! ";
Ws-> label (1st, label, xf); // number starting from 0, 2nd rows, columns, that is, C3
Wb. Dump ("workbook.xls ");
Return 0;
}
Compile:
G ++ helloxls. cpp-lxls-I/usr/local/include/xlslib/-I/usr/local/include/-L/usr/local/lib/-o helloxls
Reference: http://ju.outofmemory.cn/entry/106483
Disclaimer: this blog is for reference by others. For your convenience, I have summarized it! Thank you, bloggers.