Solved

reading excel file using borland 6.0

Posted on 2004-09-20
9
844 Views
Last Modified: 2012-08-13
I am trying to read excel file using Borland 6.0. I think TExcelWorksheet component is the way to go but I can not find any documentation as how to use it, can you suggest a source of reference that contains some examples of how this component.
0
Comment
Question by:Masood_b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 12105477
Example code:
With TExcelApplication Excel, TExcelWorkBook Book and TExcelWorksheet Sheet..


        WideString fname = "c:\\test.xls";
        WideString sname = "Hello World";
        RangePtr r;
        Excel->Connect();
        Book->ConnectTo(Excel->Workbooks->Open(fname));
        Sheet->ConnectTo(Book->Worksheets->get_Item(1));

        Excel->Set_Visible(0, True);
        Sheet->Set_Name(sname);
        r = Sheet->Cells->SpecialCells(xlCellTypeLastCell);
        long x = r->Column;
        long y = r->Row;
        r->set_Formula("=sum(a1:b3)+1000");
        long v = r->get_Value();
        Sheet->Cells->set__Default(y+1, 1, v);
        r = Sheet->Cells->get_Range_("a1", "b20");
        FontPtr f = r->get_Font();
        r->set_Formula("=rand()");
        r = r = Sheet->Cells->SpecialCells(xlCellTypeLastCell);
        y = r->Row;
        Sheet->Cells->set__Default(y+2, 1, "=average(a1:b20)");
        Sheet->Cells->Calculate();
        f->set_Color(clRed);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Masood_b
ID: 12108427
Axter

I tried the set of code you gave me I get these error message from compiler what do you suggest as the solution

Build
  [C++ Error] Unit1.cpp(21): E2285 Could not find a match for 'Sheets::get_Item(int)'
  [C++ Error] Unit1.cpp(23): E2316 'Set_Visible' is not a member of 'TExcelApplication'
  [C++ Error] Unit1.cpp(24): E2316 'Set_Name' is not a member of 'TExcelWorksheet'
  [C++ Error] Unit1.cpp(28): E2034 Cannot convert 'char *' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(28): E2342 Type mismatch in parameter 'Param1' (wanted 'tagVARIANT', got 'char *')
  [C++ Error] Unit1.cpp(29): E2034 Cannot convert 'tagVARIANT' to 'long'
  [C++ Error] Unit1.cpp(30): E2034 Cannot convert 'long' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(30): E2342 Type mismatch in parameter 'RowIndex' (wanted 'tagVARIANT', got 'long')
  [C++ Error] Unit1.cpp(30): E2034 Cannot convert 'int' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(30): E2342 Type mismatch in parameter 'ColumnIndex' (wanted 'tagVARIANT', got 'int')
  [C++ Error] Unit1.cpp(30): E2034 Cannot convert 'long' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(30): E2342 Type mismatch in parameter 'Param3' (wanted 'tagVARIANT', got 'long')
  [C++ Error] Unit1.cpp(31): E2034 Cannot convert 'char *' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(31): E2342 Type mismatch in parameter 'Cell1' (wanted 'tagVARIANT', got 'char *')
  [C++ Error] Unit1.cpp(31): E2034 Cannot convert 'char *' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(31): E2342 Type mismatch in parameter 'Cell2' (wanted 'tagVARIANT', got 'char *')
  [C++ Error] Unit1.cpp(33): E2034 Cannot convert 'char *' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(33): E2342 Type mismatch in parameter 'Param1' (wanted 'tagVARIANT', got 'char *')
  [C++ Error] Unit1.cpp(36): E2034 Cannot convert 'long' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(36): E2342 Type mismatch in parameter 'RowIndex' (wanted 'tagVARIANT', got 'long')
  [C++ Error] Unit1.cpp(36): E2034 Cannot convert 'int' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(36): E2342 Type mismatch in parameter 'ColumnIndex' (wanted 'tagVARIANT', got 'int')
  [C++ Error] Unit1.cpp(36): E2034 Cannot convert 'char *' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(36): E2342 Type mismatch in parameter 'Param3' (wanted 'tagVARIANT', got 'char *')
  [C++ Error] Unit1.cpp(38): E2034 Cannot convert 'const TColor' to 'tagVARIANT'
  [C++ Error] Unit1.cpp(38): E2228 Too many error or warning messages
0
 
LVL 30

Expert Comment

by:Axter
ID: 12108563
Looks  like you don't have the right header files included.

Did you download this library on to your computer?

If so, do a keyword search for the above member function errors, and see if you can find the required header.
0
 

Author Comment

by:Masood_b
ID: 12111152
I tried to the search for the member function and could not find any info on them.
What should I use as the header and library.

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12632996
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question