Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

The class 'SysExcelWorkbooks' does not contain the method itemFromNum

(0) ShareShare
ReportReport
Posted on by 462

Good day folks,

I am writing an Excel import class in Ax 2012 R2 and I'm having an issue with SysExcelWorkbooks trying to access itemFromNum() with the below error.

0066.pastedimage1669574426959v1.png

Is there anything with the code I have written, which is below?

    SysExcelApplication     _application;
    SysExcelWorkbooks       _workbooks;
    SysExcelWorkbook        _workbook;
    SysExcelWorksheets      _worksheets;
    SysExcelWorksheet       _worksheet;
    SysExcelCells           _cells;
	
	//table names and EDT declaration omitted here
   
    COMVariantType          _type;
    int rowCount=1;
   
    container      _conFilter = ["(.xls)" ,"*.xlsx"];
  
    FileName        _fileName;
    Dialog          _dialog;
    DialogField     _dialogfield;
    _dialog = new Dialog();
    _dialog.caption("Pick a file");
    _dialogfield = _dialog.addField(extendedTypeStr(FilenameOpen));
    _dialog.filenameLookupFilter(conFilter);
    _dialog.run();

    if(_dialog.closedOk())
    {
        _fileName = _dialogfield.value();
        _application = SysExcelApplication::construct();

        _workbooks = _application.workbooks();
       
        try
        {
            _workbooks.open(_fileName);
        }
        catch (Exception::Error)
        {
            throw error("Could not open the excel upload file");
        }
        _workbook    = _workbooks.item(1);
        _worksheets  = _workbook.worksheets();
        _worksheet   = _worksheets.itemFromNum(1);
		
		
		//more code here
		
		}

Thank you in advance for your help!

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,735 Super User 2024 Season 2 on at
    RE: The class 'SysExcelWorkbooks' does not contain the method itemFromNum

    Hi Huggins,

    I was trying to start and update my (old) AX 2012 demo environment to check what might be missing. My license expired and I have to update it to be able to access the AOT. In the meantime, you found your answer.

    Thanks for providing your own answer. I have marked your question as verified, so the status of the question will be answered.

  • Verified answer
    Huggins Mafigu Profile Picture
    Huggins Mafigu 462 on at
    RE: The class 'SysExcelWorkbooks' does not contain the method itemFromNum

    I got the problem, instead of doing 

    _worksheet   = _worksheets.itemFromNum(1);
    , I wrote it as 
    _worksheet   = _workbook.itemFromNum(1);
    .

    All along I was overlooking this part.

    Thank you for your help!

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,816 Super User 2024 Season 1 on at
    RE: The class 'SysExcelWorkbooks' does not contain the method itemFromNum

    Hi Huggins,

    Error shown in the screenshot and your code is contradictory. Error says itemFromNum method in SysExcelWorkbook doesn't exist, but in your code there is such any.

    Try to recompile the code - If it doesn't help just close and reopen the ax and try compiling again.

    Thanks,

    Girish S.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,735 Super User 2024 Season 2 on at
    RE: The class 'SysExcelWorkbooks' does not contain the method itemFromNum

    Moved the question from the Dynamics 365 Finance to the Dynamics AX forum.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans