代码如下: with Dbgridname.DataSource.DataSet do
begin
pBookMark := GetBook;
DisableControls;
for I:=0 to dbgridname.Columns.Count-1 do
begin
if dbgridname.Columns[I].Visible=False then
Continue;
Sheet.Cells[J,I+1] := dbgridname.Columns[I].Title.Caption;
end;
Inc(J);
First;
while not Eof do begin
for I:=0 to dbgridname.Columns.Count-1 do begin
if dbgridname.Columns[I].Visible=False then
Continue;
Sheet.Cells[J,I+1]:=trim(dbgridname.DataSource.DataSet.Fieldbyname(dbgridname.Columns[i].FieldName).asstring);//asstring 不能转换为文本的吗?
//改变颜色,字体颜色和底色
Sheet.Cells[J,I+1].font.ColorIndex:=3;
Sheet.Cells[J,I+1].Select;
sheet.Cells[J,I+1].Interior.ColorIndex:=50
end;
Inc(J);
Next;
end;
GotoBook(pBookMark);
FreeBook(pBookMark);
EnableControls;
end;
XLApp.activeworkbook.saveas(StrSaveFile);
Application.ProcessMessages;
XLApp.Application.Quit;
end;
begin
pBookMark := GetBook;
DisableControls;
for I:=0 to dbgridname.Columns.Count-1 do
begin
if dbgridname.Columns[I].Visible=False then
Continue;
Sheet.Cells[J,I+1] := dbgridname.Columns[I].Title.Caption;
end;
Inc(J);
First;
while not Eof do begin
for I:=0 to dbgridname.Columns.Count-1 do begin
if dbgridname.Columns[I].Visible=False then
Continue;
Sheet.Cells[J,I+1]:=trim(dbgridname.DataSource.DataSet.Fieldbyname(dbgridname.Columns[i].FieldName).asstring);//asstring 不能转换为文本的吗?
//改变颜色,字体颜色和底色
Sheet.Cells[J,I+1].font.ColorIndex:=3;
Sheet.Cells[J,I+1].Select;
sheet.Cells[J,I+1].Interior.ColorIndex:=50
end;
Inc(J);
Next;
end;
GotoBook(pBookMark);
FreeBook(pBookMark);
EnableControls;
end;
XLApp.activeworkbook.saveas(StrSaveFile);
Application.ProcessMessages;
XLApp.Application.Quit;
end;
解决方案 »
- 关于线程的一点疑惑
- 刚从广州回来,想在长沙找个工作,面试了几个单位都说我工资开高了,到底应该要多少工资?
- 如何选择超过四个小数点的数据类型?
- 在C/S下,这个功能怎样实现??
- 请问如何捕捉到系统文件移动、删除、改名等操作?
- 使用fastreport时,一个你都会遇到的问题!!
- 如何将循环中的变量实时送到另外一个窗口的控件中
- ClassName为TStringGrid的控件,我想用SendMessage(hwnd, WM_GETTEXT,....)得到它内部单元格的值
- 关于Delphi开发Web程序的报表打印问题(又得出放分了)
- 如何给图片随意加文字(vc,deiph)
- VAB转Delphi代码
- 为什么在动态创建ADOConnection会出错??
Sheet1.Range['b1','b100'].NumberFormat:='@';
Sheet.Cells[J,I+1]:=''''+trim(dbgridname.DataSource.DataSet.Fieldbyname(dbgridname.Columns[i].FieldName).asstring);