1
我正在嘗試使用LibXL。我可以從工作表中提取數據,但需要一個函數來將具有Excel行和列索引的字符串轉換爲startRow,endRow,startCol,endCol,即無法使LibXL xlSheetGetNamedRange正常工作
將「A1:B3」轉換爲startRow = 0,endRow = 2,startCol = 0,endCol = 1(LibXL使用基於0的索引)
我試過了我能想到的所有東西。該庫沒有附帶任何使用該功能的示例,而且文檔相當稀少。我究竟做錯了什麼?
這裏是我的代碼:
int main()
{
const char range[] = "B2:C3";
int i, ret, rowFirst=0, rowLast=0, colFirst=0, colLast=0;
BookHandle book;
SheetHandle sheet;
book = xlCreateBook();
ret = xlBookLoad(book, "/home/jason/Downloads/panel.xls");
sheet = xlBookGetSheet(book, 0);
ret = xlSheetGetNamedRange(sheet, &range[0], &rowFirst, &rowLast, &colFirst, &colLast);
printf("ret from xlSheet...Range = %d\n", ret);
printf("%s\n", xlBookErrorMessage(book));
printf("rowLast = %d\n", rowLast);
printf("rowLast = %d\n", rowLast);
printf("colFirst = %d\n", colFirst);
printf("colLast = %d\n", colLast);
return 0;
}