Solved

paradox7 table to Excel97

Posted on 1998-09-19
3
223 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
Comment Utility
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
Comment Utility
Hello.


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


sakya
 


0
 

Author Comment

by:Syouchi
Comment Utility
Thank you.

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

Syouchi.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

9 Experts available now in Live!

Get 1:1 Help Now