c# - Copy HSSFCellStyle to XSSFCellStyle in NPOI -


my input file .xls have read data, manipulate , write .xlsx file along styles.

so, using npoi hssf read .xls , npoi xssf generate .xlsx file. done data. have copy cell formats .xls , apply output file.

when write outputheaderstyle.clonestylefrom(inputheaderstyle); exception occurs inputheaderstyle of type hssfcellstyle , outputheaderstyle of type xssfcellstyle

can clone 1 xssfcellstyle another, not between hssfcellstyle , xssfcellstyle

outputheaderstyle.clonestylefrom((xssfcellstyle)inputheaderstyle); 

throws exception

unable cast object of type 'npoi.hssf.usermodel.hssfcellstyle' type 'npoi.xssf.usermodel.xssfcellstyle'

is there other way copy style?

well, cell style of .xls file hssfcellstyle , .xlsx file xssfcellstyle. there no direct way convert hssfcellstyle xssfcellstyle in npoi.

i managed program copying 1 one style individually.

_xssfstyle .borderleft = _hssfstyle .borderleft; _xssfstyle .borderright = _hssfstyle .borderright; _xssfstyle .bordertop = _hssfstyle .bordertop; _xssfstyle .borderbottom = _hssfstyle .borderbottom; _xssfstyle .fillforegroundcolor = npoi.hssf.util.hssfcolor.grey25percent.index; _xssfstyle .fillpattern = npoi.ss.usermodel.fillpattern.solidforeground; _xssfstyle .wraptext = _hssfstyle .wraptext; _xssfstyle .verticalalignment = _hssfstyle .verticalalignment; 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -