Hello,
I open a xlsx-File as "my own template" with flexcel actual version, see listing 1 below.
Then I create an Excel-File using this template, see listing 2-
In the last line I obtain an "access violation". How ist should be correctly?
Sincerely Peter
listing 1
()
function TCoordinatesXLSForm.ReadTemplate: boolean;
()
var
templateFileName : string;
fname : string;
begin
templateFileName := 'NNextNeighbors.Template.xlsx';
RedFIO.GetFirstPathFromRedirectionFile(path, templateFileName);
ok := RedFIO.UseFirstDirectoryFromPath(path, templateFileName, fname);
if(XLSNeighbors=Nil) then
begin
XLSNeighbors := TXlsFile.Create(true);
end;
XLSNeighbors.Open(fName);
XLSNeighbors.ActiveSheet := 1;
//XLSNeighbors.Save(fName);
ReadTemplate := True;
EXIT;
end;
listing 2:
()
function TCoordinatesXLSForm.WriteNeighborsExcel(fileName : string): boolean;
()
var
i : Cardinal;
j : Cardinal;
completeFilePath : string;
begin
if(XLSNeighbors=Nil) then
begin
XLSNeighbors := TXlsFile.Create(true);
end;
GetPathFromRedirectionFile(completeFilePath, fileName);
completeFilePath := completeFilePath + ''+fileName;
XLSNeighbors.Save(completeFilePath);