NpsExcelFormat is used to apply special formatting to Excel cells.
Sample Code:
var format1 = new NpsExcelFormat("","");
format1.SetFont("Arial",11,true,false,false,"black");
format1.SetAlignment("centre");
format1.SetVerticalAlignment("centre");
format1.SetBorder("all","thin");
format1.SetBackground("yellow");
format1.SetOrientation("vertical");
| NpsExcelFormat |
new(String type,String format_str) Constructor. 1.type=date, means a constructor which specifies a date format for cells which use this format object; 2.type=number, means a constructor which specifies a number format for cells which use this format object; 3.if any other value setted, format_str would be omitted. |
| void |
SetFont(String font_name,int point_size,boolean bold,boolean italic,boolean underline,String color) font_name: font name, such as 'Arial', 'Arial Black','Verdana', etc. point_size: the point size of font bold=true, means a bold font italic=true, means a italic font underline=true, means a underline font Color can be set to 'red', 'blue', 'yellow', 'green', 'grey', 'white', 'black' only. |
| void |
SetAlignment(String align) Sets the horizontal alignment for this format. left: Data cells with this alignment will appear at the left hand edge of the cell right: Data in cells with this alignment will be right aligned centre: Data in cells with this alignment will be centred justify: Data in cells with this alignment will be justified fill: Data in cells with this alignment will fill the cell |
| void |
SetVerticalAlignment(String align) Sets the vertical alignment for this format top: Cells with this specified vertical alignment will have their data aligned at the top bottom: Cells with this specified vertical alignment will have their data aligned at the bottom centre: Cells with this specified vertical alignment will have their data aligned centrally justify: Cells with this specified vertical alignment will have their data justified |
| void |
SetBorder(String border,String style) Sets the specified border for this format border: the border; style: the border line style The border parameter can be set to 'none','all','top','bottom','left' and 'right'; The style parameter can be set to 'none', 'thin', 'thick', 'dash_dot', 'dash_dot_dot', 'dashed', 'dotted', 'double', 'hair', 'medium', 'medium_dash_dot', 'medium_dash_dot_dot', 'medium_dashed', 'SLANTED_DASH_DOT' |
| void |
SetBackground(String color) Sets the background colour for this cell format The background could be 'red', 'blue', 'yellow', 'green', 'grey', 'white', 'black'. |
| void |
SetIndentation(int i) Sets the indentation of the cell text |
| void |
SetLocked(boolean b) Sets whether or not this XF record locks the cell. |
| void |
SetOrientation(String orientation) Sets the text orientation for this format. The orientation parameter could be 'vertical', 'horizontal'; |
| void |
SetShrinkToFit(boolean b) Sets the shrink to fit flag |
| void |
SetWrap(boolean wrap) Sets the wrap indicator for this format. |