谁有快速从StringGrid导出数据到word和xls的例子!要比较快的!(200分)

  • 主题发起人 主题发起人 chinanbzxx
  • 开始时间 开始时间
C

chinanbzxx

Unregistered / Unconfirmed
GUEST, unregistred user!
我用Tserver控件好慢!!!
 
//以下是一个输出到Word的例子,很难快到哪,你可以取消格式的设置
//因为这里面有表格线的设置、页脚的设置等...
procedure DBGridExportToWord(tempGrid: TObject);
var
WordApplication: TWordApplication;
WordDocument: TWordDocument;
WordFont: TWordFont;
WordParagraphFormat: TWordParagraphFormat;

Template,NewTemplate,ItemIndex:OleVariant;
v1,v2,v3: OleVariant;
coli,colii,rowi,i,j:integer;
ClientDataSet:TClientDataSet;

tReportTitle: string;
tPageWidth,tPageHeight,tTopMargin,tBottomMargin,tLeftMargin,tRightMargin: Double;
tXHLen: Double;
tFX: integer;

procedure setfont;
begin
// WordFont.ConnectTo(WordDocument.Sentences.Get_Last.Font);
// if ChkBoxUnderline.checked then WordFont.Underline := 2;
// if ChkBoxBold.checked then WordFont.Bold := 1;
// if ChkBoxItalic.Checked then WordFont.Italic := 1;
// if ChkBoxEmboss.Checked then WordFont.Emboss := 1;
// if ChkBoxEngrave.checked then WordFont.Engrave := 1;
// if ChkBoxShadow.checked then WordFont.shadow := 1;
// if ChkBoxDoublestrike.checked then WordFont.DoubleStrikeThrough := 1;
// if ChkBoxStrike.checked then WordFont.StrikeThrough := 1;
// WordFont.Size := StrToInt(Size.text);
// if Fonttype.Itemindex >= 0 then
// WordFont.Name := FontType.Items[FontType.Itemindex];
end;
begin
try
WordSetupForm:=TWordSetupForm.Create(nil);
WordSetupForm.ShowModal;
i:=WordSetupForm.ModalResult;
if i=mrOK then
begin
tReportTitle:=WordSetupForm.edtReportTitle.Text;
tPageWidth:=StrToFloat(WordSetupForm.edtPageWidth.Text);
tPageHeight:=StrToFloat(WordSetupForm.edtPageHeight.Text);
tTopMargin:=StrToFloat(WordSetupForm.edtTopMargin.Text);
tBottomMargin:=StrToFloat(WordSetupForm.edtBottomMargin.Text);
tLeftMargin:=StrToFloat(WordSetupForm.edtLeftMargin.Text);
tRightMargin:=StrToFloat(WordSetupForm.edtRightMargin.Text);
tFX:=WordSetupForm.rgFX.ItemIndex;
tXHLen:=StrToFloat(WordSetupForm.edtXHLen.Text);
end;
finally
WordSetupForm.Free;
end;
if i=mrCancel then exit;

try
WordApplication:=TWordApplication.Create(nil);
WordDocument:=TWordDocument.Create(nil);
WordParagraphFormat:=TWordParagraphFormat.Create(nil);
WordFont:=TWordFont.Create(nil);

Template := EmptyParam; //这里若使用模板,则应使用模板的绝对路径名
NewTemplate := True;
ItemIndex := 1;
try
WordApplication.Disconnect;
Wordapplication.Connect;
except
MessageDlg('Word 可能还没有安装!', mtError, [mbOk], 0);
Abort;
end;

Wordapplication.Visible := True;
WordApplication.Caption := tReportTitle;
Template := EmptyParam;
NewTemplate := False;
WordApplication.Documents.Add(Template, NewTemplate);
{Assign WordDocument component}
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
{Turn Spell checking of because it takes a long time if enabled and slows down Winword}
WordApplication.Options.CheckSpellingAsYouType := False;
WordApplication.Options.CheckGrammarAsYouType := False;

WordApplication.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter;
WordApplication.Selection.Font.Bold := wdToggle;
WordApplication.Selection.Font.Size := 22;
WordApplication.Selection.TypeText(tReportTitle);
WordApplication.Selection.TypeParagraph;
WordApplication.Selection.Font.Bold := wdToggle;
WordApplication.Selection.Font.Size := 11;
WordApplication.Selection.ParagraphFormat.Alignment := wdAlignParagraphLeft;

if tFX=0 then WordDocument.PageSetup.Orientation:=wdOrientPortrait
else WordDocument.PageSetup.Orientation:=wdOrientLandscape;
WordDocument.PageSetup.TopMargin:=WordApplication.MillimetersToPoints(tTopMargin);
WordDocument.PageSetup.BottomMargin:=WordApplication.MillimetersToPoints(tBottomMargin);
WordDocument.PageSetup.LeftMargin:=WordApplication.MillimetersToPoints(tLeftMargin);
WordDocument.PageSetup.RightMargin:=WordApplication.MillimetersToPoints(tRightMargin);
WordDocument.PageSetup.PageWidth:=WordApplication.MillimetersToPoints(tPageWidth);
WordDocument.PageSetup.PageHeight:=WordApplication.MillimetersToPoints(tPageHeight);

//设置页脚
if WordDocument.ActiveWindow.View.SplitSpecial<>wdPaneNone then
WordDocument.ActiveWindow.Panes.Item(2).Close;
if (WordDocument.ActiveWindow.ActivePane.View.type_=wdNormalView)
or (WordDocument.ActiveWindow.ActivePane.View.type_=wdOutlineView) then
WordDocument.ActiveWindow.ActivePane.View.type_:=wdPrintPreview;
WordDocument.ActiveWindow.ActivePane.View.SeekView:=wdSeekCurrentPageHeader;
if WordApplication.Selection.HeaderFooter.IsHeader then
WordDocument.ActiveWindow.ActivePane.View.SeekView:= wdSeekCurrentPageFooter
else
WordDocument.ActiveWindow.ActivePane.View.SeekView:= wdSeekCurrentPageHeader;
WordApplication.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
WordApplication.Selection.TypeText('第');
v1:=wdFieldPage;v2:=EmptyParam;v3:=EmptyParam;
WordApplication.Selection.Fields.Add(WordApplication.Selection.Range,v1,v2,v3);
WordApplication.Selection.TypeText('/');
v1:=wdFieldNumPages;v2:=EmptyParam;v3:=EmptyParam;
WordApplication.Selection.Fields.Add(WordApplication.Selection.Range,v1,v2,v3);
WordApplication.Selection.TypeText('页');
v1:=wdLine; v2:=EmptyParam;
WordApplication.Selection.HomeKey(v1,v2);
v1:=wdLine; v2:=wdExtend;
WordApplication.Selection.EndKey(v1,v2);
WordApplication.Selection.Borders.Item(wdBorderTop).LineStyle:=WordApplication.Options.DefaultBorderLineStyle;
WordApplication.Selection.Borders.Item(wdBorderTop).LineWidth:=wdLineWidth050pt;
WordApplication.Selection.Borders.Item(wdBorderTop).ColorIndex:=WordApplication.Options.DefaultBorderColorIndex;

WordApplication.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
v1:=wdLine; v2:=EmptyParam;
WordApplication.Selection.HomeKey(v1,v2);
v1:=wdLine; v2:=wdExtend;
WordApplication.Selection.EndKey(v1,v2);
WordApplication.Selection.Borders.Item(wdBorderTop).LineStyle := wdLineStyleNone;
WordApplication.Selection.Borders.Item(wdBorderLeft).LineStyle := wdLineStyleNone;
WordApplication.Selection.Borders.Item(wdBorderBottom).LineStyle := wdLineStyleNone;
WordApplication.Selection.Borders.Item(wdBorderRight).LineStyle := wdLineStyleNone;
WordDocument.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;

with WordDocument do
begin
j:=0;
for coli:=0 to (tempGrid as TDBGrid).FieldCount-1 do
if not (tempGrid as TDBGrid).DataSource.DataSet.FieldByName((tempGrid as TDBGrid).Columns[coli].FieldName).Visible then Continue
else inc(j);
//创建表格
tables.Add(WordDocument.Words.Last,(tempGrid as TDBGrid).DataSource.DataSet.RecordCount+1,j+1); //考虑加一个序号

//完成表头
tables.Item(1).Cell(1,1).Width :=WordApplication.MillimetersToPoints(tXHLen); //序号
tables.Item(1).Cell(1,1).Range.Text:='序号';
//下面完成其它的表头部分
j:=2;
for coli:=0 to (tempGrid as TDBGrid).FieldCount-1 do
begin
if not (tempGrid as TDBGrid).DataSource.DataSet.FieldByName((tempGrid as TDBGrid).Columns[coli].FieldName).Visible then Continue;
begin
tables.Item(1).Cell(1, j).Width :=WordApplication.MillimetersToPoints(ScreenPixelToMM((tempGrid as TDBGrid).Columns[coli].Width));
tables.Item(1).Cell(1, j).Range.Text:=(tempGrid as TDBGrid).Columns[coli].FieldName;
end;
inc(j);
end;

//表格居中
WordApplication.Selection.Tables.Item(1).Rows.Alignment := wdAlignRowCenter;
//不允许跨页断行
WordApplication.Selection.Tables.Item(1).Rows.AllowBreakAcrossPages := 0;
//将数据填入表格
for rowi:=0 to (tempGrid as TDBGrid).DataSource.DataSet.RecordCount-1 do
begin
tables.Item(1).Cell(rowi+2,1).Range.Set_Text(IntToStr(rowi+1));
tables.Item(1).Cell(rowi+2,1).Width :=WordApplication.MillimetersToPoints(tXHLen); //序号
i:=1;
for coli:=0 to (tempGrid as TDBGrid).FieldCount-1 do
begin
if not (tempGrid as TDBGrid).DataSource.DataSet.FieldByName((tempGrid as TDBGrid).Columns[coli].FieldName).Visible then Continue;
inc(i);
if i>=j then Break;
tables.Item(1).Cell(rowi+2,i).Range.Set_Text((tempGrid as TDBGrid).DataSource.DataSet.FieldByName((tempGrid as TDBGrid).Columns[coli].FieldName).AsString);
tables.Item(1).Cell(rowi+2,i).Width :=WordApplication.MillimetersToPoints(ScreenPixelToMM((tempGrid as TDBGrid).Columns[coli].Width));
end;
(tempGrid as TDBGrid).DataSource.DataSet.Next;
end;
(tempGrid as TDBGrid).DataSource.DataSet.First;
end;
//表头格式设置
v1:=wdStory; v2:=EmptyParam;
WordApplication.Selection.HomeKey(v1,v2);
v1:=wdLine; v2:=1; v3:=EmptyParam;
WordApplication.Selection.MoveDown(v1,v2,v3);

WordApplication.Selection.SelectRow;
WordApplication.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter;
//表格线条设置
WordApplication.Selection.Tables.Item(1).Select;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderLeft).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderLeft).LineWidth := wdLineWidth100pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderLeft).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderRight).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderRight).LineWidth := wdLineWidth100pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderRight).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderTop).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderTop).LineWidth := wdLineWidth100pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderTop).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderBottom).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderBottom).LineWidth := wdLineWidth100pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderBottom).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderHorizontal).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderHorizontal).LineWidth := wdLineWidth050pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderHorizontal).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderVertical).LineStyle := wdLineStyleSingle;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderVertical).LineWidth := wdLineWidth050pt;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderVertical).ColorIndex := wdAuto;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderDiagonalDown).LineStyle := wdLineStyleNone;
WordApplication.Selection.Tables.Item(1).Borders.Item(wdBorderDiagonalUp).LineStyle := wdLineStyleNone;
WordApplication.Selection.Tables.Item(1).Borders.Shadow := False;
v1:=wdStory; v2:=EmptyParam;
WordApplication.Selection.HomeKey(v1,v2);
except
on E: Exception do
begin
ShowMessage(E.Message);
end;
end;
WordApplication.Disconnect;
WordFont.Free;
WordParagraphFormat.Free;
WordDocument.Free;
WordApplication.Free;
end;

至于Excel,可以先输出到一个MEMO中,各值以TAB(#9)分隔,然后整个拷贝到
Excel中,速度会快很多...
 
to yanghaijun, 很快吗?,
>>至于Excel,可以先输出到一个MEMO中,各值以TAB(#9)分隔,然后整个拷贝到
Excel中,速度会快很多...???

整个拷贝咋拷??不懂请赐教
 
本人做的报表导入excel
procedure Tsals002r1Frm.ReportToExcel(wkBook:_Workbook;SheetNumber:integer);
var
Datas : Variant;
tempstr:string;
wkSheet:_Worksheet;
line,col,i,j,z:integer;
aray, total1,total2,total3:real;

begin
i:=0;j:=12;
salsorddet.Open;
tempstr:='select distinct cust_pono ';
tempstr:=tempstr+copy(salsorddet.CommandText,pos('from',salsorddet.CommandText),length(salsorddet.CommandText));
ADODataSet2.close;
ADODataSet2.CommandText:=tempstr;
ADODataSet2.open;
tempstr:='';
col := SalsOrdDet.RecordCount;
line := 33+col+1+ADODataSet2.recordcount+adodataset3.RecordCount;
Datas:= varArrayCreate([1,line,1,10],varVariant);
wksheet:=wkbook.Worksheets.add(emptyparam,emptyparam,emptyparam,emptyparam,SheetNumber)as _worksheet;
wksheet.Cells.HorizontalAlignment:=xlcenter;
wksheet.Name:=SalsOrdHdr.Fieldbyname('sono').asstring;
wksheet.cells.Item[1,1].columnwidth:=3;
wksheet.cells.Item[1,2].columnwidth:=5;
wksheet.cells.Item[1,3].columnwidth:=6;
wksheet.cells.Item[1,4].columnwidth:=11;
wksheet.cells.Item[1,5].columnwidth:=19;
wksheet.cells.Item[1,6].columnwidth:=7;
wksheet.cells.Item[1,7].columnwidth:=6;
wksheet.cells.Item[1,8].columnwidth:=5;
wksheet.cells.Item[1,9].columnwidth:=5;
wksheet.cells.Item[1,10].columnwidth:=6;
Datas[1,5] := 'COE LIMITED';
wksheet.Cells.Item[1,5].font.size:=22;
Datas[2,5] := 'G/F,3C KENT ROAD,KOWLOON TONG';
Datas[3,5] := 'KOWLOON,HONG KONG';
Datas[4,5] := 'TEL:(852)23760133 FAX:(852)23770971';
Datas[5,5] := 'E-MAIL:coeltd@netvigator.com';
wksheet.Range[wksheet.Cells.Item[2,5],wksheet.cells.Item[5,5]].Font.size:=8;
Datas[6,5] := 'PROFORMA INVOICE';
wksheet.Cells.Item[6,5].font.size:=22;
wksheet.Range[wksheet.cells.item[7,1],wksheet.cells.item[10,10]].font.size:=8;
Datas[7,7] := 'Form No: QR002-14-02 Edition:A';
Datas[8,1] := 'Proforma Invoice '+SalsOrdHdr.Fieldbyname('sono').asstring;
if SalsOrdHdr.Fieldbyname('pDate').AsString<>'' then
Datas[8,7] := 'Data : '+ Formatdatetime('mmm,dd,yyyy',SalsOrdHdr.Fieldbyname('pDate').value)
else
Datas[8,7] := 'Data : '+ Formatdatetime('mmm,dd,yyyy',date);
Datas[9,1] := 'Customer: ' + SalsOrdHdr.Fieldbyname('custname').asstring;
wksheet.Range[wksheet.cells.Item[8,1],wksheet.cells.item[9,1]].HorizontalAlignment:=xlleft;
Datas[9,7] := 'Ref.No: '+ SalsOrdHdr.Fieldbyname('ref_no').asstring;
Datas[10,2] := SalsOrdHdr.Fieldbyname('custaddr1').asstring;
Datas[10,7] := 'Order Data: '+ FormatDatetime('mmm,dd,yyyy',SalsOrdHdr.Fieldbyname('ord_date').value);
Datas[11,1] := 'List';
Datas[11,2] := 'Customer '+#13+'Model NO';
Datas[11,3] := 'COE '+#13+'Model No';
Datas[11,4] := 'Delivery'+#13+'Time';
Datas[11,5] := 'Description';
Datas[11,6] := 'Qty'+#13+'(Sets)';
Datas[11,7] := 'Unit Price'+#13+'USD FOB China';
Datas[11,8] := 'Amount'+#13+'(USD)';
Datas[11,9] := 'Unit'+#13+'Volume';
Datas[11,10] := 'Sub'+#13+'(CBM)';
wksheet.Range[wksheet.Cells.Item[11,1],wksheet.cells.item[11,10]].Font.size:=9;
with SalsOrdDet do
begin
DisableControls;
First;

while not Eof do
begin
if tempstr<>SalsOrdDetcust_pono.AsString then
begin
tempstr:=SalsOrdDetcust_pono.AsString;
wksheet.Range[wksheet.Cells.item[12+i,1],wksheet.cells.item[12+i,10]].Borders.item[3].LineStyle:=1;
datas[12+i,5]:='P.O:'+SalsOrdDetcust_pono.AsString;
inc(i);//inc(j);
datas[12+i,5]:=SalsOrdDetPName.AsString;
//j:=length(SalsOrdDetPName.AsString)div 19;
end
else
begin
datas[12+i,5]:=SalsOrdDetPName.AsString;
//j:=length(SalsOrdDetPName.AsString)div 19;
end;
{if j=32 then
wksheet.range[wksheet.cells.item[j,1],wksheet.cells.item[j,10]].Borders.item[4].LineStyle:=1;
}
Datas[12+i,1] := SalsOrdDetseq_calculate.Value;
Datas[12+i,2] :=#13+SalsOrdDetcust_pno.AsString;
Datas[12+i,3] :=#13+SalsOrdDetprod_no.AsString;
if SalsOrdDetprd_del_d.AsString<>'' then
Datas[12+i,4] := Formatdatetime('mmm,dd,yyyy',SalsOrdDetprd_del_d.Value)
else
Datas[12+i,4] := SalsOrdDetprd_del_d.AsString;
//Datas[12+i,5] := SalsOrdDetcust_pono.AsString+#13+' '+SalsOrdDetPName.AsString;
Datas[12+i,6] := SalsOrdDetord_q.asstring;
Datas[12+i,7] := SalsOrdDetunit_price.AsString;
Datas[12+i,8] := SalsOrdDetAmount.AsString;
Datas[12+i,9] := SalsOrdDetunit_volume.AsString;
Datas[12+i,10] := SalsOrdDetSubCbm.AsString;
if ADODataSet3.RecordCount<>0 then
begin
ADODataSet3.first;
z:=i+1;
while not ADODataSet3.Eof do
begin
i:=i+1;
Datas[12+i,3]:=ADODataSet3.fieldbyname('pno').asstring;
Datas[12+i,5]:=ADODataSet3.fieldbyname('pnoremark').asstring;
Datas[12+i,6]:=ADODataSet3.fieldbyname('qty_per').asstring;
adodataset3.next;
end;
end;
if SalsOrdDet.Fieldbyname('ord_q').asstring<>'' then
total1 :=total1+SalsOrdDet.Fieldbyname('ord_q').value;
if SalsOrdDet.Fieldbyname('Amount').asstring<>'' then
Total2 :=Total2+SalsOrdDet.Fieldbyname('Amount').value;
if SalsOrdDet.Fieldbyname('subcbm').asstring<>'' then
Total3 :=Total3+SalsOrdDet.Fieldbyname('Subcbm').value;
i:=i+1;
Next;
end;
EnableControls;
end;
wksheet.Range[wksheet.Cells.item[12,5],wksheet.cells.item[12+i,5]].HorizontalAlignment:=xlleft;
wksheet.Range[wksheet.Cells.item[12,1],wksheet.cells.item[12+i,10]].verticalAlignment:=xltop;
wksheet.range[wksheet.cells.item[11,1],wksheet.cells.item[12+i,10]].WrapText:=true;
SalsOrdInstruction.Open;
Datas[13+i,5] := 'TOTAL';
Datas[13+i,6] := floattostr(total1);
Datas[13+i,8] := floattostr(total2);
Datas[13+i,10] := floattostr(total3);
Datas[14+i,1] := 'Terms and L/C Shipping Instructions:';
Datas[15+i,1] := 'Payment Method '+ SalsOrdInstructionPaytermDesc.AsString;
Datas[16+i,1] := 'Delivery Method '+SalsOrdInstructiondel_mth.AsString;
Datas[17+i,1] := 'Port of Loading '+SalsOrdInstructionport_of_loading.AsString;
Datas[18+i,1] := 'Port of Discharge '+SalsOrdInstructionport_of_discharge.AsString;
Datas[19+i,1] := 'Forwarder '+SalsOrdInstructionforwarder.AsString;
Datas[20+i,1] := 'Packing '+SalsOrdInstructionPacking.AsString;
{CASE SalsOrdInstructionpartial_del.AsString[1] OF
'A':Datas[21+i,1] := 'Partial Delivery '+'ALLOWED' ;
'U':Datas[21+i,1] := 'Partial Delivery '+'UNALLOWED';
ELSE
Datas[21+i,1] := 'Partial Delivery '+'';
END;
CASE SalsOrdInstructiontranshipment.AsString[1] OF
'A':Datas[22+I,1] :='Transhipment '+'ALLOWED';
'U':Datas[22+i,1] :='Transhipment '+'UNALLOWED';
else
Datas[22+i,1] :='Transhipment ';
end;}
if SalsOrdInstructionpartial_del.AsString='A' then
Datas[21+i,1] := 'Partial Delivery '+'ALLOWED'
else if SalsOrdInstructionpartial_del.AsString='U' then
Datas[21+i,1] := 'Partial Delivery '+'UNALLOWED'
else
Datas[21+i,1] := 'Partial Delivery '+'';
if SalsOrdInstructiontranshipment.AsString='A' then
Datas[22+i,1] :='Transhipment '+'ALLOWED'
else if SalsOrdInstructiontranshipment.AsString='U' then
Datas[22+i,1] :='Transhipment '+'UNALLOWED'
else
Datas[22+i,1] :='Transhipment ';

Datas[23+i,1] := 'Destination '+SalsOrdInstructiondestination.AsString;
Datas[24+i,1] := 'Consignee '+SalsOrdInstructionconsignee.AsString;
Datas[25+i,1] := 'Insturance '+SalsOrdInstructioninsturance.AsString;
Datas[26+i,1] := 'Qty & Amount '+SalsOrdInstructionqty_amount.AsString;
Datas[27+i,1] := 'Inspection '+SalsOrdInstructioninspection.AsString;
Datas[28+i,1] := 'Re-Export C/O '+SalsOrdInstructionre_export.AsString;
Datas[29+i,1] := 'Bill of Lading '+SalsOrdInstructionbill_of_lading.AsString;
Datas[30+i,1] := 'L/C Charges '+SalsOrdInstructionlc_charges.AsString;
Datas[31+i,1] := 'Banker '+SalsOrdInstructionbanker_name.AsString;
Datas[32+i,1] := ' '+SalsOrdInstructionbanker_addr.AsString;
Datas[33+i,1] := ' '+SalsOrdInstructionbanker_ac_no.AsString;
Datas[34+i,1] := 'Remarks '+SalsOrdInstructionremarks.AsString;
wksheet.range[wksheet.cells.item[14+i,1],wksheet.cells.item[34+i,1]].font.size:=10;
wksheet.range[wksheet.cells.item[14+i,1],wksheet.cells.item[34+i,1]].HorizontalAlignment:=xlleft;

{ wkSheet:=wkBook.WorkSheets.Add(EmptyParam,
EmptyParam,EmptyParam,EmptyParam,0)
as _WorkSheet; }
with wkSheet do
begin
Range[cells.Item[1,1],cells.Item[line,10]].Value:=Datas;
end;
wksheet.Range[wksheet.cells.item[11,1],wksheet.cells.item[11,10]].borders.linestyle:=1;
wksheet.Range[wksheet.cells.item[11,1],wksheet.cells.item[13+i,10]].Borders.item[1].linestyle:=1;
wksheet.Range[wksheet.cells.item[11,1],wksheet.cells.item[13+i,10]].Borders.item[2].linestyle:=1;
wksheet.Range[wksheet.cells.item[13+i,1],wksheet.cells.item[13+i,10]].Borders.item[4].linestyle:=1;

Datas:=Unassigned;
with wkSheet.Range[wkSheet.Cells.Item[1,1],wkSheet.Cells.Item[6,10]],Font do
begin
Merge(True); //合并单元格
HorizontalAlignment:= xlCenter;
FontStyle:=Bold;
end;
end;
 
后退
顶部