Solved

reading excel file using borland 6.0

Posted on 2004-09-20
9
795 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
  • 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
 
LVL 30

Expert Comment

by:Axter
ID: 12105520
0
 
LVL 30

Expert Comment

by:Axter
ID: 12105574
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now