Thread: C++ Builder and Excel files

  1. #1
    Registered User
    Join Date
    Sep 2004

    C++ Builder and Excel files

    I need to generate Excel files based on database queries.
    I accomplished what I wanted to some extent.
    I use a TExcelApplication component to connect to Excel and fill the matrix with data gathered from a database query.
    But I'm having trouble generating more than one file within the same run of the program.
    The first file is ok , but when i try to load a second excel workbook it won't display anything but the header of the excel window.Besides if i try to fill a second workbook ,it causes Excel to raise an error when exiting.

    Here is quite how I do it,any help regarding what is wrong will be appreciated
    Second run of the below (trimmed)code does not work properly:
    BTW : Conenct Kind of the component is ckRunningOrNew and AutoConnect , AutoQuit are false

    TExcelApplication *Excel;
    TExcelWorksheet *ExcelWS = new TExcelWorksheet(this);
    TExcelWorkbook  *ExcelWB = new TExcelWorkbook(this);  
    ExcelWS->ConnectKind = Excel->ConnectKind;
    ExcelWB->ConnectKind = Excel->ConnectKind;
    Excel->set_SheetsInNewWorkbook(LOCALE_USER_DEFAULT, 1);
    // .....
    // Fill the matrix ... this is ok ...
    // ....
    // save file...
    ExcelWB->SaveAs((OleVariant)wcTmp,(OleVariant)xlNormal, EmptyParam, EmptyParam, (OleVariant)false, (OleVariant)false,
    delete wcTmp;
    delete ExcelWS;
    delete ExcelWB;
    Last edited by Salem; 09-23-2004 at 12:03 PM. Reason: [monty]tag tag tag tag tag tag tag tag tag tag tag tag tag tag[/monty]

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Can't you export the data as a comma (CSV) or tab separated text file? All spreadsheets can open these.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

  3. #3
    Registered User
    Join Date
    Sep 2004
    No , I can't
    I need to format the data

    Thanks yet

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    I dont use Borland...I could help you in VC++ if you have access?

    You could give anonytmouse's DispHelper library a go. Not sure if it will work on Borland but it might work for you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. looking for Borland Builder hints
    By BrownB in forum Tech Board
    Replies: 3
    Last Post: 11-07-2006, 10:57 AM
  2. Accessesing Excel files from borland c++ builder 6
    By warturtle in forum Windows Programming
    Replies: 4
    Last Post: 09-21-2005, 11:50 PM
  3. TExcelApplication problem in Builder
    By mfdemi in forum C++ Programming
    Replies: 0
    Last Post: 12-23-2004, 01:42 AM
  4. C++ Builder DataGrid data to Excel files
    By fadraga in forum C++ Programming
    Replies: 3
    Last Post: 10-12-2004, 11:38 AM
  5. Borland Builder & Office
    By gustavosserra in forum C++ Programming
    Replies: 4
    Last Post: 05-29-2004, 09:38 PM