Easy way to reproduce (SetCellValueInXlsx sample modified to provoque the error) :
Sorry for the title, I just realised that I didn't put the whole library name. I naturally refere to the XSSF namespace. I will try to change this title to make things clear for everyone ;)
using System;
using System.Collections.Generic;
using System.Text;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.IO;
namespace NPOI.Examples.XSSF.SetCellValuesInXlsx
{
class Program
{
static void Main(string[] args)
{
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet1 = workbook.CreateSheet("Sheet1");
sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
int x = 1;
for (int i = 1; i <= 15; i++)
{
IRow row = sheet1.CreateRow(i);
for (int j = 0; j < 15; j++)
{
//row.CreateCell(j).SetCellValue(x++);
Double dRandom = new Random(x++).NextDouble();
row.CreateCell(j).SetCellValue(dRandom);
}
}
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
}
}
}
When one tries to open the result file, Excel 2010 asks for a repair confirmation, and Excel 2003 refuses to open the file.Sorry for the title, I just realised that I didn't put the whole library name. I naturally refere to the XSSF namespace. I will try to change this title to make things clear for everyone ;)