Exemplo n.º 1
0
Arquivo: extract.c Projeto: 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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
static PyObject *
read_str(XLPySheet *self, PyObject *args)
{
	const int row, col;
	if(!PyArg_ParseTuple(args, "ii", &row, &col)) return NULL;

	FormatHandle fmt = NULL;
	const char *str = xlSheetReadStr(self->handler, row, col, &fmt);
	if(!str) Py_RETURN_NONE;

	if(!fmt) return Py_BuildValue("(sO)", str, Py_None);

	XLPyFormat *obj = PyObject_New(XLPyFormat, &XLPyFormatType);
	obj->handler = fmt;
	return Py_BuildValue("(sO)", str, obj);
}
Exemplo n.º 4
0
Arquivo: read.c Projeto: 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;
}