tags:

views:

55

answers:

1

I'm trying to use the NPOI library in a winforms app. I have referenced the latest NPOI dll in my project and tried to reproduce the examples gave by NPOI and found on SO:

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.CreateSheet("Sheet1");
        HSSFRow headerRow = sheet.CreateRow(0);

But this won't compile on my machine because HSSFWorkbook.CreateSheet() returns a NPOI.SS.UserModel.Sheet instead of a NPOI.SS.UserModel.HSSFSheet.

What am I missing here ?

+1  A: 

Try the following:

Sheet sheet = workbook.CreateSheet("Sheet1");
Row headerRow = sheet.CreateRow(0);

And include the namespace NPOI.SS.UserModel

Sheet and Row are actually interfaces, but don't have the I prefix (I presume) because this library is a port from Java.

amarsuperstar
This also seems to work. I haven't checked the detailed history but I guess they added the interfaces in the latest version.
DrDro