我用DBGridEh导出excel中,字段长度为1000,但是某些值导不出,字段长度350就到不出,有无好解决方法
if sdlgExport.Execute then
SaveDBGridEhToExportFile(TDBGridEhExportAsXLS,DBGridEh1, sdlgExport.FileName, True);
帮帮忙!!!!!!!!!!!!
if sdlgExport.Execute then
SaveDBGridEhToExportFile(TDBGridEhExportAsXLS,DBGridEh1, sdlgExport.FileName, True);
帮帮忙!!!!!!!!!!!!
解决方案 »
- 送500分 ,正向冗余校验 (LRC)的问题,请熟悉RS232或者RS485通信的老大帮忙。
- 如何将bmp文件转成ico文件
- 注册表
- 决定放99分给片三叫他差一分成不了两星哇哈哈哈
- 问一个比较简单的select语句?
- delphi中mscomm按一定的数据协议控制LED看板怎样实现!
- 请问哪儿有报表控件和自动生成帮助的控件下载,谢谢!
- DBGridEH问题
- 用Foxpro或Access实现数据库的话,编程时一定要安装Foxpro/Access吗?如果程序完成后作成安装程序给用户,用户也需要安装Foxpro/Access吗?
- :sybase中生成的SQL语句在MS SQL中执行,须不须要转化??????
- 各路高手,请帮下在下,如何实现这样的效果呀
- dbgrid中post问题
看看控件事件吧
或者用别的方法导出
var i: Integer;
ColList: TColumnsEhList;
ASelectionType: TDBGridEhSelectionType;
begin
Stream := AStream;
try
with DBGridEh do
begin
if IsExportAll then ASelectionType := gstAll else ASelectionType := Selection.SelectionType;
if ASelectionType = gstNon then Exit;
with DataSource.Dataset do
begin
DisableControls;
SaveBook;
try
case ASelectionType of
gstRecordBooks:
begin
ExpCols := VisibleColumns;
// FooterValues := AllocMem(SizeOf(Currency) * ExpCols.Count * DBGridEh.FooterRowCount);
SetLength(FooterValues, ExpCols.Count * DBGridEh.FooterRowCount);
WritePrefix;
if dgTitles in Options then WriteTitle(VisibleColumns);
for i := 0 to Selection.Rows.Count - 1 do
begin
Book := Selection.Rows[I];
CalcFooterValues;
WriteRecord(VisibleColumns);
end;
for i := 0 to FooterRowCount - 1 do WriteFooter(VisibleColumns, i);
end;
gstRectangle:
begin
ColList := TColumnsEhList.Create;
try
for i := Selection.Rect.LeftCol to Selection.Rect.RightCol do
if Columns[i].Visible then
ColList.Add(Columns[i]);
ExpCols := ColList;
// FooterValues := AllocMem(SizeOf(Currency) * ExpCols.Count * DBGridEh.FooterRowCount);
SetLength(FooterValues, ExpCols.Count * DBGridEh.FooterRowCount);
WritePrefix;
if dgTitles in Options then WriteTitle(ColList);
Book := Selection.Rect.TopRow;
while True do
begin
WriteRecord(ColList);
CalcFooterValues;
// if CompareBooks(Pointer(Selection.Rect.BottomRow), Pointer(Book)) = 0 then Break;
if DataSetCompareBooks(DBGridEh.DataSource.Dataset, Selection.Rect.BottomRow, Book) = 0 then Break;
Next;
if Eof then Break;
end;
for i := 0 to FooterRowCount - 1 do WriteFooter(ColList, i);
finally
ColList.Free;
end;
end;
gstColumns:
begin
ExpCols := Selection.Columns;
// FooterValues := AllocMem(SizeOf(Currency) * ExpCols.Count * DBGridEh.FooterRowCount);
SetLength(FooterValues, ExpCols.Count * DBGridEh.FooterRowCount);
WritePrefix;
if dgTitles in Options then WriteTitle(Selection.Columns);
First;
while Eof = False do
begin
WriteRecord(Selection.Columns);
CalcFooterValues;
Next;
end;
for i := 0 to FooterRowCount - 1 do WriteFooter(Selection.Columns, i);
end;
gstAll:
begin
ExpCols := VisibleColumns;
// FooterValues := AllocMem(SizeOf(Currency) * ExpCols.Count * DBGridEh.FooterRowCount);
SetLength(FooterValues, ExpCols.Count * DBGridEh.FooterRowCount);
WritePrefix;
if dgTitles in Options then WriteTitle(VisibleColumns);
First;
while Eof = False do
begin
WriteRecord(VisibleColumns);
CalcFooterValues;
Next;
end;
for i := 0 to FooterRowCount - 1 do WriteFooter(VisibleColumns, i);
end;
end;
finally
RestoreBook;
EnableControls;
end;
end;
end;
WriteSuffix;
finally
// FreeMem(FooterValues);
end;
end;
跟踪调试 看看是在什么溢出
Excelid: OleVariant; //导出到excel,第一个uses要加上ComObj
begin
try
Excelid:=CreateOLEObject('Excel.Application');
except
Application.MessageBox('Excel没有安装!', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
try
Excelid.Visible:= True;
Excelid.WorkBooks.Add;
Excelid.WorkSheets[1].Cells[1,1].Value := '商品名称';
Excelid.WorkSheets[1].Cells[1,2].Value := '单位';
h:=2;
data.Qpublic1.First;
while not data.Qpublic1.Eof do
begin
Excelid.WorkSheets[1].Cells[h,1].Value := data.Qpublic1.FieldByName('X').AsString;
Excelid.WorkSheets[1].Cells[h,2].Value := data.Qpublic1.FieldByName('Y).AsString;
data.Qpublic1.Next;
h:=h+1;
end;
Excelid.Quit;
except
Application.MessageBox('导入数据出错!请检查文件的格式是否正确!', '提示信息', MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
end;
end;看看这种行吗?