Subject: Excel Export: How to set cell format to "Text"?
Date: 2018-11-13 19:13:05
From: iokevins
Source: excel-export-set-cell-format-text
----------------------------------------------------------------------

How do I set exported Excel cell format, from "General", to "Text"? 

I have cell values with numeric string data (e.g., "0123456789"). When I open the exported Excel file, I want Excel to display the cell format type as "Text". If left as type "General", the Excel export seems to turn the value into scientific notation and/or drops the leading zero.

What I've tried:

 1. oSheet.Item(iRowIterator, iColumnIterator).NumberFormat = ExcelFormatType.Text
 2. oSheet.Item(iRowIterator, iColumnIterator).NumberFormat = "Text"

Results:

 1. Sets NumberFormat to string "2"; Excel export shows format type = "Number" and value displayed as "0123456789.00"
 2. Sets NumberFormat to string "Text"; Excel export shows format type = "Number" and value displayed as "0123456789.00"

Thank you

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index