1

I am using Aspose Cells and I need to convert a particular column to text format, as the column consists of both numbers and Text, by default the column is taken as number format. I have used

 Aspose.Cells.Style style = worksheet.Cells["A3"].GetStyle();
 style.Number = 49;
 worksheet.Cells["A3"].SetStyle(style);

the above code works only for particular Cell but I need to Set Text format entire column, I have tried using this

 Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()];
 style.Number = 49; //Sets the Text format.
 StyleFlag flag = new StyleFlag();  
 worksheet.Cells.ApplyColumnStyle(0, style, flag); 
 worksheet.Cells.ApplyColumnStyle(1, style, flag);

the above code not working. Is there any other way to fix this?

Thanks in Advance

Arun D
  • 444
  • 3
  • 7
  • 23

1 Answers1

1

I got solution for this,

        var workbook = new Workbook();
        var worksheet = workbook.Worksheets[0];
        Aspose.Cells.Style TextStyle = workbook.CreateStyle();
        TextStyle.Number = 49;
        StyleFlag TextFlag = new StyleFlag();
        TextFlag.NumberFormat = true;
        worksheet.Cells.Columns[0].ApplyStyle(TextStyle, TextFlag);
        worksheet.Cells.Columns[1].ApplyStyle(TextStyle, TextFlag);
Arun D
  • 444
  • 3
  • 7
  • 23
  • Correct Solution. Besides, you can always apply styles manually via Microsoft Excel and then reads them in memory via Aspose.Cells API and check the correct value of Style.Number or Style.Custom properties. Thank you. – shakeel Mar 17 '17 at 10:43