简体   繁体   中英

Cannot convert workbook to sheet in NPOI

I use NPOI 2.0.1 beta to import excel(xlsx) data to GridView .
Firstly , using this link , convert xlsx Worksheet format to xls Worksheet .
But , at the following line , it's show me error .

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

And here is a screen-shoot ,

在此处输入图片说明

How can I fix it ?
Or is there a better way ? Thanks In Advance :)

In NPOI 2.0, you should use ISheet and IWorkbook interface.

ISheet sheet = workbook.CreateSheet("Sheet1");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM