0

This seems like a super simple issue to resolve. The type or namespace 'Sheet' is simply not there, so I get the red underline with the above message.

I have included:

using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;//(i think it should be in here)

Code that has error:

HSSFWorkbook hssfworkbook;
hssfworkbook = new HSSFWorkbook();

Sheet sheet1 = hssfworkbook.CreateSheet("Sheet1");  //this causes the error

Oh and further down, same error here. 'Row' not defined.

Row row = sheet1.CreateRow(i);

Using MS Visual Studio 2013. (C#) Thanks.

miniparser
  • 107
  • 1
  • 6

1 Answers1

0

you need to typecast the ISheet interface returned by the CreateSheet method to HSSFSheet. Namespace should be NPOI.SS.UserModel:

HSSFWorkbook hssfworkbook= new HSSFWorkbook ();
HSSFSheet sheet1 = (HSSFSheet)hssfworkbook.CreateSheet("Sheet1");
var row = sheet1.CreateRow(0);
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
kumar chandraketu
  • 2,232
  • 2
  • 20
  • 25