This project is read-only.

Need Generic CellStyle Class

Mar 3, 2010 at 3:55 PM

Hello,

I've just discovered NPOI and have immediately fallen in love.  However, I have one need that I can't find.  If it's available, please point me in the right direction.  Otherwise, consider this a feature request. 

I'm creating a generic class called ExcelDump that will be used to dump the data in a DataTable to an Excel file using NPOI.  Basically, I want to be able to pass a datatable and have the class parse out the column names to create a header with and then fill in the cells below the header with data from the DadtaTable.  I would also like to be able to let the style of the header and table body to be defined by the calling class (before the workbook is created) using properties on the ExcelDump class.  It seems that the only cell style class is HSSFCellStyle which requires some advance knowledge of the workbook.  If we had just a generic CellStyle class that allowed me to define all the fonts, colors, borders, etc. that could later be copied into an HSSFCellStyle class it would be very helpful.  Of course, I can create this class manually but it seems useful enough that it should be included.  Or perhaps a better implementation would be to create a parameterless constructor for HSSFCellStyle.

Thanks,

Ian

Mar 4, 2010 at 1:49 AM

I suggest you have a look at this: http://www.cnblogs.com/coolite/articles/NPOI_01.html. Although it's in Chinese, the code can be used to generate a xls from a dataset very easily. Hope it's helpful for you.