Formating programmatically Excel cells from Scientific numeric to Text with C#

北城余情 提交于 2021-01-29 12:20:50

问题


I'm facing a problem after extracting data from my sqlServer dataBase to my Excel worksheet using Microsoft.Office.Interop.Excel reference. Numeric data are displayed in a scientific numeric format, instead of being displayed in a text format. I tried to format my cell this way, but still doesn't work : Microsoft.Office.Interop.Excel.Range cell= (Range) worksheet.Cells[rowNum, fieldNum]; cell.NumberFormat="@"; I tried even to set my cells format in my Input Excel file; which i'm actually using as a template for this program; as Number or Text but helplessly it's not working.

How can i fix please this problem ?


回答1:


try by using EntireColumn

cell.EntireColumn.NumberFormat = "@";


来源:https://stackoverflow.com/questions/25889016/formating-programmatically-excel-cells-from-scientific-numeric-to-text-with-c-sh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!