0

I have an excel sheet and each column in the excel sheet has different datatypes. One column in the excel sheet has values like

**Column name**
6%
10%
15%
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
<blankvalue>
FZDxxxCV
01
FZDLKMCV
FZDLKMCV
FZDLKMCV
FZDLKMCV

Note:"< blankvalue >" is an empty cell in the excel. now on importing the excel this particular column values becomes blank except the first 3 values which get converted to decimal as 0.06 , 0.10, 0.15. The type of the 1st 3 cells in excel is "Percentage" whereas the type of the other cells are "General". I also tried changing the connection string properties still no use. Any suggestions?

4

1 に答える 1

1

これは、Excel からデータをインポートする際の典型的な問題です。ADO プロバイダーは最初の数行に基づいてデータ型を推測し、最初の推測に適合しないものはすべて破棄されます。

あなたの場合、初期の行に基づいて列が数値であると推測し、FZDLKMCV値を破棄しています。

それは大きな苦痛であり、さまざまな解決策があります。この問題については、既に StackOverflow にたくさんあります。これらのリンクを試してください:

C# を使用して Excel スプレッドシートにアクセスすると、一部のセルで空白の値が返されることがある
Excel ファイルの OleDB 接続文字列に関するヘルプ
OleDB と混合 Excel データ型 : 欠落データ

于 2012-01-23T12:14:17.600 に答える