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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to format entire column

Thread ID:

Created:

Updated:

Platform:

Replies:

102281 Jan 17,2012 05:27 PM UTC Apr 28,2017 12:10 PM UTC ASP.NET Web Forms (Classic) 9
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On January 17, 2012 05:27 PM UTC

In Excel, I can select an entire column, right-click, select Format Cells and set the alignment or number format for the entire column. How do I do this in XlsIO?


Sridhar [Syncfusion]
Replied On January 18, 2012 11:52 AM UTC

Hi Jim Slater,

Thank you for using Syncfusion products.

We have an IRange array Columns property for selecting the entire column of the worksheet. We have given below the sample code snippet for your reference for setting the number format and cell style.

Code Snippet [C#]:

worksheet.Columns[0].NumberFormat = "#,###";
worksheet.Columns[0].CellStyle.ColorIndex = ExcelKnownColors.Black;

Please try the above code snipppet at your side and let us know if this helps you.

Please let me know if you require any further clarifications.

Thanks,
Sridhar.S



Gordon Hooton
Replied On January 10, 2013 12:44 AM UTC

Does similar apply when you need t convert a column of numbers to text ?

Thanks and regards

Sridhar [Syncfusion]
Replied On January 10, 2013 04:51 AM UTC

Hi Jim Slater,

Thank you so much for the update.

We can apply the text in the column of numbers using the following code.
 
Code Snippet[C#]:

 worksheet.Columns[0].Text = "Syncfusion";

Please try the above code snipppet at your side and let us know if this helps you.

Please let me know if you require any further clarifications.

Thanks,
Sridhar.S


Gordon Hooton
Replied On January 10, 2013 06:55 AM UTC

Thanks for the prompt reply.

Sorry - could have been clearer in my request.
What I was after was that I have a spreadsheet with a column of numbers, which I want is to have the same numbers formatted as text rather than numbers in that column.

Thanks and regards


Sridhar [Syncfusion]
Replied On January 10, 2013 08:54 AM UTC

Hi Jim Slater,
 
Thank you so much for the update.
 
Please use the following number format string to convert the column of numbers to an text format in an spreadsheet.
 
Code Snippet [C#]:
 workSheet.Columns[0].CellStyle.NumberFormat = "@";
 
Please try the above code and let us know if this solves the above reported problem at your side.
 
Please let me know if you require any further clarifications.
 
Thanks,
Sridhar.S

Gordon Hooton
Replied On January 10, 2013 09:57 PM UTC

Thanks for that - now another question - how do I do the reverse
I have a column that is all dates (except for the header) but when I export it to Excel the column is all text, and thereforehard to manipulate.

Is there a way to force the column to be in date format

Thanks and regards

Sridhar [Syncfusion]
Replied On January 17, 2013 09:33 AM UTC

Hi Gordon,

Thank you so much for the update.

Please use the below code snippet to set the custom date number format for the columns in the worksheet.

Code Snippet[C#]:
workSheet.Columns[0].CellStyle.NumberFormat ="m/d/yyyy";

Please take a look at the video to change the custom number format strings for the given data.

Video Link:
http://www.syncfusion.com/downloads/Support/DirectTrac/103072/Custom Format-459493620.zip

Note:The custom format string can be selected from the FormatCells windows dialog in MS Excel.

Please take a look at the video and let us know if this helps you.

If you are using ImportDataTable method to import the data to an excel worksheet please use the below overload method to import the data with their data types.

Code Syntax[C#]:

ImportDataTable(DataTable dataTable, bool isFieldNameShown, int firstRow, int firstColumn, bool preserveTypes);

 

Please take a look at the video, try the code snippets at your side and let us know if this helps you.

 

Please let me know if you have any concerns.

Thanks,
Sridhar.S


raman
Replied On April 27, 2017 07:30 AM UTC

In Case of Open Offfice

in One Column we have both type of values String and numeric. Numeric value to be shown as string.

Case 1
we have used Cell .NumberFormat = "@" , And if Value is Numberic it is shown at 1.00 , Please check Attached Image.
----------------------------------------------------------------------------------------------------------------------------
Case 2
If we use .NumberFormat = "General" , Then Value Numeric is shown 1 but right-aligned . we have set .CellStyle.HorizontalAlignment = Syncfusion.XlsIO.ExcelHAlign.HAlignLefteven then value is right aligned.
------------------------------------------------------------------------------------------------------------------------------
Case 3
if cell.NumberFormat = "text" , Then Also numeric values shown as 1.00
Thanks & regardsraman kumar

Abirami Varadharajan [Syncfusion]
Replied On April 28, 2017 12:10 PM UTC

Hi Raman, 
 
Please find the details for your queries below. 
 

Queries 

Details 

we have used Cell .NumberFormat = "@" , And if Value is Numberic it is shown at 1.00 , Please check Attached Image. 

  

If number format to a cell is applied as "@" in XlsIO, the numeric values is shown as 1 as in the below screen shot, which is the document generated using XlsIO and opened in Open Office 4.1.1. If your requirement is to set number as text, we recommend this option. 

  

 

  

Note: We don’t find any attachment from your update. 

If we use .NumberFormat = "General" , Then Value Numeric is shown 1 but right-aligned . we have set .CellStyle.HorizontalAlignment = Syncfusion.XlsIO.ExcelHAlign.HAlignLefteven then value is right aligned. 

  

Number with General format is always right aligned. This is the behavior in MS Excel and Open office. XlsIO also behaves similarly. 

  

If the HAlign is set to Left, then the values are left aligned when applied in XlsIO. 

  

If cell.NumberFormat = "text" , Then Also numeric values shown as 1.00 

The numeric value is shown as 1, not as 1.00. 

  

The above scenarios are applied in a sample and shared in the following link for further reference. 

  

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/XlsIO_Sample-1662801360.zip 

  

If the output of the given sample is not as in the above screen shot, then check your Open Office version and get back to us with necessary details. The issue might raise in a specific Open Office version. 

  

If the issue still persists, kindly modify the sample to reproduce the issue and send back to us to investigate further on this. 

 
Regards, 
Abirami. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;