View Issue Details

IDProjectCategoryView StatusLast Update
0002899JEDI VCL00 JVCL Componentspublic2006-04-05 01:18
ReporterrobycarAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.30 
Summary0002899: TJvgExportExcel always create file even if SaveToFileName is empty
DescriptionEven if TJvgExportExcel.SaveToFilename property is empty a file named ".xls" will be always created.

Original Code:

    if ExtractFileExt(FSaveToFileName) = '' then
      FSaveToFileName := ChangeFileExt(FSaveToFileName, '.xls');
    DeleteFileEx(FSaveToFileName);

    if FSaveToFileName <> '' then
      XL.WorkBooks[XL.WorkBooks.Count].SaveAs(FSaveToFileName);

Simple Solution

    if FSaveToFileName <> '' then
    begin
      if ExtractFileExt(FSaveToFileName) = '' then
        FSaveToFileName := ChangeFileExt(FSaveToFileName, '.xls');
      DeleteFileEx(FSaveToFileName);
      XL.WorkBooks[XL.WorkBooks.Count].SaveAs(FSaveToFileName);
    end;

A Better solution may ensure that FSaveToFileName is a valid file name. e.g. a file whose name withouth extension is not an empty string:
    if ExtractFileName(FSaveToFileName) <> '' then
    begin
      if ExtractFileExt(FSaveToFileName) = '' then
        FSaveToFileName := ChangeFileExt(FSaveToFileName, '.xls');
      DeleteFileEx(FSaveToFileName);
      XL.WorkBooks[XL.WorkBooks.Count].SaveAs(FSaveToFileName);
    end;
Additional InformationFilename: \jvcl\run\JvgExportComponents.pas
Class: TJvgExportExcel
Method: Execute
Line Position: 457 - 462
TagsNo tags attached.

Activities

AHUser

2005-04-23 01:43

developer   ~0007053

Wouldn't it be better to not create the xls-Data if there is no filename?

obones

2006-03-30 07:49

administrator   ~0008765

This is ready to be comitted in CVS, basically if the filename is empty, it's not saved.

obones

2006-04-05 01:18

administrator   ~0008927

This is now in CVS

Issue History

Date Modified Username Field Change
2005-04-22 05:51 robycar New Issue
2005-04-23 01:43 AHUser Note Added: 0007053
2006-03-30 07:49 obones Note Added: 0008765
2006-03-30 07:49 obones Status new => confirmed
2006-04-05 01:18 obones Status confirmed => resolved
2006-04-05 01:18 obones Resolution open => fixed
2006-04-05 01:18 obones Assigned To => obones
2006-04-05 01:18 obones Note Added: 0008927