excel(10分)

  • 主题发起人 主题发起人 mjf_jigh
  • 开始时间 开始时间
M

mjf_jigh

Unregistered / Unconfirmed
GUEST, unregistred user!
本人用ACCESS数据库和BDE开发了一段代码,并且将选者出来的数据导入到EXCEL 表中,
可是在ACCESS中年级字段中有象001这样的字符,可到了EXCEL中变成了1,我想问一下如何
在程序中更改EXCEL中属性列的属性?
 
问题解决了么,我也有这个问题,如果搞定了,麻烦给俺也通通气。谢
sn_ming@163.com
 
判断首位是0的话就在前面加上一个'
比如001直接在Excel里面写作 '001
这样就可以了
 
老猫的方法可行,已通过。
 
说具体点
 
可以尝试以下语句,将某列的格式设定为文本格式:

ExcelApplication1.ActiveSheet.Columns[1].NumberFormatLocal := "@";
 
procedure Texportexcel.BitBtn1Click(Sender: TObject);
var
row,column,Tempcolumn:integer;
i,j:integer;
begin
inherited;
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApplication1.Disconnect;
Try
{ Excelapplication1.Connect;
ExcelWorkbook1.Connect;
ExcelWorksheet1.Connect;}
Except
Messagedlg('沒有安裝Excel!'+char(13)+
'請重新安裝!',mtinformation,[mbok],0);
Abort;
end;
Excelapplication1.Visible[0]:=true;
Excelapplication1.Caption:= '數據導出窗口程序';
Excelapplication1.Workbooks.Add(varNull,0);
Excelworkbook1.ConnectTo(excelapplication1.workbooks[excelapplication1.workbooks.count]);
Excelworksheet1.ConnectTo(excelworkbook1.worksheets[1] as _worksheet);
Excelworksheet1.Cells.Item[1,3]:='TOOLING PROGRESS REPORT';
Excelworksheet1.Cells.Item[2,1]:='Customer:';
Excelworksheet1.Cells.Item[2,3]:=dm.xvalue.fieldbyname('customer').value;
Excelworksheet1.Cells.Item[3,1]:='Cust.No:';
Excelworksheet1.Cells.item[3,3]:=dm.xvalue.fieldbyname('custph').value;
Excelworksheet1.Cells.Item[4,1]:='Description';
Excelworksheet1.Cells.Item[4,3]:=dm.xvalue.fieldbyname('custcpname').value;
Excelworksheet1.Cells.item[5,1]:='RSC No.:';
Excelworksheet1.Cells.Item[5,3]:=dm.xvalue.fieldbyname('rscno').value;
Excelworksheet1.Cells.item[6,1]:='Chinese Description:';
Excelworksheet1.Cells.Item[6,3]:=dm.xvalue.fieldbyname('rsccpname').value;
Excelworksheet1.Cells.Item[7,1]:='Start date:';
Excelworksheet1.Cells.Item[7,3]:=dm.xvalue.fieldbyname('rjdate').value;
Excelworksheet1.Cells.item[8,1]:='Estimate Finish Date:';
Excelworksheet1.Cells.Item[8,3]:=dm.xvalue.fieldbyname('rjoverdate').value;
Excelworksheet1.Cells.item[9,1]:='Actual Finish Date';
Excelworksheet1.cells.Item[10,1]:='total days:';
Excelworksheet1.Cells.Item[10,3]:=dm.xvalue.fieldbyname('totaldays').value;
Excelworksheet1.cells.item[11,1]:='Progress Per Day:';
Excelworksheet1.Cells.Item[11,3]:=dm.xvalue.fieldbyname('perday').value+'%';
Excelworksheet1.Cells.Item[12,1]:='Date/Time';
EXCELWORKSHEET1.Cells.Item[12,2]:='PLAN(%)';
Excelworksheet1.Cells.Item[12,3]:='ACTUAL(%)';
Excelworksheet1.Cells.Item[12,4]:='GAP';
Excelworksheet1.Cells.Item[12,5]:='WORKING DAYS';
row:=13;
dm.evalue.First ;
While Not(dm.evalue.Eof) do
begin
TempColumn := 0 ;
for Column:=1 to DbGrid1.FieldCount do
begin
if DbGrid1.Columns.Items[Column-1].Visible = True Then
begin
TempColumn := TempColumn + 1 ;
ExcelWorksheet1.Cells.Item[row,TempColumn] := DbGrid1.Fields[Column-1].AsString;
end;
end;
dm.evalue.Next;
row:=row + 1;
end;
end;
給分,快點!
 
多人接受答案了。
 
后退
顶部