We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

IWorksheet Range - Select All Cells > Right-click > Format Cells > Text

We have a legacy pivot table report that requires all cells to be formatted as text.  I'm trying to make sense of the following documentation but having trouble -

http://help.syncfusion.com/UG/Reporting/XlsIO/ASP.NET%20MVC/default.htm#!documents/numberformatting.htm

Basically, the manual steps in Excel would be

  1. Select All Cells
  2. Right-click > Format Cells
  3. Select "Text" format

Thanks for your assistance.


2 Replies

AW Adam Woodcock September 7, 2012 03:14 PM UTC

Once I had my IWorksheet defined.  Applying myWorkSheetName.Range.NumberFormat = "@" is what I was looking for.  

Now when I right-click in Excel > Format Cells, its applying the desired formatting.


RA Rajesh A Syncfusion Team September 10, 2012 06:31 AM UTC

Hi Adam,

Thank you for using the Syncfusion Products.

To apply the desired numberformat to all cells then, we need to mention the range. Please refer to the below code snippet which illustrates this. Also we have attached sample for you reference. Could you please try this and let us know if this helps you.

Case 1. //If we use the below code, blank cells has no effect.

      sheet.Range.NumberFormat = "@";

Case 2.  //Setting Number Format as Text.

      //WE need to mention the specified Range.         

      sheet.Range["A1:XF1000"].NumberFormat = "@";

Please find the sample for "formatting cells" from the below link and let us know if this helps you.

Sample link: Sample

Please let us know if you need any clarification.

Thanks and Regards,

Rajesh A.


Loader.
Live Chat Icon For mobile
Up arrow icon