0

I'm exporting the values in the grid to excel through C# code. When i open the exported excel, the string column is displayed as integer and the leading '0' in that field gets deleted. how to handle this.

1
  • What's the library that you're using for creating the excel file? Commented Mar 8, 2012 at 20:12

4 Answers 4

1

This isn't a programming issue; it's Excel's default way of displaying what it thinks are numbers.

It assumes that 00001 is a number and should be displayed as 1. Change your cells to display "Text" instead of numbers in Excel.

Sign up to request clarification or add additional context in comments.

Comments

0

I have no experience in making Excel files but when entering text in Excel you can write '00123. The ' makes the whole difference.

Comments

0

Style the TDs with mso-number-format:\@

Comments

0

A quick way to get around this is to prefix your cell value with an apostrophe.

Excel hides the apostrophe automatically and forces the text mode for the cell to Text

Try it directly in Excel and you'll see what I mean eg type '07799123477 into a cell with General text formatting (the default)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.