Hi @Mike Gerbi , Welcome to Microsoft Q&A,
Based on the code you provided, the problem may be in your CreateExcel
method. I noticed that you are having issues creating the worksheetPart
object, specifically you are encountering an error on the following line of code:
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
As you can see from the error message, the error is related to type parameter constraints. This indicates that there is a problem when you are trying to add a new worksheet section.
In order to solve this problem, you can try to use different methods to create WorksheetPart
, for example, you can try to use AddNewPart
method overloaded form, or directly instantiate WorksheetPart
** kind.
Here's an alternative you can try:
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>(
Alternatively, you can instantiate WorksheetPart
directly:
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet =
Both methods should effectively create a new WorksheetPart
object without causing type parameter constraint errors. Please try one of these methods and check if it resolves the issue you are experiencing.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.