数据导出到Execel中,总是第一列为空不知道为何?
代码:
nCurrRow := 1;
if SePTitle <> '' then begin
Sheet.Cells[1,1] := SePTitle;
sheet.range[sheet.cells[2, 1],sheet.cells[2,nCols]].Select; //选择该列
//Excelid.selection.HorizontalAlignment := $FFFFEFF4; //居中
Excelid.selection.MergeCells := True;
//表体(包括表头)
nCurrRow := 2;
end;
ProgressBar1.Position :=0;
ProgressBar1.Max :=mGrid.RowCount;
for i:=0 to mGrid.RowCount-1 do begin
ProgressBar1.Position :=ProgressBar1.Position +1;
nCurrCol := 1;
for j:=0 to mGrid.ColCount-1 do begin
if mGrid.ColWidths[j]>0 then begin
if (j=2)or (j=4) or( j=5) then begin
Sheet.Cells[nCurrRow,nCurrCol].NumberFormatLocal := '@';
Sheet.Cells[nCurrRow,nCurrCol] := mGrid.Cells[j,i];
end else begin
Sheet.Cells[nCurrRow,nCurrCol] := mGrid.Cells[j,i];
end;
nCurrCol := nCurrCol + 1;
end;
end;
nCurrRow := nCurrRow + 1;
end;
请大家多多指教。
代码:
nCurrRow := 1;
if SePTitle <> '' then begin
Sheet.Cells[1,1] := SePTitle;
sheet.range[sheet.cells[2, 1],sheet.cells[2,nCols]].Select; //选择该列
//Excelid.selection.HorizontalAlignment := $FFFFEFF4; //居中
Excelid.selection.MergeCells := True;
//表体(包括表头)
nCurrRow := 2;
end;
ProgressBar1.Position :=0;
ProgressBar1.Max :=mGrid.RowCount;
for i:=0 to mGrid.RowCount-1 do begin
ProgressBar1.Position :=ProgressBar1.Position +1;
nCurrCol := 1;
for j:=0 to mGrid.ColCount-1 do begin
if mGrid.ColWidths[j]>0 then begin
if (j=2)or (j=4) or( j=5) then begin
Sheet.Cells[nCurrRow,nCurrCol].NumberFormatLocal := '@';
Sheet.Cells[nCurrRow,nCurrCol] := mGrid.Cells[j,i];
end else begin
Sheet.Cells[nCurrRow,nCurrCol] := mGrid.Cells[j,i];
end;
nCurrCol := nCurrCol + 1;
end;
end;
nCurrRow := nCurrRow + 1;
end;
请大家多多指教。
http://blog.csdn.net/suiyunonghen/archive/2009/05/21/4207564.aspx