-3
A
回答
-1
閱讀如果你的意思libxls:
有哪些可以作爲示例代碼源存檔內部測試。 下面是libxls-1.4.0/test/test2.c
內容:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of libxls -- A multiplatform, C/C++ library
* for parsing Excel(TM) files.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2004 Komarov Valery
* Copyright 2006 Christophe Leitienne
* Copyright 2008-2012 David Hoerl
*
*/
// THIS FILE LETS YOU QUICKLY FEED A .xls FILE FOR PARSING
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "libxls/xls.h"
int main(int argc, char *argv[])
{
xlsWorkBook* pWB;
xlsWorkSheet* pWS;
unsigned int i;
if(argc != 2) {
printf("Need file arg\n");
exit(0);
}
struct st_row_data* row;
WORD t,tt;
pWB=xls_open(argv[1],"UTF-8");
if (pWB!=NULL)
{
for (i=0;i<pWB->sheets.count;i++)
printf("Sheet N%i (%s) pos %i\n",i,pWB->sheets.sheet[i].name,pWB->sheets.sheet[i].filepos);
pWS=xls_getWorkSheet(pWB,0);
xls_parseWorkSheet(pWS);
printf("pWS->rows.lastrow %d\n", pWS->rows.lastrow);
for (t=0;t<=pWS->rows.lastrow;t++)
{
printf("DO IT");
row=&pWS->rows.row[t];
xls_showROW(row);
for (tt=0;tt<=pWS->rows.lastcol;tt++)
{
xls_showCell(&row->cells.cell[tt]);
}
}
printf("Count of rows: %i\n",pWS->rows.lastrow);
printf("Max col: %i\n",pWS->rows.lastcol);
printf("Count of sheets: %i\n",pWB->sheets.count);
xls_showBookInfo(pWB);
} else {
printf("pWB == NULL\n");
}
return 0;
}
如果你的意思libxl:
下面你會發現從http://www.libxl.com/ C語言編寫的一個數據讀取的例子。 此外,他們在其主頁上提供documentation和more examples。
BookHandle book = xlCreateBook();
if(book)
{
if(xlBookLoad(book, L"example.xls"))
{
SheetHandle sheet = xlBookGetSheet(book, 0);
if(sheet)
{
double d;
const wchar_t* s = xlSheetReadStr(sheet, 2, 1, NULL);
if(s) wprintf(L"%s\n", s);
d = xlSheetReadNum(sheet, 3, 1, NULL);
printf("%g\n", d);
}
}
xlBookRelease(book);
}
+0
爲什麼downvote? 請留下評論,以便我可以解決可能的問題與我的答案! – g0hl1n
相關問題
- 1. c#讀取excel文件
- 2. 讀取Excel文件從C#
- 3. 使用ExcelLibrary在C#中讀取Excel .xlsx文件時出現OutOfMemoryException
- 4. 用C#讀取Excel xlsb文件
- 5. 讀取密碼保護excel文件,而不使用OLEDB在c#
- 6. 在使用ADO.Net讀取C#excel文件時出現問題
- 7. 使用adodb讀取64位Windows 7中的excel文件的C++?
- 8. 使用Microsoft DocumentFormat.OpenXml SDK讀取c#中的excel文件
- 9. 使用C#中的OLEDB讀取密碼保護的excel文件
- 10. 使用OleDB讀取c#中的excel文件?
- 11. 用read_excel讀取excel文件
- 12. 在C中讀取Excel#
- 13. 在C中讀取文件讀取#
- 14. 讀取Excel文件
- 15. 無法讀取excel文件,使用openpyxl
- 16. 使用Html5讀取Excel文件
- 17. 使用Gembox讀取Excel文件 - Columns.Count = 0
- 18. 如何使用AJAX讀取excel文件?
- 19. 使用PHP讀取MS Excel 2007文件
- 20. 使用Java讀取excel文件
- 21. 使用HSSF讀取Excel文件
- 22. 使用PHP讀取Excel文件
- 23. 使用POI EventModel讀取Excel文件
- 24. 在文件中讀取C++
- 25. 在C中讀取文件
- 26. 在C中讀取文件
- 27. C#讀取Excel 2007 xlsm文件的庫?
- 28. C#Excel文件OLEDB讀取HTML導入
- 29. C#按列讀取Excel文件索引
- 30. 在PHP中讀取Excel文件
你可以得到所有細節[這裏](http://www.libxl.com) – Zico
我認爲[libxls(http://libxls.sourceforge.net/)的意思,而不是[libxl] (http://www.libxl.com/)? – g0hl1n