简体   繁体   中英

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

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="@"; 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 ?

通过使用EntireColumn尝试

cell.EntireColumn.NumberFormat = "@";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM