We are trying to bold a row in excel , Visual studio 2008,
framework 3.5 NPOI 1.2.5.0 – getting compile error
Following is the code snippet,
ICellStyle style1 = templateWorkbook.CreateCellStyle();
style1.SetFont(font1);
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
HSSFFont font = (HSSFFont)hssfworkbook.CreateFont();
font.Boldweight = HSSFFont.BOLDWEIGHT_BOLD;
style1.SetFont(font1);
it is giving compile error on line where we have written
font.Boldweight = HSSFFont.BOLDWEIGHT_BOLD;
compile Error 2
'NPOI.HSSF.UserModel.HSSFFont' does not contain a definition for 'BOLDWEIGHT_BOLD'
C:\SampleApp\XLSFormatDotNet\XLSFormatingDLL\Class1.cs 301 60 XLSFormatingDLL
Sample codes on the internet show same syntax, but I am getting this compiler error, seems strange,
please help me. any suggestion welcome.
Regards
sham
HSSFFont is a class (see http://npoi.codeplex.com/SourceControl/changeset/view/64939#134674). The
Boldweightproperty is of typeshortand there is an enum to help you set the properties:You should try to do something like this:
Maybe they have changed from constants to enums and haven’t updated their samples.