Kiran Reddy
Kiran Reddy

Reputation: 1125

DataGridView showing extra digits after importing excel sheet in windows application

Excel cell contain only $248.40 and it is set as currency format. But it is showing 284.3899 in DataGridView.

Can you please help how can i show as it is what ever excel sheet contain in DataGridView.

Upvotes: 2

Views: 518

Answers (2)

Talha
Talha

Reputation: 19262

Go to DataGridView Columns property. Select the Column(Cell) which you want to format. And in Appearances section, browse the button of DefaultCellStyle. A dialog form will be open. Here you can set the Format of your cell in the Format Property.

Set here the decimal format property '#.##'. This will set the property at Design time. If you want to set the property at runtime than see the answer of Vok.

More on numeric Formatting, Read MSDN

Upvotes: 2

Vok
Vok

Reputation: 467

The underlying value in the spreadsheet probably contains more digits.

You need to apply formatting to your datagridview

DataGridView.Columns[0].DefaultCellStyle.Format = "#.##"

Upvotes: 1

Related Questions