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;
}
```
Please provide a solution.
Comments: Solved the issue! See post above for details, but to simplify, this code didn't work when I tried to edit the file it created: ``` var wb = new XLWorkbook(); wb.Worksheets.Add(dataTable); wb.SaveAs(fileName); ``` Whereas, this code works great... if I create the file this way, I can edit it no problem: ``` var wb = new XLWorkbook(); wb.Worksheets.Add("Sheet1"); var ws = wb.Worksheet(1); ws.Cell("A1").Value = dataTable.AsEnumerable(); wb.SaveAs(fileName); ``` Hope this helps you! Thx. Great library!
```
try
{
var workbook = new XLWorkbook(FILE_PATH);
}
catch (Exception ex)
{
throw;
}
```
Please provide a solution.
Comments: Solved the issue! See post above for details, but to simplify, this code didn't work when I tried to edit the file it created: ``` var wb = new XLWorkbook(); wb.Worksheets.Add(dataTable); wb.SaveAs(fileName); ``` Whereas, this code works great... if I create the file this way, I can edit it no problem: ``` var wb = new XLWorkbook(); wb.Worksheets.Add("Sheet1"); var ws = wb.Worksheet(1); ws.Cell("A1").Value = dataTable.AsEnumerable(); wb.SaveAs(fileName); ``` Hope this helps you! Thx. Great library!