Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: Setting the data type of a cell

$
0
0

I am brand new to C# and NPOI, so bare with me.

I am trying to set the cells for all numbers to 'number' in Excel.  

I have a method CreateExcel().  The styles are being created like this:

ICellStyle styAnswer = wb.CreateCellStyle();
styAnswer.BorderBottom = CellBorderType.MEDIUM;
styAnswer.BottomBorderColor =HSSFColor.GREY_40_PERCENT.index;
styAnswer.BorderTop = CellBorderType.MEDIUM;
styAnswer.TopBorderColor = HSSFColor.GREY_40_PERCENT.index;
styAnswer.BorderLeft = CellBorderType.MEDIUM;
styAnswer.LeftBorderColor = HSSFColor.GREY_40_PERCENT.index;
styAnswer.BorderRight = CellBorderType.MEDIUM;
styAnswer.RightBorderColor = HSSFColor.GREY_40_PERCENT.index;
styAnswer.WrapText = true;
styAnswer.FillForegroundColor = HSSFColor.YELLOW.index;
styAnswer.FillPattern = FillPatternType.SOLID_FOREGROUND;
styAnswer.WrapText = true;
styAnswer.SetFont(normalFont);
styAnswer.Alignment = HorizontalAlignment.CENTER;
styAnswer.VerticalAlignment = VerticalAlignment.CENTER;
The data type is then specified in a
foreach (SurveyQuestionEntity question in surveyDataModel.Questions)
{
    switch ((AnswerType)question.AnswerTypeId)
    {
        case AnswerType.Number:
        {
                //Where i Assume the code will gobreak;
         }
    }
}

How do I accomplish this


Viewing all articles
Browse latest Browse all 1621

Trending Articles