Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002899 [JEDI VCL] 00 JVCL Components major always 2005-04-22 05:51 2006-04-05 01:18
Reporter robycar View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00
Summary 0002899: TJvgExportExcel always create file even if SaveToFileName is empty
Description Even 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 Information Filename: \jvcl\run\JvgExportComponents.pas
Class: TJvgExportExcel
Method: Execute
Line Position: 457 - 462
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0007053)
AHUser (developer)
2005-04-23 01:43

Wouldn't it be better to not create the xls-Data if there is no filename?
(0008765)
obones (administrator)
2006-03-30 07:49

This is ready to be comitted in CVS, basically if the filename is empty, it's not saved.
(0008927)
obones (administrator)
2006-04-05 01:18

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker