1、在主界面模块上放置openoffice控件,并改名为MO1
2、添加如下过程
procedure TForm1.PrintAllMenuItem(AMainMenu: TMainMenu; XRow: Integer);
function FindChindMenuItem(AMeunItem: TMenuItem; YCol: Integer): Boolean;
var
i: Integer;
begin
MO1.SetCellString(Xrow,YCol,AMeunItem.Caption);
if AMeunItem.Count = 0 then
begin
Inc(XRow);
Exit;
end;
for i := 0 to AMeunItem.Count-1 do
begin
if AMeunItem.Items[i].Visible then
FindChindMenuItem(AMeunItem.Items[i],YCol+1);
end;
end;
begin
MO1.ExportType := theOpenOffice;
MO1.NewDoc();
FindChindMenuItem(AMainMenu.Items,1);
MO1.Disconnect;
ShowMessage('ComPlete!');
end;
function FindChindMenuItem(AMeunItem: TMenuItem; YCol: Integer): Boolean;
var
i: Integer;
begin
MO1.SetCellString(Xrow,YCol,AMeunItem.Caption);
if AMeunItem.Count = 0 then
begin
Inc(XRow);
Exit;
end;
for i := 0 to AMeunItem.Count-1 do
begin
if AMeunItem.Items[i].Visible then
FindChindMenuItem(AMeunItem.Items[i],YCol+1);
end;
end;
begin
MO1.ExportType := theOpenOffice;
MO1.NewDoc();
FindChindMenuItem(AMainMenu.Items,1);
MO1.Disconnect;
ShowMessage('ComPlete!');
end;
3、在主界面模块放置一个Button控件,Button.Click事件代码为
procedure TForm1.Button1Click(Sender: TObject);
begin
PrintAllMenuItem(MainMenu1,1);
end;
begin
PrintAllMenuItem(MainMenu1,1);
end;
运行系统,点击Button即为转出系统菜单项的Excel档。