Home > Back-end >  Questions about Delphi Excel operation
Questions about Delphi Excel operation

Time:09-20

Is to give 2 table, table 1 and table 2, and table is generated by Delphi three statements (excel), how many how many financial statement data are generated,
(X is given by the data, Y is to automatically generate data)
I will only do add and delete access database, Excel will not, there is a great god can you tell me how to do it, or any similar case? Thank you,

Table 1:
The customer name shipping address contact...
XX XX XXX company

Table 2:
The customer name on June 7 August amounts owed arrears amount amounts owed
XXX XXX XXX XXX company

Table 3:
Hello Mr YY:
You balance of YYY yuan

Shipping address: YYY
Contact: YYY

CodePudding user response:

Delphi operation Excel simple example, you can also use Delphi's own controls, in the Servers page, on the same principle:
 
USES Comobj;
procedure TForm1.Button1Click(Sender: TObject);
Var
ExlApp WorkBook1, Sheet1: Variant;
J: integer;
The begin
Try
ExlApp:=CreateOleObject (' Excel. Application);
WorkBook1:=CreateOleObject ('. Excel Sheet);
Except,
MessageBox (handle, 'call wrong, there is no right to install Microsoft Excel! ', 'prompt', MB_OK + MB_ICONInformation);
The Exit;
end;
ExlApp. Visible:=True;
WorkBook1:=exlApp WorkBooks. Add;//add the workspace
Sheet1:=WorkBook1 WorkSheets [1].//get the first book
For j:=1 to 5 do
The begin
Sheet1. Columns [j]. Journal of numberformatlocal:='@';//set as text format
Sheet1. Cells [1, j] Interior. Color:=$00 d9ffce;//set the cell background to light green
Sheet1. Cells [1, j] Borders. [9] graphics.linestyle:=1;//set the border lines
Sheet1. Columns [j]. Journal of columnwidth:=20;//set the column width
Sheet1. Cells [j] 1, :='cell value;
end;
end;

CodePudding user response:

refer to the original poster AAA15079595120 response:
is to give 2 table, table 1 and table 2, and table is generated by Delphi three statements (excel), how many how many financial statement data are generated,
(X is given by the data, Y is to automatically generate data)
I will only do add and delete access database, Excel will not, there is a great god can you tell me how to do it, or any similar case? Thank you,

Table 1:
The customer name shipping address contact...
XX XX XXX company

Table 2:
The customer name on June 7 August amounts owed arrears amount amounts owed
XXX XXX XXX XXX company

Table 3:
Hello Mr YY:
You balance of YYY yuan

Shipping address: YYY
Contact: YYY


You this is to create Excel spreadsheet, if can't Excel imported into the Delphi ah,

CodePudding user response:

reference 1st floor santiaodahan response:
Delphi Excel simple example of operation, also can use Delphi's own controls, in the Servers page, on the same principle:
 
USES Comobj;
procedure TForm1.Button1Click(Sender: TObject);
Var
ExlApp WorkBook1, Sheet1: Variant;
J: integer;
The begin
Try
ExlApp:=CreateOleObject (' Excel. Application);
WorkBook1:=CreateOleObject ('. Excel Sheet);
Except,
MessageBox (handle, 'call wrong, there is no right to install Microsoft Excel! ', 'prompt', MB_OK + MB_ICONInformation);
The Exit;
end;
ExlApp. Visible:=True;
WorkBook1:=exlApp WorkBooks. Add;//add the workspace
Sheet1:=WorkBook1 WorkSheets [1].//get the first book
For j:=1 to 5 do
The begin
Sheet1. Columns [j]. Journal of numberformatlocal:='@';//set as text format
Sheet1. Cells [1, j] Interior. Color:=$00 d9ffce;//set the cell background to light green
Sheet1. Cells [1, j] Borders. [9] graphics.linestyle:=1;//set the border lines
Sheet1. Columns [j]. Journal of columnwidth:=20;//set the column width
Sheet1. Cells [j] 1, :='cell value;
end;
end;

You this is to create Excel spreadsheet, if can't Excel imported into the Delphi ah,

CodePudding user response:

reference AAA15079595120 reply: 3/f
Quote: refer to 1st floor santiaodahan response:

Delphi operation Excel simple example, you can also use Delphi's own controls, in the Servers page, on the same principle:
 
USES Comobj;
procedure TForm1.Button1Click(Sender: TObject);
Var
ExlApp WorkBook1, Sheet1: Variant;
J: integer;
The begin
Try
ExlApp:=CreateOleObject (' Excel. Application);
WorkBook1:=CreateOleObject ('. Excel Sheet);
Except,
MessageBox (handle, 'call wrong, there is no right to install Microsoft Excel! ', 'prompt', MB_OK + MB_ICONInformation);
The Exit;
end;
ExlApp. Visible:=True;
WorkBook1:=exlApp WorkBooks. Add;//add the workspace
Sheet1:=WorkBook1 WorkSheets [1].//get the first book
For j:=1 to 5 do
The begin
Sheet1. Columns [j]. Journal of numberformatlocal:='@';//set as text format
Sheet1. Cells [1, j] Interior. Color:=$00 d9ffce;//set the cell background to light green
Sheet1. Cells [1, j] Borders. [9] graphics.linestyle:=1;//set the border lines
Sheet1. Columns [j]. Journal of columnwidth:=20;//set the column width
Sheet1. Cells [j] 1, :='cell value;
end;
end;

You this is to create Excel spreadsheet, if can't Excel imported into the Delphi,

Excel operation must be read and write Excel file, this is one way, call Excel program interface, can be hidden interface exlApp. Visible:=False; Read two Excel, write another, then quit, large amount of data you'd better use the database,
WorkBook1. SaveAs (' filename. XLS);
WorkBook1. Close;
ExlApp. Quit;
ExlApp:=the Unassigned;

CodePudding user response:

It is recommended to use XLSReadWriteII4, to EXCEL,
  • Related