0

I was wondering if there is a way to keep the leading 0 while using SuperCsv.

My problem is that I have a few columns which have numbers with leading 0. I want to keep the 0, but excel keeps stripping it, I've also tried to append a few characters at the beginning of the number like ' = " but no good result.

Excel is displaying the first character which I've added at the beginning of the number, so the column value looks like =0222333111 , and that's because probably supercsv is wrapping the output between quotes.

I didn't find anything on the superCsv website and I guess I am not the only one who has this problem. Should I migrate the to an Excel Java lib, or there is a workaround?

4

2 に答える 2

0

CSV ファイル形式では、外部プログラムによるセルの処理方法を指定できません。先頭のゼロが CSV ファイルに書き込まれていても (まだ行っていない場合は確認してください)、Excel は、先頭のゼロが偶然そこにあると考えて破棄する可能性があります。

あらゆる種類の非表示の Unicode 文字を追加するなどの回避策がある場合でも、これは単なるハックであり、他のバージョンの Excel での動作が保証されていません。

したがって、CSV は要件に適したファイル形式ではないようです。別のファイル形式に切り替えるか、すべてのセルを数値ではなく文字列として扱うように Excel を構成します (後者が可能かどうかはわかりません)。

于 2013-07-11T08:14:59.193 に答える