Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

can't able to read site and warehouse values from excel

(0) ShareShare
ReportReport
Posted on by 454

Hi,

I need to read the Site and Warehouse values from an excel sheet. But it returns an empty value. For example if my site is "1" it returns empty. Here is the code. Help me on this.

site = cells.item(row, 4).value().bStr();
warehouse = cells.item(row, 5).value().bStr();

Regards,

Ram

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,091 on at
    RE: can't able to read site and warehouse values from excel

    Hi Ram Kumar,

    Check if you see "ComExcelDocument_RU" class in AOT. It has a method "variant2Str" which automatically converts a value from Excel type to string.

    site = ComExcelDocument_RU::variant2Str(cells.item(row, 4).value());
    warehouse = ComExcelDocument_RU::variant2Str(cells.item(row, 5).value());

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: can't able to read site and warehouse values from excel

    Hi Ram,

    It's better you change the format of the cell to Text. If any string values are passed later like "1A", "2B" etc, your code will fail.

  • Ram Kumar Profile Picture
    454 on at
    RE: can't able to read site and warehouse values from excel

    Hi Gunjan,

    I have already tried converting integer value to string but this also returns empty value.

    Regards,

    Ram

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: can't able to read site and warehouse values from excel

    Hi Ram,

    You can try one of two options -

    1. Change the value in excel cells to be of type string, rather than integer. This is a better option you can set the excel template in the same way.

    2. You can try to convert the integer value to string and check if that works-

    site        = int2Str(cells.item(row, 4).value().int());
    warehouse   = int2Str(cells.item(row, 5).value().int());

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: can't able to read site and warehouse values from excel

    In AX, site and warehouse ids are strings. Therefore I suggest to handle them as strings in Excel, too. Otherwise you can't use the Excel or your code if your customer has (now or in the future) a site or warehouse where the id has other characters than numbers.

  • Ram Kumar Profile Picture
    454 on at
    RE: can't able to read site and warehouse values from excel

    Hi Gunjan,

    As it is a integer value "1" it cant read ,it only reads a string value. what steps i have to do to read a number value.

    Regards,

    Ram

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: can't able to read site and warehouse values from excel

    Hi Ram,

    Please check if the cells are storing the values as integers instead of string. That might be causing the values to be returned as empty.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,202 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans