web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

excelCOM.SpecialCells(11); the variable for the last row of a excel sheet dont reset

(0) ShareShare
ReportReport
Posted on by

Hey,

    worksheet                       = workbooks.item(1).worksheets().itemFromNum(1);
    cells                                 = worksheet.cells();
    excelCOM                        = cells.comObject();
    excelCOM                        = excelCOM.SpecialCells(11);
    lastRow                           = excelCOM.Row();


with this code i want get the last row of my excel sheet.
This works fine but if i change the rows of the excel sheet, the varibale (lastRow)

dont geht the new amount of the rows.

I reset the lastRow at the end of my code with lastRow = 0;

Example:

I had a sheet with 700 rows and change it to 39 but the lastRow stand still on 700 i dont know why but if i import a new Excel sheet they change to the new amout of rows.

And if i create the file new with the 39 rows they get the amout too of the 39 rows.

Thanks for every help

Felix

*This post is locked for comments

I have the same question (0)
  • Verified answer
    DavidGunawan Profile Picture
    1,381 on at

    Hi Felix,

    Might be you can use below method to find the last row.

    Row findLastRow(SysExcelWorkSheet _workSheet)

    {

       #define.Star('*')

       #define.Space(' ')

       SysExcelRange   range;

       Row             numOfRows = 0;

       ;

       range = _workSheet.cells().range(#ExcelTotalRange);

       try

       {

           // Finds the row where the first contents is found.

           range = range.find(#Star, null, #xlFormulas, #xlWhole, #xlByRows, #xlPrevious);

       }

       catch (Exception::Error)

       {

           error("@SYS59926");

           excelApplication.quit();

       }

       if (range)

       {

           numOfRows = range.row();

       }

       return numOfRows;

    }

  • Community Member Profile Picture
    on at

    hey DavidGunawan,

    i can find the last row, and my code works fine but the one variable dont reset, i think they know where what stand in the table.

    The stand on 700 because this was the highest row.

    But after the change of the rows they dont search again for the new row amout and stand still on 700.

    Thanks

  • DavidGunawan Profile Picture
    1,381 on at

    Hi Felix,

    Have you tried the sample code? Was it works ?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans