Home » excel » c# – "The specified package is invalid. The main part is missing." In Closed XML

c# – "The specified package is invalid. The main part is missing." In Closed XML

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am using the closed XML for generating the excel template. After filling the data in the generated excel, I am trying to import the excel with data. It returns error “The specified package is invalid. The main part is missing.” . I am using XLSX file.

try
 {
      var   workbook = new XLWorkbook(FILE_PATH);
}
catch (Exception ex)
{   
         throw;
}

It throws error when creating object of XLWOrkbook using the excel template generated.

Please provide a solution,

Thanks in Advance…

How to&Answers:

I got the issue. My file was in the format “Strict Open XML Spreadsheet“. I have changed into “Excel Workbook“. It might be useful for you.