I have this simple procedure but I found a problem, while debugging I found Delphi execute ForceDirectories
successfully but jump directly to the end of the procedure without executing the lines after it, why is that ??
var
export_dir: string;
grd_idx: integer;
begin
export_dir := 'c:\app1\export\';
SysUtils.ForceDirectories(export_dir);
showmessage('this line executed then it jump to the end !!');
for grd_idx := 0 to pred(pagecontrol1.ActivePage.ComponentCount) do begin
if (pagecontrol1.ActivePage.components[grd_idx] is Tmycomp) then
ExportToExcel(export_dir+(pagecontrol1.ActivePage.components[grd_idx] as Tmycomp).Name, (pagecontrol1.ActivePage.components[grd_idx] as Tmycomp),
true, true, true, 'xlsx');
end;
end;
I use Delphi XE5, 64bit project
Update:
I noticed also placing break points on the line after showmessage has an x icon for invalid break point instead of the little red icon for valid break point so I traced from the beginning of the procedure and I can confirm starting from the line begin with the For
loop it does not get executed.
ExportToExcel is a built in procedure for exporting data to Excel.
C:\app1
folder does not exist, it must be created first before theexport
folder can be, and a non-admin user can't create folders off the root ofC:
under Windows Vista and above with UAC enabled. You're not checking the return value ofForceDirectories
(or you could simply build with debug DCUs and step into the call to see why it's failing). – Ken Whiteend;
!!! – WilliamExportToExcel
might do, what you are typecasting toTmycomp
or what aTmycomp
is in the first place, and you've not been clear about where the problem is occurring yet. – Ken White