Solved

paradox7 table to Excel97

Posted on 1998-09-19
3
229 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
[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
  • 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

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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

696 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