1.下载libxls源码包:
    
     http://sourceforge.net/projects/libxls/
    
    
   
2.安装
(1)./configre
(2)make
(3) make install
(4)由于头文件跟库文件的目录放的位置不对,所以需要手动把它们拷贝到系统路径下面去
    cp -r -v /usr/local/libxls/include/libxls/ /usr/include
    
    cp -r -v /usr/local/libxls/lib/ /usr
   
cp -r -v /usr/local/libxls/include/xls.h /usr/include
一个简单的例子:read_xls.c
#include <stdio.h>
#include <stdlib.h>
#include <xls.h>
#include <unistd.h>
#include <string.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) {
    fprintf(stderr, "please input the xml file.");
    return EXIT_FAILURE;
  }
  pWb = xls_open(argv[1], "UTF-8");
  if (NULL == pWb) {
    fprintf(stderr, "File not found!\n");
    return EXIT_FAILURE;
  }
  pWs = xls_getWorkSheet(pWb, 0); 
  xls_parseWorkSheet(pWs);
  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");
  }
  xls_close_WS(pWs);
  xls_close_WB(pWb);
  return 0;
}
(5)编译运行
gcc -lxlsreader read_xls.c -o read_xls
但是在运行的时候会报错:
error while loading shared libraries: libxlsreader.so.1: cannot open shared   
    出现这类错误表示,系统不知道
    
     xxx.so
    
    放在哪个目录下,这时候就要在/etc/
    
     ld.so.conf中加入xxx.so所在的目录。
    
   
    
     一般而言,有很多的so会存放在/usr/local/lib这个目录底下,去这个目录底下找,果然发现自己所需要的.so文件。
    
   
    
     所以,在/etc/ld.so.conf中加入/usr/local/libx
     
      sl/lib
     
     这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。
    
   
或者在/etc/ld.so.conf.d/下新建一个.conf文件,并在其中加入目标路径就可以了,在运行/sbin/ldconfig
 
