示例#1
0
文件: extract.c 项目: icune/R
int main()
{
    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, 0);

                if(s) wprintf(L"%s\n", s);

                d = xlSheetReadNum(sheet, 3, 1, 0);
                printf("%g\n", d);
            }
        }     
       
        xlBookRelease(book);
    }

    printf("\nPress any key to exit...");
    _getch();

    return 0;
}
示例#2
0
文件: extract.c 项目: antontest/c
int main()
{
    BookHandle book = xlCreateBook();
    if(book) 
    {
        if(xlBookLoad(book, "example.xls")) 
        {
            SheetHandle sheet = xlBookGetSheet(book, 0);
            if(sheet)
            {
                double d;
                const char* s = xlSheetReadStr(sheet, 2, 1, 0);

                if(s) printf("%s\n", s);

                d = xlSheetReadNum(sheet, 3, 1, 0);
                printf("%g\n", d);
            }
        }     
       
        xlBookRelease(book);
    }

    return 0;
}
示例#3
0
文件: read.c 项目: antontest/c
int main(int argc, char **argv)
{
    SheetHandle sheet;
    BookHandle book = xlCreateBook();

    if (!book) return -1;

    xlBookLoad(book, "example.xls");
    sheet = xlBookGetSheet(book, 3);
    int row = xlSheetLastRow(sheet);
    int col = xlSheetLastCol(sheet);
    int i = 0, j = 0;
    char *str = NULL;
    int num;

    for (i = 0; i < row; i++) {
        for (j = 0; j < col; j++) {
            if (i != 0 && ( j == 0 || j == 4 || j == 5)) {
                num = xlSheetReadNum(sheet, i, j, 0);
                if (num > 0)
                    printf("%d ", num);
                else printf(" ");
            } else {
                str = (char *)xlSheetReadStr(sheet, i, j, 0);
                if (!str) {
                } else {
                    printf("%s ", str);
                }
            }
        }
        printf("\n");
    }
    //xlSheetWriteNum(sheet, 1, 1, 1111, 0);
    //xlBookSave(book, "example.xls");
    xlBookRelease(book);

    return 0;
}
示例#4
0
文件: book.c 项目: nahody/libxlpy
static PyObject *
load(XLPyBook *self, PyObject *args)
{
	const char* fileName;
	int size;
	PyObject *raw = NULL;
	if(!PyArg_ParseTuple(args, "s#|O!", &fileName, &size, &PyBool_Type, &raw))
		return NULL;

	if (raw && PyObject_IsTrue(raw)) {
		// fileName is treated as the buffer
		if(!xlBookLoadRaw(self->handler, fileName, size)) {
			Py_RETURN_FALSE;
		}
	}
	else {
		if(!xlBookLoad(self->handler, fileName)) {
			Py_RETURN_FALSE;
		}
	}

	Py_RETURN_TRUE;
}