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 :
Finance | Project Operations, Human Resources, ...
Answered

Can I upload the '.xls' file to Dynamics 365 using OfficeOpenXml?

(0) ShareShare
ReportReport
Posted on by 314

Hi expert. Please help me.

I can't upload the excel .xls file in the excel upload feature that I made, the error description is like this.
'The file is not an valid Package file. If the file is encrypted, please supply the password in the constructor.'

pastedimage1629103039767v1.png

I've specified the accepted file types in the code ('.xls,.xlsx'), does anyone know the solution? Can I actually upload .xls file to the solution?

pastedimage1629103101809v2.png

* When I debug the code,, I am not getting much information from the call stack when the error occur

pastedimage1629107481455v1.png

In the output section of Debugging, I get error message --> Exception thrown: 'System.IO.InvalidDataException' in EPPlus.dll

pastedimage1629107518017v2.png

I have the same question (0)
  • Verified answer
    WillWU Profile Picture
    22,361 on at

    Hi Michael Antony,

    EPPlus does not work with the XLS format.

    You could use Microsoft.Office.Interop.Excel to convert .xls to .xlsx and then you could use EPPlus library.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi Michael,

    did you already verify what exact line in your code throws the error? 

  • André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at

    Hi Michael,

    Your coding looks like a customization. I would suggest to review the coding and check which exact statement is causing the error.

    When looking at the screenshot, I think you want to import journal lines. Can't you use the standard features, like data import export framework or the Open in Excel functionality?

  • Michael Antony Profile Picture
    314 on at

    Hi Nikolaos, when I try to debug the code,, I am not getting much information whereabout the error might happen (I included a screenshot on my main post). But I get error --> Exception thrown: 'System.IO.InvalidDataException' in EPPlus.dll

  • Michael Antony Profile Picture
    314 on at

    Hi Andre, when I try to debug the code,, I am not getting much information whereabout the exact code that the error happen (I included a screenshot on my main post). But I get error --> Exception thrown: 'System.IO.InvalidDataException' in EPPlus.dll

    What I need is to insert multiple Journal Header with each having Journal Lines, that's why I create a customized feature because such functionality is not supported in standard DIEF, isn't that correct Andre?

  • Michael Antony Profile Picture
    314 on at

    Hi Will Wu,

    Could you please give me a reference or example code to start working with Microsoft.Office.Interop.Excel to convert .xls?

  • WillWU Profile Picture
    22,361 on at

    Hi Michael,

    Please check:

    stackoverflow.com/.../18904633

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans