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)

Error when use Open XML to read excel file

(0) ShareShare
ReportReport
Posted on by 575

Dear All,

I am using OXML to read an excel file from server side.

When i enter the data manually in the excel file it is working fine. I can able to ready the excel file.

Link I used:    axbytes.blogspot.fr/.../readwrite-excel-files-from-aos-using.html

But when i copy paste the data from some other place, i am not able to ready the excel file.

When i debugged, i found where it is getting blocked based on a validation

When i try to fetch the value in the cell , 

oxmlspreadSheet = OXMLSpreadsheetDocument_RU::construct(tmpMovTo);
oxmlworkBook = OXMLWorkBook_RU::construct(oxmlspreadSheet);
worksheets = oxmlworkBook.worksheets();

for (worksheetNumber = 1; worksheetNumber <= worksheets.elements(); worksheetNumber++)
{
oxmlworksheet = oxmlworkBook.getWorksheet(worksheetNumber);
sheetName = oxmlworksheet.name();
if (sheetName != #Instruction)  // to skip the instruction sheet and read the second sheet
{
rows = oxmlworksheet.rows();

// rowNum 1 is header so skipped
for ( rowNum = 2; rowNum <= rows.elements(); rowNum++)
{
if (!oxmlworksheet.row(rowNum).cells().empty()) // row is empty or not
{
oxmlrow = oxmlworksheet.row(rowNum);
cells = oxmlrow.cells();
isRecord = false;


for ( colNum = 1; colNum <= cells.elements(); colNum++)
{
//if (!oxmlworksheet.row(rowNum).cell(colNum).cellReferenceByIndex(colNum))
if (!oxmlworksheet.row(rowNum).cell(colNum).getValue())
{
isRecord = true;
}
}

// To store the row values in a container
if(isRecord)
{
for (colNum = 1; colNum <= cells.elements(); colNum++)
{
oxmlcell = oxmlrow.cell(colNum);
sLine += oxmlcell.getValue();

}
}

In the above snippet, when i try to get value of the cell, 

it is getting inside the class, OXMLCELL_RU > getValue() method,  here if the type is string they are calling one more method getSharedStringValue()  ..where error is thrown, saying already the value exist in the cell.

1. Is there any way to fetch value from the cell ?

2. Any examples, or links. I searched in AX using cros reference  but nowhere it is used

3. Or is there any other way to read excel file in server side

Regards,

Arun B S

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If the pasted data cannot be fetched, but the manually entered one can, then it must be formatting-related.

    Maybe you have hidden rows? If you used an AX definition group with an Excel template, the first couple of rows are hidden and specially formatted, which may be the cause why it does not work.

    Also check the formatting of the cell (general/text/custom) as that might be wrong.

    Validate that in what region / locality have you created the data, maybe different regions are causing the problem.

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