SysDataExcelCOM save Method

Hello Guys,

in administration panel under the periodic there is a Excel Template wizard.Its inserting the table’s datas to an excel file,but It does not work it.its gives me error about save method of SysDataExcelCOM.

when I debug it its going to catch always after the this.save() line,when I check the method I could not see any weird things,I dont know why its going to catch always.

this is the biuldwork method of this class:


    SysExcelWorkbook    sysExcelWorkbook;
    SysExcelWorksheet   sysExcelWorksheet;
    boolean             fileExists;
    Set                 skipFilenames;
    ;

    if (!Global::hasSecuritykeyAccess(securitykeynum(AdminPeriodic), AccessType::View))
    {
        throw error(strfmt("@SYS97038", securitykeystr(AdminPeriodic), enum2str(AccessType::View)));
    }

    skipFilenames = new Set(Types::String);

    select count(RecId) from tmpExcelColumn;

    progress = new SysOperationProgress();
    progress.setCaption("@SYS97389");
    progress.setTotal(tmpExcelColumn.RecId);

    try
    {
        this.checkSheetNames();

        while select forupdate tmpExcelWorkbook
            order by Id
        {
            if (!tmpExcelWorkbook.Filename)
            {
                throw error("@SYS18624");
            }

            fileExists = WinAPI::fileExists(tmpExcelWorkbook.Filename);

            switch (fileExists)
            {
                case true :
                    switch (fileExistsRule)
                    {
                        case SysDataExcelFileExistsRule::Abort :
                            throw error(strfmt("@SYS18625", tmpExcelWorkbook.Filename));

                        case SysDataExcelFileExistsRule::SkipFile :
                            warning(strfmt("@SYS18625", tmpExcelWorkbook.Filename));
                            warning(strfmt("@SYS97313", tmpExcelWorkbook.Filename));
                            skipFilenames.add(tmpExcelWorkbook.Filename);
                            continue;

                        case SysDataExcelFileExistsRule::CreateFile :
                            warning(strfmt("@SYS18625", tmpExcelWorkbook.Filename));
                            tmpExcelWorkbook.Filename = this.newFilename(tmpExcelWorkbook.Filename);
                            tmpExcelWorkbook.update();
                            info(strfmt("@SYS97314", tmpExcelWorkbook.Filename));
                            break;

                        case SysDataExcelFileExistsRule::ModifyFile :
                            sysExcelWorkbook = this.createWorkBook(tmpExcelWorkbook.Filename, true);
                            break;
                    }

                    if (fileExistsRule != SysDataExcelFileExistsRule::OverwriteFile &&
                        fileExistsRule != SysDataExcelFileExistsRule::CreateFile)
                    {
                        break;
                    }

                default :
                    this.checkFileAccess(tmpExcelWorkbook.Filename);
                    sysExcelWorkbook = this.createWorkBook(tmpExcelWorkbook.Filename);
                    break;
            }

            this.initWorkbook(sysExcelWorkbook);

            this.addWorkbookOptions();

            this.createStyles(sysExcelWorkbook);
            this.createDefinitionWorksheet(sysExcelWorkbook, tmpExcelWorkbook);

            while select tmpExcelWorksheet
                index hint WorkbookIdx
                where tmpExcelWorksheet.WorkbookId == tmpExcelWorkbook.Id
            {
                sysExcelWorksheet = this.createDataWorksheet(sysExcelWorkbook, tmpExcelWorksheet);
            }


            this.save();
        }
    }
    catch
    {
        excel.displayAlerts(false);
        excel.quit();
        excel.displayAlerts(true);

        throw error("@SYS97315");
    }

    if (sysExcelWorkbook)
    {
        this.save();
    }

    progress = null;

    return skipFilenames;

and this is the save method:

public void save()
{
    ;
    excel.displayAlerts(false);
    excel.save();
    excel.displayAlerts(true);
}

after excel.save line its going to catch and throws error.

What does the error say?

Save method of application class failed. 0x800a03EC

Which branch of your code is used when it fails? Please remove all code not related to the error; it will help you with debugging.

while select tmpexcelworksheet

index hint workbookIdx

where tmpexcelworksheet.workbookId == tmpexcelworkbook.Id

{

sysExcelworksheer = this.createdataworksheet(sysexcelworkbook,tmpexcelworksheet);

}

this.save(); // after save method it goes to catch,and then throws error.

catch

{

excel.displayAlerts(false);

excel.quit();

excel.displayAlerts(true);

}

if(sysexcelworkbook)

this.save();

}

Is the while select really necessary to reproduce the problem? Will the disappear if you call createdataworksheet() only once? If not, it’s another piece of code to remove.
Also, you didn’t tell us what code you have in createdataworksheet(), so we can’t comment on it.
Consider merging your code to a single method demonstrating the problem (and nothing else).