データの分析、グラフ作成、および通信のためのツールを備えた Microsoft 表計算ソフトウェアのファミリ
> <c r="B1" t="s">> <v>0</v>> </c>> sharedStrings.xml> <si>> <t>セルB1</t>> <rPh sb="0" eb="4">> <t>セルビーイチ</t>> </rPh>> <phoneticPr fontId="1"/>> </si>
Cell クラスの t 属性が "s" であるなら、
そのセルのタイプは「共有文字列」です。
Working with sheets (Open XML SDK)
引用:
> String values in a cell are not stored in the cell table > unless they are the result of a calculation. > Therefore, instead of seeing External Link: as the content > of the cell's v node, instead you see a zero-based index > into the shared string table where that string is stored > uniquely. > This is done to optimize load/save performance and to reduce > duplication of information. To determine whether the 0 in > v is a number or an index to a string, the cell's data type > must be examined. > When the data type indicates string, then it is an index > and not a numeric value.
引用:
> This element expresses the value contained in a cell.> If the cell contains a string, then this value is > an index into the shared string table, pointing to > the actual string value.> Otherwise, the value of the cell is expressed directly> in this element.> Cells containing formulas express the last calculated > result of the formula in this element.
つまり B1 セルの値は、共有文字列テーブルにおける
0 番目のノード( si 要素)で定義されている文字列である
ということです。
> このようなデータの並びはどのような時に発生するのか> ご存じの方いらっしゃいませんでしょうか?> このようなデータの並びになる手法がわかれば。と思いました。
手法も何も、ユーザーが Excel アプリケーションを使って
ワークシートを自由に編集した結果としてそのようになっている
だけではないでしょうか。
例えば、以下に示す通りの操作によって作成、保存されたブックにおいて、
それぞれの xml がどのように記述されることになるか確認してみて下さい。
- Excel を起動し、新規ブックを作成する。
- ワークシート[Sheet1]の B1 セルに "ABC" という文字列を入力する。
- ワークシート[Sheet1]の C1 セルに "DEF" という文字列を入力する。
- ワークシート[Sheet1]の A1 セルに "GHI" という文字列を入力する。
- 新規ワークシート[Sheet2]を挿入する。
- ワークシート[Sheet2]の A1 セルに "DEF" という文字列を入力する。
- そのブックに名前をつけて保存し、ブックを閉じる。
( xl/worksheets/sheet1.xml より抜粋)
<sheetData>
<row r="1" spans="1:3" x14ac:dyDescent="0.15">
<c r="A1" t="s">
<v>2</v>
</c>
<c r="B1" t="s">
<v>0</v>
</c>
<c r="C1" t="s">
<v>1</v>
</c>
</row>
</sheetData>
( xl/worksheets/sheet2.xml より抜粋)
<sheetData>
<row r="1" spans="1:1" x14ac:dyDescent="0.15">
<c r="A1" t="s">
<v>1</v>
</c>
</row>
</sheetData>
( xl/sharedStrings.xml より抜粋)
<si>
<t>ABC</t>
<phoneticPr fontId="1"/>
</si>
<si>
<t>DEF</t>
<phoneticPr fontId="1"/>
</si>
<si>
<t>GHI</t>
<phoneticPr fontId="1"/>
</si>
上記の結果から分かる通り、そのブック内のいずれかのセルに対して
新しい文字列が格納されるごとに、共有文字列テーブルに新規ノードが
追加され、そのインデックスがそのセルの v 要素にセットされます。
また、セルに対して入力された文字列が既に共有文字列テーブルに
存在する場合は、該当する共有文字列( n 番目のノード)の
インデックスがそのセルの v 要素にセットされます。