Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

paradox7 table to Excel97

Posted on 1998-09-19
3
Medium Priority
?
244 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 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

705 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