Solved

paradox7 table to Excel97

Posted on 1998-09-19
3
226 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 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