Solved

How to use TExcelApplication TExcelWorkBook TExcelWorksheet in builder 6

Posted on 2004-09-23
5
12,340 Views
Last Modified: 2013-11-17
I am trying to read an Excel file, I was provided the following code but I can not make it compile. Can you provide name of book(s) that explain how to use these components. I have placed the compiler error messages that I get at the end.

  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);

Complier Error Messages

[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
Comment
Question by:Masood_b
  • 2
5 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 12141492
Hello there,

Some books you will find usefull info are:
C++Builder 4 Unleashed.
C++ Builder 5 Developer's guide
C++ Builder 6 Developer's guide

gtokas.
0
 

Author Comment

by:Masood_b
ID: 12146370
Thank you for your response, I looked at C++ Builder 6 Developer's guide I did not see any documentation for TExcelApplication TExcelWorkBook TExcelWorksheet.

Can you suggest what I should be looking for.

Thanks you
0
 
LVL 16

Accepted Solution

by:
George Tokas earned 125 total points
ID: 12146758
Sorry you are right.
C++Builder5 Developer's guide have examples.
Also C++Builder 4 unleashed.

Check out for examples at borland's community site. Maybe there are some.
http://community.borland.com

gtokas.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to install eclipse SCADA on Linux Debian? 4 154
Java Help 2 86
Unable to start eclipse ? 17 154
eclipse package explorer vs project explorer view 2 184
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

821 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