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; }
int ExportAnyData(CString filename, vector<string> &orders) { Book* book = xlCreateBook(); if(!book) return 0; for(vector<string>::iterator it = orders.begin(); it != orders.end(); it++) { CString Filename = it->c_str(); Filename += ".xml"; TiXmlElement *Root = getXMLRoot(Filename); Sheet* sheet = book->addSheet(it->c_str()); if(!sheet) return 0; addOneSheet(sheet, Root); delete Root->GetDocument(); } if(book->save(_T(filename.GetBuffer(0)) )) { return 1; } else { return 0; } book->release(); }
int main() { BookHandle book = xlCreateBook(); if(book) { SheetHandle sheet = xlBookAddSheet(book, "Sheet1", 0); if(sheet) { FormatHandle dateFormat; xlSheetWriteStr(sheet, 2, 1, "Hello, World !", 0); xlSheetWriteNum(sheet, 3, 1, 1000, 0); dateFormat = xlBookAddFormat(book, 0); xlFormatSetNumFormat(dateFormat, NUMFORMAT_DATE); xlSheetWriteNum(sheet, 4, 1, xlBookDatePack(book, 2008, 4, 29, 0, 0, 0, 0), dateFormat); xlSheetSetCol(sheet, 1, 1, 12, 0, 0); } if(xlBookSave(book, "example.xls")) printf("File example.xls has been created.\n"); xlBookRelease(book); } return 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; }
int main() { BookHandle book = xlCreateBook(); if(book) { FontHandle font; FormatHandle format; SheetHandle sheet; font = xlBookAddFont(book, 0); xlFontSetName(font, L"Impact"); xlFontSetSize(font, 36); format = xlBookAddFormat(book, NULL); xlFormatSetAlignH(format, ALIGNH_CENTER); xlFormatSetBorder(format, BORDERSTYLE_MEDIUMDASHDOTDOT); xlFormatSetBorderColor(format, COLOR_RED); xlFormatSetFont(format, font); sheet = xlBookAddSheet(book, L"Custom", 0); if(sheet) { xlSheetWriteStr(sheet, 2, 1, L"Format", format); xlSheetSetCol(sheet, 1, 1, 25, 0, 0); } if(xlBookSave(book, L"format.xls")) printf("\nFile format.xls has been created.\n"); } printf("\nPress any key to exit..."); _getch(); return 0; }
bool XlsHelper::CreateWookbook() { workbook_ = xlCreateBook(); if (workbook_) { return true; } else { return false; } }
static PyObject * init(XLPyBook *self, PyObject *args) { int *bookType = 0; if(!PyArg_ParseTuple(args, "|i", &bookType)) return NULL; if (bookType == 0) { self->handler = xlCreateBook(); } else { self->handler = xlCreateXMLBook(); } Py_RETURN_NONE; }
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; }
void test(int number) { BookHandle book; SheetHandle sheet; clock_t t1, t2, t3; int row, col; double d, n; printf("---------------------------------\n"); if(number == 1) { printf(" strings \n"); } else { printf(" numbers \n"); } printf("---------------------------------\n"); book = xlCreateBook(); if(book) { sheet = xlBookAddSheet(book, "Sheet1", 0); if(sheet) { printf("writing %d cells... ", (maxRow - 1) * maxCol); t1 = clock(); if(number == 1) { for(row = 1; row < maxRow; ++row) { for(col = 0; col < maxCol; ++col) { xlSheetWriteStr(sheet, row, col, makeString(), 0); } } } else { for(row = 1; row < maxRow; ++row) { for(col = 0; col < maxCol; ++col) { xlSheetWriteNum(sheet, row, col, 1234, 0); } } } printf("ok\n"); t2 = clock(); d = (double)(t2 - t1) / CLOCKS_PER_SEC; printf("time: %.3f sec\n", d); if(d > 0) { n = (maxRow - 1) * maxCol / d; printf("speed: %d cells/sec\n", (int)n); } printf("\n"); printf("saving... "); if(number == 1) { xlBookSave(book, "perfstr.xls"); } else { xlBookSave(book, "perfnum.xls"); } printf("ok\n"); t3 = clock(); printf("time: %.3f sec\n\n", (double)(t3 - t2) / CLOCKS_PER_SEC); printf("total time: %.3f sec\n", (double)(t3 - t1) / CLOCKS_PER_SEC); d = (double)(t3 - t1) / CLOCKS_PER_SEC; if(d > 0) { n = (maxRow - 1) * maxCol / d; printf("speed with saving on disk: %d cells/sec\n", (int)n); } printf("\n"); } xlBookRelease(book); } }
int main() { BookHandle book = xlCreateBook(); if(book) { FontHandle boldFont; FontHandle titleFont; FormatHandle titleFormat; FormatHandle headerFormat; FormatHandle descriptionFormat; FormatHandle amountFormat; FormatHandle totalLabelFormat; FormatHandle totalFormat; FormatHandle signatureFormat; SheetHandle sheet; boldFont = xlBookAddFont(book, 0); xlFontSetBold(boldFont, 1); titleFont = xlBookAddFont(book, 0); xlFontSetName(titleFont, L"Arial Black"); xlFontSetSize(titleFont, 16); titleFormat = xlBookAddFormat(book, 0); xlFormatSetFont(titleFormat, titleFont); headerFormat = xlBookAddFormat(book, 0); xlFormatSetAlignH(headerFormat, ALIGNH_CENTER); xlFormatSetBorder(headerFormat, BORDERSTYLE_THIN); xlFormatSetFont(headerFormat, boldFont); xlFormatSetFillPattern(headerFormat, FILLPATTERN_SOLID); xlFormatSetPatternForegroundColor(headerFormat, COLOR_TAN); descriptionFormat = xlBookAddFormat(book, 0); xlFormatSetBorderLeft(descriptionFormat, BORDERSTYLE_THIN); amountFormat = xlBookAddFormat(book, 0); xlFormatSetNumFormat(amountFormat, NUMFORMAT_CURRENCY_NEGBRA); xlFormatSetBorderLeft(amountFormat, BORDERSTYLE_THIN); xlFormatSetBorderRight(amountFormat, BORDERSTYLE_THIN); totalLabelFormat = xlBookAddFormat(book, 0); xlFormatSetBorderTop(totalLabelFormat, BORDERSTYLE_THIN); xlFormatSetAlignH(totalLabelFormat, ALIGNH_RIGHT); xlFormatSetFont(totalLabelFormat, boldFont); totalFormat = xlBookAddFormat(book, 0); xlFormatSetNumFormat(totalFormat, NUMFORMAT_CURRENCY_NEGBRA); xlFormatSetBorder(totalFormat, BORDERSTYLE_THIN); xlFormatSetFont(totalFormat, boldFont); xlFormatSetFillPattern(totalFormat, FILLPATTERN_SOLID); xlFormatSetPatternForegroundColor(totalFormat, COLOR_YELLOW); signatureFormat = xlBookAddFormat(book, 0); xlFormatSetAlignH(signatureFormat, ALIGNH_CENTER); xlFormatSetBorderTop(signatureFormat, BORDERSTYLE_THIN); sheet = xlBookAddSheet(book, L"Invoice", 0); if(sheet) { xlSheetWriteStr(sheet, 2, 1, L"Invoice No. 3568", titleFormat); xlSheetWriteStr(sheet, 4, 1, L"Name: John Smith", NULL); xlSheetWriteStr(sheet, 5, 1, L"Address: San Ramon, CA 94583 USA", 0); xlSheetWriteStr(sheet, 7, 1, L"Description", headerFormat); xlSheetWriteStr(sheet, 7, 2, L"Amount", headerFormat); xlSheetWriteStr(sheet, 8, 1, L"Ball-Point Pens", descriptionFormat); xlSheetWriteNum(sheet, 8, 2, 85, amountFormat); xlSheetWriteStr(sheet, 9, 1, L"T-Shirts", descriptionFormat); xlSheetWriteNum(sheet, 9, 2, 150, amountFormat); xlSheetWriteStr(sheet, 10, 1, L"Tea cups", descriptionFormat); xlSheetWriteNum(sheet, 10, 2, 45, amountFormat); xlSheetWriteStr(sheet, 11, 1, L"Total:", totalLabelFormat); xlSheetWriteNum(sheet, 11, 2, 280, totalFormat); xlSheetWriteStr(sheet, 14, 2, L"Signature", signatureFormat); xlSheetSetCol(sheet, 1, 1, 40, 0, 0); xlSheetSetCol(sheet, 2, 2, 15, 0, 0); } if(xlBookSave(book, L"invoice.xls")) printf("\nFile invoice.xls has been created.\n"); xlBookRelease(book); } printf("\nPress any key to exit..."); _getch(); return 0; }