怎样设置导出excel文件 单元格的字体,颜色,单元格列的宽度 ?
procedure TDisplayMasterSearch.Button1Click(Sender: TObject);
var iRow,jCol,kRow,mRow,nCol:integer;
eclApp1,WorkBook1:Variant;//声明?OLE Automation ?象
xlsFileName1:string;
begin
if SDSaveExcel.Execute then
xlsFileName1:=SDSaveExcel.FileName
else
exit;
try//?建OLE?象Excel Application与 WorkBook
eclApp1:=CreateOleObject('Excel.Application');
WorkBook1:=CreateOleobject('Excel.Sheet');
except
ShowMessage('You Computer not install Microsoft Excel。');
Exit;
end;
try
ShowMessage('System will be input data proceedure,it maybe takes some time!');
workBook1:=eclApp1.workBooks.Add;
eclapp1.cells(1,1):='GroupNo';
eclapp1.cells(1,2):=DisplaySearchResult.EdCatalogueNo.Text;
eclapp1.cells(2,1):='GroupNo';
eclapp1.cells(2,2):='GroupName';
eclapp1.cells(2,3):='PNC';
eclapp1.cells(2,4):='PNC_Name';
eclapp1.cells(2,5):='Use_Time';
eclapp1.cells(2,6):='ModelName';
eclapp1.cells(2,7):='DESCRIPTION';
eclapp1.cells(2,8):='REP';
eclapp1.cells(2,9):='PartNo';
eclapp1.cells(2,10):='REPPartNo';
eclapp1.cells(2,11):='QTY';
eclapp1.cells(2,12):='RENARES';
eclapp1.cells(2,13):='RESON';
//k :=3;
mRow:= LISTNotUseParts.AllRowCount;
nCol:= LISTNotUseParts.AllColCount;
for kRow:=3 to mRow do
begin
iRow:=1;
for jCol:=1 to nCol do
begin
eclapp1.cells(KRow,jCol) :=LISTNotUseParts.AllCells[iRow-1,jCol-1];
iRow:=iRow+1;
end
end ;
WorkBook1.saveas(xlsFileName1);
WorkBook1.close;
eclApp1.Quit;
Application.MessageBox('Succeed','Attention',MB_OK);
except
ShowMessage('System can not handle the EXCEL file,due to the file opened in wrong software or system errors');
WorkBook1.close;
eclApp1.Quit;
end;
end;
怎样设置 导出的颜色,字体, 列的宽度