C# excel write and read app with NPOI library

  • Thread starter Thread starter erkantan
  • Start date Start date
E

erkantan

Guest
I have visual studio 2008 and Excel 2007 . I want to write and read from excel file (.xlsx) with NPOI 2.0 library . I can create excel file but i want to open excel file it error (Excel found unreadable content in test.xlsx.Do you want to recover the contents of this workbook?)

My code block

XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = (XSSSheet) wb.CreateSheet("sheet");
for(int i = 0; i < 3; i++){

var r = sheet.CreateRow(i);

for(int j = 0; j < 2; j++){

r.CreateCell(j);

}

}

using(var fs = new FileStream("test.xlsx",FileMode.Create , FileAccess.Write)){

wb.write(fs);
}


I tried a lot of things but always same error. Normally i create .NET FrameWork 3.5 project i changed .NET FrameWork 2.0 but same error.What is the solution?

Continue reading...
 
Back
Top