Solved

paradox7 table to Excel97

Posted on 1998-09-19
3
225 Views
Last Modified: 2010-04-06
Hello.

I want to write paradox7-type table data on a Excel97 sheet.
I can understand a code for Excel 95, but can't understand it for the Excel97.
Please teach me the code for the Excel 97.

My code for Excel 95 is as follows.

----------------------------------------------------------------------
procedure TForm1.WriteExcel(DBName:String);
var
  E_Excel: Variant;
  E_Application: Variant;
  E_WorkBook: Variant;
  E_WorkSheet: Variant;
  i,j: Integer;
  MyPath:string;
begin
  MyPath:=ExtractFilePath(ParamStr(0));

// open the Excel application
  E_Excel :=  CreateOleObject('Excel.Application');
  E_Application :=  E_Excel.Application;
  E_Application.Visible :=  TRUE;
  E_Application.WorkBooks.Open(Mypath+'MyData.XlS'); // decide a Excel file name
  E_WorkBook :=  E_Application.ActiveWorkbook;
  E_WorkSheet :=  E_Application.ActiveSheet;

// write Table1's data on the excel file
  i :=  1;
  ShowMessage(IntToStr(Table1.RecordCount));
  Table1.First;
  while not Table1.eof do
  begin
    E_WorkBook.WorkSheets.Cells(i,1).Value  :='1';
    //Table1.FieldByName('field name 1').AsString;
    E_WorkSheet.Cells(i,2).Value  :=  Table1.FieldByName('field name 2').AsString;
    E_WorkSheet.Cells(i,3).Value  :=  Table1.FieldByName('field name 3').AsString;
    E_WorkSheet.Cells(i,4).Value  :=  Table1.FieldByName('field name 4').AsString;

    Table1.Next;
  end;
  Table1.First;

//save and quit the Excel app.
  E_WorkBook.FileSaveAs('test.xls');
  E_Application.WorkBooks.Close;
  E_Excel.Quit;

end;

-----------------------------------------------------------------------------
Thanks for your help.

Syouchi.

0
Comment
Question by:Syouchi
  • 2
3 Comments
 

Expert Comment

by:sakya
ID: 1340233
Hello.

Hmmm...Maybe....

I think you just change Cells(0,0) to Cells[0,0].


sakya




0
 

Accepted Solution

by:
sakya earned 50 total points
ID: 1340234
Hello.


I forgot one thing.
You should use 'SaveAs' in stead of 'FileSaveAs'.


sakya
 


0
 

Author Comment

by:Syouchi
ID: 1340235
Thank you.

I spent a couple of days on this stupid probrem by the Microsoft's upgrade.

Syouchi.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi custom sort exception 6 135
Using idhttp to login to instagram 2 76
Comparing dates in Delphi. Greater than/ Less than 3 116
Delphi and Access based Enumeration 9 47
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

25 Experts available now in Live!

Get 1:1 Help Now