Delphi Control Excel Generate report

Source: Internet
Author: User
Tags ole

Summary: Excel is currently the most popular data report making tool. This article describes how to use Delphi to control the data exchange between the database and the report, and discuss some details of the report making project.

1 Introduction

As the important information carrier of the enterprises and institutions, the data report form has been used in the practical work with the continuous advancement of information construction. Therefore, the data report has become an important function in the management information system, and because of the diversity of the data and the increase of the statistic information, the system realization of the data report becomes more and more complicated.

Delphi is an efficient Visual database management Information System development tool. But the report controls provided in the Delphi development environment are not ideal when making complex reports, whether it is the Quick Report control group provided in the previous release, or the rave control group provided by Delphi 7. Will not allow users to make changes to the generated report, and program control is difficult to implement. Excel as a modern office commonly used spreadsheet production tools, with its easy to operate and practical, has been the industry's favorite office staff. According to the practical application, this paper introduces various methods of using Delphi programming to control Excel to generate report.

2 Delphi Control method of Excel

2.1 Creating Excel Files

To control excel in Delphi, you must use OLE Automation. OLE2 is now generally used to create OLE objects, and when an OLE object is activated, the server program activates only within the container program, which is called "in-place activation" (in-place activation).

When you create an Excel file, you first create an OLE object and then create the worksheet worksheet in the object, as shown in the function Createexcel:

function createExcel:variant;
var
  v:variant;
  sheet:variant;
begin
  v:=createoleobject('Excel.Application');//创建OLE对象
  v.visible:=true;
  v.workbooks.add(-4167); //添加工作表
  v.workbooks[1].sheets[1].name:='test';
  sheet:=v.workbooks[1].sheets['test'];
  return v;
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.