Hello...
I have NPOI 2.2.1 and I realized that when generating XLSX file and opening with Excel 2013, a message box telling that a problem was encountered but Excel could try to recover from it. When I click "Yes", the sheet is finally shown.
This is the code:
```
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet = workbook.CreateSheet(this.Title);
using (var exportData = new MemoryStream())
{
workbook.Write(exportData);
return exportData.GetBuffer();
}
```
As you see, I am only creating the workbook, adding a sheet and then returning the bytes array. That array is stored in file using this code:
```
string targetFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), String.Concat(btnExportar.Tag, "_", DateTime.Now.ToString("yyyyMMddHHmmss"), ".xlsx"));
System.IO.File.WriteAllBytes(targetFile, xls.GetExcelData());
```
With XLS files there is no problem.
Regards
Jaime
Comments: ** Comment from web user: VincentM **
I have NPOI 2.2.1 and I realized that when generating XLSX file and opening with Excel 2013, a message box telling that a problem was encountered but Excel could try to recover from it. When I click "Yes", the sheet is finally shown.
This is the code:
```
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet = workbook.CreateSheet(this.Title);
using (var exportData = new MemoryStream())
{
workbook.Write(exportData);
return exportData.GetBuffer();
}
```
As you see, I am only creating the workbook, adding a sheet and then returning the bytes array. That array is stored in file using this code:
```
string targetFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), String.Concat(btnExportar.Tag, "_", DateTime.Now.ToString("yyyyMMddHHmmss"), ".xlsx"));
System.IO.File.WriteAllBytes(targetFile, xls.GetExcelData());
```
With XLS files there is no problem.
Regards
Jaime
Comments: ** Comment from web user: VincentM **
The Error lies in the core.xml file located in the docProps directory in the generated XLSX file.
The <cp:coreProperties> tag written by Excel is converted to <coreProperties> when NPOI writes the file.
I don't know what to do to correct the source code...
Regards
VincentM